Skip to content

Commit

Permalink
Fix stylecheck linter issues
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Obbard <[email protected]>
  • Loading branch information
obbardc committed Jul 22, 2023
1 parent b230a2f commit 0b1f3b8
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion backend_qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (b qemuBackend) KernelRelease() (string, error) {
}
}

return "", fmt.Errorf("No kernel found")
return "", fmt.Errorf("kernel not found")
}

func (b qemuBackend) KernelPath() (string, error) {
Expand Down
4 changes: 2 additions & 2 deletions backend_uml.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (b umlBackend) Supported() (bool, error) {
}

func (b umlBackend) KernelRelease() (string, error) {
return "", errors.New("Not implemented")
return "", errors.New("not implemented")
}

func (b umlBackend) KernelPath() (string, error) {
Expand Down Expand Up @@ -162,7 +162,7 @@ func (b umlBackend) Start() (bool, error) {
// one of the sockets will be attached to the slirp-helper
slirpHelperSocket := os.NewFile(uintptr(netSocketpair[0]), "")
if slirpHelperSocket == nil {
return false, fmt.Errorf("Creation of slirpHelperSocket failed")
return false, fmt.Errorf("creation of slirpHelperSocket failed")
}
defer slirpHelperSocket.Close()

Expand Down
4 changes: 2 additions & 2 deletions cmd/fakemachine/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func SetupEnviron(m *fakemachine.Machine, options Options) {
// These are the environment variables that will be detected on the
// host and propagated to fakemachine. These are listed lower case, but
// they are detected and configured in both lower case and upper case.
var environ_vars = [...]string{
var environVars = [...]string{
"http_proxy",
"https_proxy",
"ftp_proxy",
Expand All @@ -101,7 +101,7 @@ func SetupEnviron(m *fakemachine.Machine, options Options) {
}

// First add variables from host
for _, e := range environ_vars {
for _, e := range environVars {
lowerVar := strings.ToLower(e) // lowercase not really needed
lowerVal := os.Getenv(lowerVar)
if lowerVal != "" {
Expand Down
6 changes: 3 additions & 3 deletions decompressors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ func decompressorTest(t *testing.T, file, suffix string, d writerhelper.Transfor
return
}

check_f, err := os.Open(path.Join("testdata", file))
checkFile, err := os.Open(path.Join("testdata", file))
if err != nil {
t.Errorf("Unable to open check data: %s", err)
return
}
defer check_f.Close()
defer checkFile.Close()

err = checkStreamsMatch(t, output, check_f)
err = checkStreamsMatch(t, output, checkFile)
if err != nil {
t.Errorf("Failed to compare streams: %s", err)
return
Expand Down
18 changes: 9 additions & 9 deletions machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (m *Machine) copyModules(w *writerhelper.WriterHelper, modname string, copi
release, _ := m.backend.KernelRelease()
modpath := getModPath(modname, release)
if modpath == "" {
return errors.New("Modules path couldn't be determined")
return errors.New("modules path couldn't be determined")
}

if modpath == "(builtin)" || copiedModules[modname] {
Expand Down Expand Up @@ -124,7 +124,7 @@ func (m *Machine) copyModules(w *writerhelper.WriterHelper, modname string, copi
}
}
if !found {
return errors.New("Module extension/suffix unknown")
return errors.New("module extension/suffix unknown")
}

copiedModules[modname] = true
Expand Down Expand Up @@ -405,12 +405,12 @@ func (m *Machine) CreateImageWithLabel(path string, size int64, label string) (s
}

if len(label) >= 20 {
return "", fmt.Errorf("Label '%s' too long; cannot be more then 20 characters", label)
return "", fmt.Errorf("label '%s' too long; cannot be more then 20 characters", label)
}

for _, image := range m.images {
if image.label == label {
return "", fmt.Errorf("Label '%s' already exists", label)
return "", fmt.Errorf("label '%s' already exists", label)
}
}

Expand Down Expand Up @@ -506,7 +506,7 @@ func stripCompressionSuffix(module string) (string, error) {
return strings.TrimSuffix(module, suffix) + ".ko", nil
}
}
return "", errors.New("Module extension/suffix unknown")
return "", errors.New("module extension/suffix unknown")
}

func (m *Machine) generateModulesDep(w *writerhelper.WriterHelper, moddir string, modules map[string]bool) error {
Expand Down Expand Up @@ -601,17 +601,17 @@ func (m *Machine) startup(command string, extracontent [][2]string) (int, error)
/* Check the directory exists on the host */
stat, err := os.Stat(v.hostDirectory)
if err != nil || !stat.IsDir() {
return -1, fmt.Errorf("Couldn't mount %s inside machine: expected a directory", v.hostDirectory)
return -1, fmt.Errorf("couldn't mount %s inside machine: expected a directory", v.hostDirectory)
}

/* Check for whitespace in the machine directory */
if regexp.MustCompile(`\s`).MatchString(v.machineDirectory) {
return -1, fmt.Errorf("Couldn't mount %s inside machine: machine directory (%s) contains whitespace", v.hostDirectory, v.machineDirectory)
return -1, fmt.Errorf("couldn't mount %s inside machine: machine directory (%s) contains whitespace", v.hostDirectory, v.machineDirectory)
}

/* Check for whitespace in the label */
if regexp.MustCompile(`\s`).MatchString(v.label) {
return -1, fmt.Errorf("Couldn't mount %s inside machine: label (%s) contains whitespace", v.hostDirectory, v.label)
return -1, fmt.Errorf("couldn't mount %s inside machine: label (%s) contains whitespace", v.hostDirectory, v.label)
}
}

Expand Down Expand Up @@ -877,7 +877,7 @@ func (m *Machine) RunInMachineWithArgs(args []string) (int, error) {
executable, err := exec.LookPath(os.Args[0])

if err != nil {
return -1, fmt.Errorf("Failed to find executable: %w\n", err)
return -1, fmt.Errorf("failed to find executable: %w", err)
}

return m.startup(command, [][2]string{{executable, name}})
Expand Down

0 comments on commit 0b1f3b8

Please sign in to comment.