Skip to content

Commit

Permalink
fix for staticcheck ST1005 warning
Browse files Browse the repository at this point in the history
ST1005 - Incorrectly formatted error string

Signed-off-by: Siarhiej Siemianczuk <[email protected]>
  • Loading branch information
binjip978 committed Dec 11, 2023
1 parent 7778d4d commit 17804e0
Show file tree
Hide file tree
Showing 46 changed files with 83 additions and 83 deletions.
2 changes: 1 addition & 1 deletion cmds/boot/fbnetboot/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ func getClientForBootfile(bootfile string) (*http.Client, error) {
client = &http.Client{}
debug("http client setup")
default:
return nil, fmt.Errorf("Scheme %s is unsupported", scheme)
return nil, fmt.Errorf("scheme %s is unsupported", scheme)
}
return client, nil
}
Expand Down
4 changes: 2 additions & 2 deletions cmds/boot/localboot/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func BootGrubMode(devices block.BlockDevices, baseMountpoint string, guid string
bootconfigs = append(bootconfigs, ScanGrubConfigs(devices, mountpoint.Path)...)
}
if len(bootconfigs) == 0 {
return fmt.Errorf("No boot configuration found")
return fmt.Errorf("no boot configuration found")
}
log.Printf("Found %d boot configs", len(bootconfigs))
for _, cfg := range bootconfigs {
Expand Down Expand Up @@ -189,7 +189,7 @@ func BootPathMode(devices block.BlockDevices, baseMountpoint string, guid string
log.Printf("Dry-run, will not actually boot")
} else {
if err := cfg.Boot(); err != nil {
return fmt.Errorf("Failed to boot kernel %s: %v", cfg.Kernel, err)
return fmt.Errorf("failed to boot kernel %s: %v", cfg.Kernel, err)
}
}
return nil
Expand Down
12 changes: 6 additions & 6 deletions cmds/core/cpio/cpio.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var (
d = flag.Bool("v", false, "Debug prints")
format = flag.String("H", "newc", "format")

errInvalidArgs = errors.New("Usage of the command:\ncpio o < name-list [> archive]\ncpio i [< archive]\ncpio p destination-directory < name-list\nOptions: -H format (default: newc) -v Debug prints ")
errInvalidArgs = errors.New("usage of the command:\ncpio o < name-list [> archive]\ncpio i [< archive]\ncpio p destination-directory < name-list\nOptions: -H format (default: newc) -v Debug prints ")
)

func run(args []string, stdin *os.File, stdout io.Writer, d bool, format string) error {
Expand All @@ -59,7 +59,7 @@ func run(args []string, stdin *os.File, stdout io.Writer, d bool, format string)

archiver, err := cpio.Format(format)
if err != nil {
return fmt.Errorf("Format %q not supported: %w", format, err)
return fmt.Errorf("format %q not supported: %w", format, err)
}

switch op {
Expand Down Expand Up @@ -132,18 +132,18 @@ func run(args []string, stdin *os.File, stdout io.Writer, d bool, format string)
name := scanner.Text()
rec, err := cr.GetRecord(name)
if err != nil {
return fmt.Errorf("Getting record of %q failed: %w", name, err)
return fmt.Errorf("getting record of %q failed: %w", name, err)
}
if err := rw.WriteRecord(rec); err != nil {
return fmt.Errorf("Writing record %q failed: %w", name, err)
return fmt.Errorf("writing record %q failed: %w", name, err)
}
}

if err := scanner.Err(); err != nil {
return fmt.Errorf("Error reading stdin: %w", err)
return fmt.Errorf("error reading stdin: %w", err)
}
if err := cpio.WriteTrailer(rw); err != nil {
return fmt.Errorf("Error writing trailer record: %w", err)
return fmt.Errorf("error writing trailer record: %w", err)
}

case "t":
Expand Down
6 changes: 3 additions & 3 deletions cmds/core/ip/ip_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,11 +361,11 @@ func run(out io.Writer) error {
case nil:
case error:
if strings.Contains(err.Error(), "index out of range") {
return fmt.Errorf("Args: %v, I got to arg %v, I wanted %v after that", arg, cursor, whatIWant)
return fmt.Errorf("args: %v, I got to arg %v, I wanted %v after that", arg, cursor, whatIWant)
} else if strings.Contains(err.Error(), "slice bounds out of range") {
return fmt.Errorf("Args: %v, I got to arg %v, I wanted %v after that", arg, cursor, whatIWant)
return fmt.Errorf("args: %v, I got to arg %v, I wanted %v after that", arg, cursor, whatIWant)
}
return fmt.Errorf("Bummer: %v", err)
return fmt.Errorf("bummer: %v", err)
default:
return fmt.Errorf("unexpected panic value: %T(%v)", err, err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmds/core/ping/ping_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func setupICMPv6Socket(c *net.IPConn) error {
}
// we want the stack to return us the network error if any occurred
if err := unix.SetsockoptInt(int(file.Fd()), unix.SOL_IPV6, unix.IPV6_RECVERR, 1); err != nil {
return fmt.Errorf("Failed to set sock opt IPV6_RECVERR: %w", err)
return fmt.Errorf("failed to set sock opt IPV6_RECVERR: %w", err)
}
return nil
}
2 changes: 1 addition & 1 deletion cmds/core/timeout/timeout.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ type cmd struct {

var (
timeout = flag.Duration("t", 30*time.Second, "Timeout for command")
errNoArgs = errors.New("Need at least a command to run")
errNoArgs = errors.New("need at least a command to run")
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion cmds/exp/ansi/ansi.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func ansi(w io.Writer, args []string) error {
if exists {
fmt.Fprintf(w, commands[arg])
} else {
return fmt.Errorf("Command ANSI '%v' don't exists", arg)
return fmt.Errorf("command ANSI '%v' don't exists", arg)
}
}
return nil
Expand Down
4 changes: 2 additions & 2 deletions cmds/exp/cbmem/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (o *offsetReader) ReadAt(b []byte, i int64) (int, error) {
n, err := o.r.ReadAt(b, i)
debug("\t... i %#x n %d err %v", i, n, err)
if err != nil && err != io.EOF {
return n, fmt.Errorf("Reading at #%x for %d bytes: %v", i, len(b), err)
return n, fmt.Errorf("reading at #%x for %d bytes: %v", i, len(b), err)
}
return n, err
}
Expand Down Expand Up @@ -80,7 +80,7 @@ func newOffsetReader(f *os.File, off int64, sz int) (*offsetReader, error) {
func readOneSize(r io.ReaderAt, i interface{}, o int64, n int64) error {
err := binary.Read(io.NewSectionReader(r, o, n), binary.LittleEndian, i)
if err != nil {
return fmt.Errorf("Trying to read section for %T: %v", r, err)
return fmt.Errorf("trying to read section for %T: %v", r, err)
}
return nil
}
Expand Down
6 changes: 3 additions & 3 deletions cmds/exp/console/console_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ func console(serial string) (io.Reader, io.Writer, error) {
case []byte(serial)[0] == '0':
u, err := openUART(serial)
if err != nil {
return nil, nil, fmt.Errorf("Console exits: sorry, can't get a uart: %v", err)
return nil, nil, fmt.Errorf("console exits: sorry, can't get a uart: %v", err)
}
in, out = u, u
case serial == "i8042":
u, err := openi8042()
if err != nil {
return nil, nil, fmt.Errorf("Console exits: sorry, can't get an i8042: %v", err)
return nil, nil, fmt.Errorf("console exits: sorry, can't get an i8042: %v", err)
}
in, out = u, os.Stdout
case serial == "stdio":
default:
return nil, nil, fmt.Errorf("Cconsole must be one of stdio, i8042, or an IO port with a leading 0 (e.g. 0x3f8)")
return nil, nil, fmt.Errorf("console must be one of stdio, i8042, or an IO port with a leading 0 (e.g. 0x3f8)")
}

return in, out, nil
Expand Down
2 changes: 1 addition & 1 deletion cmds/exp/dmidecode/dmidecode.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func parseTypeFilter(typeStrings []string) (map[smbios.TableType]bool, error) {
} else {
u, err := strconv.ParseUint(ts, 0, 8)
if err != nil {
return nil, fmt.Errorf("Invalid type: %s", ts)
return nil, fmt.Errorf("invalid type: %s", ts)
}
types[smbios.TableType(uint8(u))] = true
}
Expand Down
4 changes: 2 additions & 2 deletions cmds/exp/ectool/lpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (l *lpc) Command(c command, v version, idata []byte, outsize int, timeout t
l.Outb(l.status, 0xa5)

if err := l.Wait(10 * time.Second); err != nil {
return nil, errors.New("Timeout waiting for EC response")
return nil, errors.New("timeout waiting for EC response")
}

/* Check result */
Expand All @@ -96,7 +96,7 @@ func (l *lpc) Command(c command, v version, idata []byte, outsize int, timeout t
}

if i != 0 {
return nil, fmt.Errorf("Bad EC value %d", i)
return nil, fmt.Errorf("bad EC value %d", i)
}

/* Read back args */
Expand Down
4 changes: 2 additions & 2 deletions cmds/exp/nvme_unlock/nvme_unlock.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,11 @@ func run(disk string, verbose bool, verboseNoSanitize bool, noRereadPartitions b
}
diskdev, err := block.Device(disk)
if err != nil {
return fmt.Errorf("Could not find %s: %v", disk, err)
return fmt.Errorf("could not find %s: %v", disk, err)
}

if err := diskdev.ReadPartitionTable(); err != nil && !lock {
return fmt.Errorf("Could not re-read partition table: %v", err)
return fmt.Errorf("could not re-read partition table: %v", err)
}
return nil
}
Expand Down
6 changes: 3 additions & 3 deletions cmds/exp/rush/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,13 @@ func getCommand(b *bufio.Reader) (c []*Command, t string, err error) {
return nil, "", errors.New("empty commands not allowed (yet)")
}
if v.Link == "|" && v.fdmap[1] != "" {
return nil, "", errors.New("Can't have a pipe and > on one command")
return nil, "", errors.New("can't have a pipe and > on one command")
}
if v.Link == "|" && i == len(c)-1 {
return nil, "", errors.New("Can't have a pipe to nowhere")
return nil, "", errors.New("can't have a pipe to nowhere")
}
if i < len(c)-1 && v.Link == "|" && c[i+1].fdmap[0] != "" {
return nil, "", errors.New("Can't have a pipe to command with redirect on stdin")
return nil, "", errors.New("can't have a pipe to command with redirect on stdin")
}
}
return c, t, err
Expand Down
8 changes: 4 additions & 4 deletions cmds/exp/ssh/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ var (
// ssh config file
cfg *sshconfig.Config

errInvalidArgs = errors.New("Invalid command-line arguments")
errInvalidArgs = errors.New("invalid command-line arguments")
)

// loadConfig loads the SSH config file
Expand Down Expand Up @@ -135,7 +135,7 @@ func run(osArgs []string, stdin *os.File, stdout io.Writer, stderr io.Writer) er
}
config.Auth = []ssh.AuthMethod{ssh.PublicKeys(signer)}
} else if err != nil && *keyFile != "" {
return fmt.Errorf("Could not read user-specified keyfile %v: %v", kf, err)
return fmt.Errorf("could not read user-specified keyfile %v: %v", kf, err)
}
v("Config: %+v\n", config)
if term.IsTerminal(int(stdin.Fd())) {
Expand Down Expand Up @@ -164,7 +164,7 @@ func run(osArgs []string, stdin *os.File, stdout io.Writer, stderr io.Writer) er
if len(args) > 0 {
// run the command
if err := session.Run(strings.Join(args, " ")); err != nil {
return fmt.Errorf("Failed to run command: %v", err)
return fmt.Errorf("failed to run command: %v", err)
}
} else {
// Set up the terminal
Expand Down Expand Up @@ -227,7 +227,7 @@ func parseDest(input string) (user, host, port string, err error) {
port = "22"
}
if host == "" {
err = errors.New("No host specified")
err = errors.New("no host specified")
}
return
}
Expand Down
2 changes: 1 addition & 1 deletion cmds/exp/tcz/tcz.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func clonetree(tree string) error {
debug("Need to symlink %v to %v\n", path, path[lt:])

if err := os.Symlink(path, path[lt:]); err != nil {
return fmt.Errorf("Symlink: %v", err)
return fmt.Errorf("symlink: %v", err)
}

return nil
Expand Down
4 changes: 2 additions & 2 deletions pkg/acpi/acpi.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func getaddr(b []byte, addr64, addr32 int64) (int64, error) {
if err := binary.Read(io.NewSectionReader(bytes.NewReader(b), addr32, 4), binary.LittleEndian, &a32); err == nil {
return int64(a32), nil
}
return -1, fmt.Errorf("No 64-bit address at %d, no 32-bit address at %d, in %d-byte slice", addr64, addr32, len(b))
return -1, fmt.Errorf("no 64-bit address at %d, no 32-bit address at %d, in %d-byte slice", addr64, addr32, len(b))
}

// Method accepts a method name and returns a TableMethod if one exists, or error othewise.
Expand Down Expand Up @@ -112,7 +112,7 @@ func String(t Table) string {
func WriteTables(w io.Writer, tab Table, tabs ...Table) error {
for _, tt := range append([]Table{tab}, tabs...) {
if _, err := w.Write(tt.Data()); err != nil {
return fmt.Errorf("Writing %s: %v", tt.Sig(), err)
return fmt.Errorf("writing %s: %v", tt.Sig(), err)
}
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/acpi/acpi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func TestAddr(t *testing.T) {
val int64
err error
}{
{n: "zero length data", dat: []byte{}, a64: 5, a32: 1, val: -1, err: fmt.Errorf("No 64-bit address at 5, no 32-bit address at 1, in 0-byte slice")},
{n: "zero length data", dat: []byte{}, a64: 5, a32: 1, val: -1, err: fmt.Errorf("no 64-bit address at 5, no 32-bit address at 1, in 0-byte slice")},
{n: "32 bits at 1, no 64-bit", dat: []byte{1, 2, 3, 4, 5}, a64: 5, a32: 1, val: 84148994, err: nil},
{n: "64 bits at 5", dat: []byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}, a64: 5, a32: 1, val: 940138559942690566, err: nil},
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/acpi/fpdt/fpdt.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func ReadACPIFPDTTable() (acpi.Table, error) {
return t, nil
}
}
return nil, errors.New("Unable to find FPDT")
return nil, errors.New("unable to find FPDT")

}

Expand All @@ -47,7 +47,7 @@ func FindFBPTTableAdrr(t acpi.Table) (uint64, error) {
var addr uint64

if t.Sig() != "FPDT" {
return addr, fmt.Errorf("Wrong table type passed. Table Signature %s", t.Sig())
return addr, fmt.Errorf("wrong table type passed. Table Signature %s", t.Sig())
}

for i := 0; i < len(t.TableData()); i += int(t.TableData()[i+2]) {
Expand All @@ -58,7 +58,7 @@ func FindFBPTTableAdrr(t acpi.Table) (uint64, error) {
return addr, nil
}
}
return addr, errors.New("Unable to find FPBT Address")
return addr, errors.New("unable to find FPBT Address")
}

// ReadFPDTRecordHeader reads Header for records
Expand Down
2 changes: 1 addition & 1 deletion pkg/acpi/tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ func GetTable() (string, []Table, error) {
return m, t, nil
}
}
return "", nil, fmt.Errorf("Could not get ACPI tables")
return "", nil, fmt.Errorf("could not get ACPI tables")
}
2 changes: 1 addition & 1 deletion pkg/boot/bls/bls.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func parseLinuxImage(vals map[string]string, fsRoot string, variables map[string
// If it's not found, fallback to look for default_kernelopts
log.Printf("kernelopts is empty, look for default_kernelopts\n")
if value, err = getGrubvalue(variables, "default_kernelopts"); value == "" {
return nil, fmt.Errorf("No valid kernelopts is found")
return nil, fmt.Errorf("no valid kernelopts is found")
}
}
cmdlines = append(cmdlines, value)
Expand Down
2 changes: 1 addition & 1 deletion pkg/boot/bzimage/bzimage.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ func stripSignature(image []byte) ([]byte, error) {
}

// ErrKCodeMissing is returned if kernel code was not decompressed.
var ErrKCodeMissing = errors.New("No kernel code was decompressed")
var ErrKCodeMissing = errors.New("no kernel code was decompressed")

// MarshalBinary implements the encoding.BinaryMarshaler interface.
// The marshal'd image is *not* signed.
Expand Down
6 changes: 3 additions & 3 deletions pkg/boot/fit/vfit.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,14 @@ func parseHash(algo string) (crypto.Hash, error) {
})
algoSplit := strings.Split(cleaned, ",")
if len(algoSplit) == 0 {
return 0, fmt.Errorf("Unrecognized hash algo: '%s'", cleaned)
return 0, fmt.Errorf("unrecognized hash algo: '%s'", cleaned)
}
for _, alg := range algoSplit {
if matched, ok := algs[strings.ToUpper(alg)]; ok {
return matched, nil
}
}
return 0, fmt.Errorf("Unrecognized hash algo: '%s'", cleaned)
return 0, fmt.Errorf("unrecognized hash algo: '%s'", cleaned)
}

// parseSignatures parses dt.Node to RSASignatures
Expand Down Expand Up @@ -179,7 +179,7 @@ func parseSignatures(n ...*dt.Node) ([]Signature, error) {
}
}
if len(sigs) == 0 {
return nil, fmt.Errorf("Failed to parse any valid Signatures")
return nil, fmt.Errorf("failed to parse any valid Signatures")
}
return sigs, nil
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/boot/initrd.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,14 @@ func CreateInitrd(files ...string) (io.ReaderAt, error) {
for _, n := range files {
rec, err := cr.GetRecord(n)
if err != nil {
return nil, fmt.Errorf("Getting record of %q failed: %v", n, err)
return nil, fmt.Errorf("getting record of %q failed: %v", n, err)
}
if err := w.WriteRecord(rec); err != nil {
return nil, fmt.Errorf("Writing record %q failed: %v", n, err)
return nil, fmt.Errorf("writing record %q failed: %v", n, err)
}
}
if err := cpio.WriteTrailer(w); err != nil {
return nil, fmt.Errorf("Error writing trailer record: %v", err)
return nil, fmt.Errorf("error writing trailer record: %v", err)
}
return bytes.NewReader(b.Bytes()), nil
}
2 changes: 1 addition & 1 deletion pkg/boot/systembooter/bootentry.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var supportedBooterParsers = []func([]byte, ulog.Logger) (Booter, error){
NewLocalBooter,
}

var errNoBooterFound = errors.New("No booter found for entry")
var errNoBooterFound = errors.New("no booter found for entry")

// GetBooterFor looks for a supported Booter implementation and returns it, if
// found. If not found, error errNoBooterFound is returned.
Expand Down
2 changes: 1 addition & 1 deletion pkg/boot/zbi/zbi.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func (it *ZBIType) ToString() (string, error) {
if typeMetadata, ok := ZBITypes[*it]; ok {
return typeMetadata.Name, nil
}
return "", fmt.Errorf("Can't find metadata for %#08x ZBIType", it)
return "", fmt.Errorf("can't find metadata for %#08x ZBIType", it)
}

// MarshalJSON returns JSON bytes of current ZBIType.
Expand Down
Loading

0 comments on commit 17804e0

Please sign in to comment.