From 17804e0a2ab49ae3a196e3763147fffab7658077 Mon Sep 17 00:00:00 2001 From: Siarhiej Siemianczuk Date: Sat, 9 Dec 2023 11:11:45 +0200 Subject: [PATCH] fix for staticcheck ST1005 warning ST1005 - Incorrectly formatted error string Signed-off-by: Siarhiej Siemianczuk --- cmds/boot/fbnetboot/main.go | 2 +- cmds/boot/localboot/main.go | 4 ++-- cmds/core/cpio/cpio.go | 12 ++++++------ cmds/core/ip/ip_linux.go | 6 +++--- cmds/core/ping/ping_linux.go | 2 +- cmds/core/timeout/timeout.go | 2 +- cmds/exp/ansi/ansi.go | 2 +- cmds/exp/cbmem/io.go | 4 ++-- cmds/exp/console/console_linux.go | 6 +++--- cmds/exp/dmidecode/dmidecode.go | 2 +- cmds/exp/ectool/lpc.go | 4 ++-- cmds/exp/nvme_unlock/nvme_unlock.go | 4 ++-- cmds/exp/rush/parse.go | 6 +++--- cmds/exp/ssh/main.go | 8 ++++---- cmds/exp/tcz/tcz.go | 2 +- pkg/acpi/acpi.go | 4 ++-- pkg/acpi/acpi_test.go | 2 +- pkg/acpi/fpdt/fpdt.go | 6 +++--- pkg/acpi/tables.go | 2 +- pkg/boot/bls/bls.go | 2 +- pkg/boot/bzimage/bzimage.go | 2 +- pkg/boot/fit/vfit.go | 6 +++--- pkg/boot/initrd.go | 6 +++--- pkg/boot/systembooter/bootentry.go | 2 +- pkg/boot/zbi/zbi.go | 2 +- pkg/curl/schemes_test.go | 2 +- pkg/dt/fdt.go | 2 +- pkg/efivarfs/vars.go | 2 +- pkg/fb/fb.go | 4 ++-- pkg/forth/forth.go | 2 +- pkg/logutil/logutil.go | 2 +- pkg/mount/block/blockdev_linux.go | 10 +++++----- pkg/msr/msr_linux.go | 2 +- pkg/pci/pci_linux.go | 2 +- pkg/txtlog/pcr_event.go | 2 +- pkg/txtlog/txtlog.go | 4 ++-- pkg/uefivars/boot/efiDevicePathProtocol.go | 4 ++-- pkg/uefivars/boot/efiDevicePathProtocol_test.go | 2 +- pkg/uefivars/vars.go | 2 +- pkg/vmtest/integration.go | 4 ++-- pkg/watchdog/watchdog.go | 4 ++-- pkg/watchdog/watchdog_test.go | 4 ++-- pkg/watchdogd/watchdogd.go | 6 +++--- tools/vpdbootmanager/add.go | 2 +- tools/vpdbootmanager/main.go | 2 +- u-root.go | 2 +- 46 files changed, 83 insertions(+), 83 deletions(-) diff --git a/cmds/boot/fbnetboot/main.go b/cmds/boot/fbnetboot/main.go index 3489ed782f..30fecb51de 100644 --- a/cmds/boot/fbnetboot/main.go +++ b/cmds/boot/fbnetboot/main.go @@ -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 } diff --git a/cmds/boot/localboot/main.go b/cmds/boot/localboot/main.go index 93038d0601..03f3986121 100644 --- a/cmds/boot/localboot/main.go +++ b/cmds/boot/localboot/main.go @@ -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 { @@ -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 diff --git a/cmds/core/cpio/cpio.go b/cmds/core/cpio/cpio.go index 765f475a8f..bc11e9f76d 100644 --- a/cmds/core/cpio/cpio.go +++ b/cmds/core/cpio/cpio.go @@ -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 { @@ -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 { @@ -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": diff --git a/cmds/core/ip/ip_linux.go b/cmds/core/ip/ip_linux.go index c1e6c52f2e..eed65dc927 100644 --- a/cmds/core/ip/ip_linux.go +++ b/cmds/core/ip/ip_linux.go @@ -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) } diff --git a/cmds/core/ping/ping_linux.go b/cmds/core/ping/ping_linux.go index e9808ff1ae..f53f5a2686 100644 --- a/cmds/core/ping/ping_linux.go +++ b/cmds/core/ping/ping_linux.go @@ -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 } diff --git a/cmds/core/timeout/timeout.go b/cmds/core/timeout/timeout.go index 3ff6332e4b..5ccfca326b 100644 --- a/cmds/core/timeout/timeout.go +++ b/cmds/core/timeout/timeout.go @@ -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() { diff --git a/cmds/exp/ansi/ansi.go b/cmds/exp/ansi/ansi.go index ae70f6c248..4f0f2692e9 100644 --- a/cmds/exp/ansi/ansi.go +++ b/cmds/exp/ansi/ansi.go @@ -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 diff --git a/cmds/exp/cbmem/io.go b/cmds/exp/cbmem/io.go index e891bd3c6c..b6c158214d 100644 --- a/cmds/exp/cbmem/io.go +++ b/cmds/exp/cbmem/io.go @@ -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 } @@ -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 } diff --git a/cmds/exp/console/console_linux.go b/cmds/exp/console/console_linux.go index 115b3c1fa6..31861c9200 100644 --- a/cmds/exp/console/console_linux.go +++ b/cmds/exp/console/console_linux.go @@ -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 diff --git a/cmds/exp/dmidecode/dmidecode.go b/cmds/exp/dmidecode/dmidecode.go index a32535d746..5e1ffd5be7 100644 --- a/cmds/exp/dmidecode/dmidecode.go +++ b/cmds/exp/dmidecode/dmidecode.go @@ -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 } diff --git a/cmds/exp/ectool/lpc.go b/cmds/exp/ectool/lpc.go index c88774009f..cb6014522d 100644 --- a/cmds/exp/ectool/lpc.go +++ b/cmds/exp/ectool/lpc.go @@ -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 */ @@ -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 */ diff --git a/cmds/exp/nvme_unlock/nvme_unlock.go b/cmds/exp/nvme_unlock/nvme_unlock.go index 616c19c4ff..1b32af9137 100644 --- a/cmds/exp/nvme_unlock/nvme_unlock.go +++ b/cmds/exp/nvme_unlock/nvme_unlock.go @@ -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 } diff --git a/cmds/exp/rush/parse.go b/cmds/exp/rush/parse.go index eaeb6d1f61..530d876efa 100644 --- a/cmds/exp/rush/parse.go +++ b/cmds/exp/rush/parse.go @@ -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 diff --git a/cmds/exp/ssh/main.go b/cmds/exp/ssh/main.go index 8141ef0541..a3654e8bdd 100644 --- a/cmds/exp/ssh/main.go +++ b/cmds/exp/ssh/main.go @@ -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 @@ -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())) { @@ -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 @@ -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 } diff --git a/cmds/exp/tcz/tcz.go b/cmds/exp/tcz/tcz.go index 391d4b22c3..5eac928bbd 100644 --- a/cmds/exp/tcz/tcz.go +++ b/cmds/exp/tcz/tcz.go @@ -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 diff --git a/pkg/acpi/acpi.go b/pkg/acpi/acpi.go index 4f20582738..6a63daa341 100644 --- a/pkg/acpi/acpi.go +++ b/pkg/acpi/acpi.go @@ -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. @@ -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 diff --git a/pkg/acpi/acpi_test.go b/pkg/acpi/acpi_test.go index e670606542..b9c8aaec6a 100644 --- a/pkg/acpi/acpi_test.go +++ b/pkg/acpi/acpi_test.go @@ -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}, } diff --git a/pkg/acpi/fpdt/fpdt.go b/pkg/acpi/fpdt/fpdt.go index 84c6513b05..f512323e42 100755 --- a/pkg/acpi/fpdt/fpdt.go +++ b/pkg/acpi/fpdt/fpdt.go @@ -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") } @@ -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]) { @@ -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 diff --git a/pkg/acpi/tables.go b/pkg/acpi/tables.go index 92707285be..7e626444c6 100644 --- a/pkg/acpi/tables.go +++ b/pkg/acpi/tables.go @@ -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") } diff --git a/pkg/boot/bls/bls.go b/pkg/boot/bls/bls.go index 4c4497e608..a98b96c69a 100644 --- a/pkg/boot/bls/bls.go +++ b/pkg/boot/bls/bls.go @@ -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) diff --git a/pkg/boot/bzimage/bzimage.go b/pkg/boot/bzimage/bzimage.go index a5dbafa78d..d1eed75099 100644 --- a/pkg/boot/bzimage/bzimage.go +++ b/pkg/boot/bzimage/bzimage.go @@ -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. diff --git a/pkg/boot/fit/vfit.go b/pkg/boot/fit/vfit.go index 72f124a7e2..0fcd4ea6af 100644 --- a/pkg/boot/fit/vfit.go +++ b/pkg/boot/fit/vfit.go @@ -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 @@ -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 } diff --git a/pkg/boot/initrd.go b/pkg/boot/initrd.go index c6feceded9..984beab264 100644 --- a/pkg/boot/initrd.go +++ b/pkg/boot/initrd.go @@ -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 } diff --git a/pkg/boot/systembooter/bootentry.go b/pkg/boot/systembooter/bootentry.go index 6420ddff66..b4158f2bbc 100644 --- a/pkg/boot/systembooter/bootentry.go +++ b/pkg/boot/systembooter/bootentry.go @@ -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. diff --git a/pkg/boot/zbi/zbi.go b/pkg/boot/zbi/zbi.go index 90232419cc..5d82a24c7f 100644 --- a/pkg/boot/zbi/zbi.go +++ b/pkg/boot/zbi/zbi.go @@ -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. diff --git a/pkg/curl/schemes_test.go b/pkg/curl/schemes_test.go index 1e9c3e653e..42d61041f2 100644 --- a/pkg/curl/schemes_test.go +++ b/pkg/curl/schemes_test.go @@ -19,7 +19,7 @@ import ( ) var ( - errTest = errors.New("Test error") + errTest = errors.New("test error") testURL = &url.URL{ Scheme: "fooftp", Host: "192.168.0.1", diff --git a/pkg/dt/fdt.go b/pkg/dt/fdt.go index 2a4189173e..9947a81c2b 100644 --- a/pkg/dt/fdt.go +++ b/pkg/dt/fdt.go @@ -444,7 +444,7 @@ func WithFileName(n string) FDTReader { } // ErrNoValidReaders indicates that no readers succeeded. -var ErrNoValidReaders = errors.New("No FDT readers succeeded") +var ErrNoValidReaders = errors.New("no FDT readers succeeded") // New returns a new FDT, trying each FDTReader in turn // until it succeeds or all have failed. It will return diff --git a/pkg/efivarfs/vars.go b/pkg/efivarfs/vars.go index 2369e87e47..009c6668df 100644 --- a/pkg/efivarfs/vars.go +++ b/pkg/efivarfs/vars.go @@ -45,7 +45,7 @@ type VariableDescriptor struct { var ( // ErrBadGUID is for any errors parsing GUIDs. - ErrBadGUID = errors.New("Bad GUID") + ErrBadGUID = errors.New("bad GUID") ) func guidParse(v string) ([]string, *guid.UUID, error) { diff --git a/pkg/fb/fb.go b/pkg/fb/fb.go index fcde8c7f87..e57ed68498 100644 --- a/pkg/fb/fb.go +++ b/pkg/fb/fb.go @@ -62,7 +62,7 @@ func DrawImageAt(img image.Image, posx int, posy int) error { DrawOnBufAt(buf, img, posx, posy, stride, bpp) err = os.WriteFile(fbdev, buf, 0o600) if err != nil { - return fmt.Errorf("Error writing to framebuffer: %v", err) + return fmt.Errorf("error writing to framebuffer: %v", err) } return nil } @@ -103,7 +103,7 @@ func DrawScaledImageAt(img image.Image, posx int, posy int, factor int) error { DrawScaledOnBufAt(buf, img, posx, posy, factor, stride, bpp) err = os.WriteFile(fbdev, buf, 0o600) if err != nil { - return fmt.Errorf("Error writing to framebuffer: %v", err) + return fmt.Errorf("error writing to framebuffer: %v", err) } return nil } diff --git a/pkg/forth/forth.go b/pkg/forth/forth.go index d95276134a..cc4571a900 100644 --- a/pkg/forth/forth.go +++ b/pkg/forth/forth.go @@ -131,7 +131,7 @@ func Putop(n string, op Op) { mapLock.Lock() defer mapLock.Unlock() if _, ok := opmap[n]; ok { - panic(fmt.Errorf("Putting %s: %w", n, ErrWordExist)) + panic(fmt.Errorf("putting %s: %w", n, ErrWordExist)) } opmap[n] = op } diff --git a/pkg/logutil/logutil.go b/pkg/logutil/logutil.go index 272b4e1d15..24e645bc03 100644 --- a/pkg/logutil/logutil.go +++ b/pkg/logutil/logutil.go @@ -45,7 +45,7 @@ func TeeOutput(writer io.Writer, maxSize int) (io.Writer, error) { // CreateTeeWriter tees out output to a file path specified by logPath up to a max limit. Creates necessary directories for the specified logpath if they don't exist. func CreateTeeWriter(writer io.Writer, logPath string, maxSize int) (io.Writer, error) { if logPath == "" { - return nil, fmt.Errorf("Empty log path") + return nil, fmt.Errorf("empty log path") } dir := filepath.Dir(logPath) if err := os.MkdirAll(dir, 0700); err != nil { diff --git a/pkg/mount/block/blockdev_linux.go b/pkg/mount/block/blockdev_linux.go index 25d4e9ae7b..b3a7f6f5aa 100644 --- a/pkg/mount/block/blockdev_linux.go +++ b/pkg/mount/block/blockdev_linux.go @@ -219,7 +219,7 @@ func (b *BlockDev) PCIInfo() (*pci.PCI, error) { vp = filepath.Join(p, "vendor") } if !found { - return nil, fmt.Errorf("Unable to find backing pci device with device and vendor files for %v", b.Name) + return nil, fmt.Errorf("unable to find backing pci device with device and vendor files for %v", b.Name) } return pci.OnePCI(p) @@ -661,19 +661,19 @@ func parsePCIList(parseList string) (pci.Devices, error) { for _, b := range bL { p := strings.Split(b, ":") if len(p) != 2 { - return nil, fmt.Errorf("Parsing device list %q: %w", parseList, ErrListFormat) + return nil, fmt.Errorf("parsing device list %q: %w", parseList, ErrListFormat) } // Check that values are hex and convert them to sysfs formats // This accepts 0xABCD and turns it into 0xabcd // abcd also turns into 0xabcd v, err := strconv.ParseUint(strings.TrimPrefix(p[0], "0x"), 16, 16) if err != nil { - return nil, fmt.Errorf("Parsing pci device %q:%w", p[0], err) + return nil, fmt.Errorf("parsing pci device %q:%w", p[0], err) } d, err := strconv.ParseUint(strings.TrimPrefix(p[1], "0x"), 16, 16) if err != nil { - return nil, fmt.Errorf("Parsing pci device %q:%w", p[1], err) + return nil, fmt.Errorf("parsing pci device %q:%w", p[1], err) } pciList = append(pciList, &pci.PCI{Vendor: uint16(v), Device: uint16(d)}) @@ -713,5 +713,5 @@ func GetMountpointByDevice(devicePath string) (*string, error) { } } - return nil, errors.New("Mountpoint not found") + return nil, errors.New("mountpoint not found") } diff --git a/pkg/msr/msr_linux.go b/pkg/msr/msr_linux.go index 098784ccb6..4a234dd4f1 100644 --- a/pkg/msr/msr_linux.go +++ b/pkg/msr/msr_linux.go @@ -277,7 +277,7 @@ func Locked() error { vendor := cpuid.VendorIdentificatorString // TODO: support more than Intel. Use the vendor id to look up msrs. if vendor != "GenuineIntel" { - return fmt.Errorf("Sorry, this package only supports Intel at present") + return fmt.Errorf("sorry, this package only supports Intel at present") } cpus, err := AllCPUs() diff --git a/pkg/pci/pci_linux.go b/pkg/pci/pci_linux.go index de39132127..b516578f4f 100644 --- a/pkg/pci/pci_linux.go +++ b/pkg/pci/pci_linux.go @@ -80,7 +80,7 @@ func OnePCI(dir string) (*PCI, error) { // It's not clear how this can happen, if ever; could someone // hotunplug a device while we are scanning? if err != nil { - return nil, fmt.Errorf("Scanning resource %d(%s): %v", i, dir, err) + return nil, fmt.Errorf("scanning resource %d(%s): %v", i, dir, err) } if b == 0 { continue diff --git a/pkg/txtlog/pcr_event.go b/pkg/txtlog/pcr_event.go index 9cf8dfad87..07b40b10d8 100644 --- a/pkg/txtlog/pcr_event.go +++ b/pkg/txtlog/pcr_event.go @@ -411,7 +411,7 @@ func getEventDataString(eventType uint32, eventData []byte) (*string, error) { } eventInfo := string(bytes.Trim(eventData, "\x00")) - return &eventInfo, errors.New("Event type couldn't get parsed") + return &eventInfo, errors.New("event type couldn't get parsed") } func stripControlSequences(str string) string { diff --git a/pkg/txtlog/txtlog.go b/pkg/txtlog/txtlog.go index 72ad3bdb2c..e0d00d34a9 100644 --- a/pkg/txtlog/txtlog.go +++ b/pkg/txtlog/txtlog.go @@ -64,7 +64,7 @@ func ParseLog(firmware FirmwareType, tpmSpec tss.TPMVersion) (*PCRLog, error) { } } default: - return nil, errors.New("No valid TPM specification found") + return nil, errors.New("no valid TPM specification found") } return pcrLog, nil @@ -158,7 +158,7 @@ func readTPM2Log(firmware FirmwareType) (*PCRLog, error) { if err != nil { return nil, err } - return nil, errors.New("First event was not an EFI SpecID Event") + return nil, errors.New("first event was not an EFI SpecID Event") } pcrLog.PcrList = append(pcrLog.PcrList, pcrEvent) diff --git a/pkg/uefivars/boot/efiDevicePathProtocol.go b/pkg/uefivars/boot/efiDevicePathProtocol.go index 5a309dfe48..7524709ab4 100644 --- a/pkg/uefivars/boot/efiDevicePathProtocol.go +++ b/pkg/uefivars/boot/efiDevicePathProtocol.go @@ -20,7 +20,7 @@ var ( Verbose bool ErrParse = errors.New("parse error") - ErrNotFound = errors.New("Described device not found") + ErrNotFound = errors.New("described device not found") // ErrUnimpl is returned when we do not implement the Device Path // Protocol entry type, because the Device Path Protocol is used for @@ -29,7 +29,7 @@ var ( // // There are probably others which can be used for boot entries, but are // not implemented simply because they have not been needed yet. - ErrUnimpl = errors.New("Not implemented") + ErrUnimpl = errors.New("not implemented") ) // ParseFilePathList decodes a FilePathList as found in a boot var. diff --git a/pkg/uefivars/boot/efiDevicePathProtocol_test.go b/pkg/uefivars/boot/efiDevicePathProtocol_test.go index b054a34b8d..0a2ec2d850 100644 --- a/pkg/uefivars/boot/efiDevicePathProtocol_test.go +++ b/pkg/uefivars/boot/efiDevicePathProtocol_test.go @@ -56,7 +56,7 @@ func TestParseFilePathList(t *testing.T) { if gotdesc != wantdesc { t.Errorf("mismatch\nwant %s\n got %s", wantdesc, gotdesc) } - expectedOutput := "Described device not found\n/EFI/BOOT/BOOTX64.EFI\n" + expectedOutput := "described device not found\n/EFI/BOOT/BOOTX64.EFI\n" resolveFailed := false var output string for _, p := range b.FilePathList { diff --git a/pkg/uefivars/vars.go b/pkg/uefivars/vars.go index cc821977ea..1335f27750 100644 --- a/pkg/uefivars/vars.go +++ b/pkg/uefivars/vars.go @@ -108,7 +108,7 @@ func (vars EfiVars) Filter(filt VarFilter) EfiVars { // https://gist.github.com/bradleypeabody/185b1d7ed6c0c2ab6cec func DecodeUTF16(b []byte) (string, error) { if len(b)%2 != 0 { - return "", fmt.Errorf("Must have even length byte slice") + return "", fmt.Errorf("must have even length byte slice") } u16s := make([]uint16, 1) diff --git a/pkg/vmtest/integration.go b/pkg/vmtest/integration.go index 031f584be2..ed02fabb28 100644 --- a/pkg/vmtest/integration.go +++ b/pkg/vmtest/integration.go @@ -373,7 +373,7 @@ func CreateTestInitramfs(o uroot.Opts, uinit, outputFile string) (string, error) if len(o.TempDir) == 0 { tempDir, err := os.MkdirTemp("", "initramfs-tempdir") if err != nil { - return "", fmt.Errorf("Failed to create temp dir: %v", err) + return "", fmt.Errorf("failed to create temp dir: %v", err) } defer os.RemoveAll(tempDir) o.TempDir = tempDir @@ -389,7 +389,7 @@ func CreateTestInitramfs(o uroot.Opts, uinit, outputFile string) (string, error) } w, err := initramfs.CPIO.OpenWriter(logger, outputFile) if err != nil { - return "", fmt.Errorf("Failed to create initramfs writer: %v", err) + return "", fmt.Errorf("failed to create initramfs writer: %v", err) } o.OutputFile = w diff --git a/pkg/watchdog/watchdog.go b/pkg/watchdog/watchdog.go index ae5c225ab7..97f8ccc15a 100644 --- a/pkg/watchdog/watchdog.go +++ b/pkg/watchdog/watchdog.go @@ -197,7 +197,7 @@ func (w *Watchdog) SetTimeout(timeout time.Duration) error { } gotTimeout := to * time.Second if gotTimeout != timeout { - return fmt.Errorf("Watchdog timeout set to %v, wanted %v", gotTimeout, timeout) + return fmt.Errorf("watchdog timeout set to %v, wanted %v", gotTimeout, timeout) } return nil } @@ -221,7 +221,7 @@ func (w *Watchdog) SetPreTimeout(timeout time.Duration) error { } gotTimeout := to * time.Second if gotTimeout != timeout { - return fmt.Errorf("Watchdog pretimeout set to %v, wanted %v", gotTimeout, timeout) + return fmt.Errorf("watchdog pretimeout set to %v, wanted %v", gotTimeout, timeout) } return nil } diff --git a/pkg/watchdog/watchdog_test.go b/pkg/watchdog/watchdog_test.go index b4177b409c..3750be8594 100644 --- a/pkg/watchdog/watchdog_test.go +++ b/pkg/watchdog/watchdog_test.go @@ -273,7 +273,7 @@ func TestSetTimeoutError(t *testing.T) { m := mockDog{} wd.syscalls = &m - wantErr := errors.New("Watchdog timeout set to 0s, wanted 5ns") + wantErr := errors.New("watchdog timeout set to 0s, wanted 5ns") if err := wd.SetTimeout(5); err != nil { if !strings.Contains(err.Error(), wantErr.Error()) { @@ -301,7 +301,7 @@ func TestSetPreTimeoutError(t *testing.T) { m := mockDog{} wd.syscalls = &m - wantErr := errors.New("Watchdog pretimeout set to 0s, wanted 5ns") + wantErr := errors.New("watchdog pretimeout set to 0s, wanted 5ns") if err := wd.SetPreTimeout(5); err != nil { if !strings.Contains(err.Error(), wantErr.Error()) { diff --git a/pkg/watchdogd/watchdogd.go b/pkg/watchdogd/watchdogd.go index d48ee6dd08..b8f6dd7ff3 100644 --- a/pkg/watchdogd/watchdogd.go +++ b/pkg/watchdogd/watchdogd.go @@ -271,7 +271,7 @@ func Run(ctx context.Context, opts *DaemonOpts) error { d := New(opts) l, cleanup, err := setupListener(d.CurrentOpts.UDS) if err != nil { - return fmt.Errorf("Failed to setup server: %v", err) + return fmt.Errorf("failed to setup server: %v", err) } go func() { log.Println("Start serving.") @@ -280,11 +280,11 @@ func Run(ctx context.Context, opts *DaemonOpts) error { log.Println("Start arming watchdog initially.") if r := d.ArmWatchdog(); r != OpResultOk { - return fmt.Errorf("Initial arm failed") + return fmt.Errorf("initial arm failed") } if r := d.StartPetting(); r != OpResultOk { - return fmt.Errorf("Start petting failed") + return fmt.Errorf("start petting failed") } for { diff --git a/tools/vpdbootmanager/add.go b/tools/vpdbootmanager/add.go index 0921a99a6a..6165333418 100644 --- a/tools/vpdbootmanager/add.go +++ b/tools/vpdbootmanager/add.go @@ -144,7 +144,7 @@ func addBootEntry(cfg systembooter.Booter, vpdDir string) error { return err } } - return errors.New("Maximum number of boot entries already set") + return errors.New("maximum number of boot entries already set") } func set(key string, value string) error { diff --git a/tools/vpdbootmanager/main.go b/tools/vpdbootmanager/main.go index d2b5e65d1e..bdb8fced63 100644 --- a/tools/vpdbootmanager/main.go +++ b/tools/vpdbootmanager/main.go @@ -83,5 +83,5 @@ func cli(args []string) error { case "dump": return dump() } - return fmt.Errorf("Unrecognized action") + return fmt.Errorf("unrecognized action") } diff --git a/u-root.go b/u-root.go index 13729e7543..e9ccaeef34 100644 --- a/u-root.go +++ b/u-root.go @@ -40,7 +40,7 @@ func (m *multiFlag) Set(value string) error { // errors from the u-root command var ( - ErrEmptyFilesArg = errors.New("Empty argument to -files") + ErrEmptyFilesArg = errors.New("empty argument to -files") ) // Flags for u-root builder.