Fixing some lint issues

Signed-off-by: Amim Knabben <amim.knabben@gmail.com>
This commit is contained in:
Amim Knabben
2020-10-02 23:12:29 -04:00
parent bb539a9965
commit 978fa6e906
13 changed files with 35 additions and 23 deletions
+3 -1
View File
@@ -105,7 +105,9 @@ func handleSingle(path string, noStdin bool) error {
if err != nil {
return err
}
console.ClearONLCR(c.Fd())
if err := console.ClearONLCR(c.Fd()); err != nil {
return err
}
// Copy from our stdio to the master fd.
quitChan := make(chan struct{})
-1
View File
@@ -374,7 +374,6 @@ func systemdVersion(conn *systemdDbus.Conn) (int, error) {
}
version, versionErr = systemdVersionAtoi(verStr)
return
})
return version, versionErr
+1 -1
View File
@@ -228,7 +228,7 @@ func checkHostNs(sysctlConfig string, path string) error {
return fmt.Errorf("could not check that %q is a symlink: %v", path, err)
}
if symLink == false {
if !symLink {
// The provided namespace is not a symbolic link,
// it is not the host namespace.
return nil
@@ -22,7 +22,9 @@ func TestValidate(t *testing.T) {
func TestValidateWithInvalidRootfs(t *testing.T) {
dir := "rootfs"
os.Symlink("/var", dir)
if err := os.Symlink("/var", dir); err != nil {
t.Fatal(err)
}
defer os.Remove(dir)
config := &configs.Config{
+1 -1
View File
@@ -1528,7 +1528,7 @@ func (c *linuxContainer) criuSwrk(process *Process, req *criurpc.CriuReq, opts *
buf := make([]byte, 10*4096)
oob := make([]byte, 4096)
for true {
for {
n, oobn, _, _, err := criuClientCon.ReadMsgUnix(buf, oob)
if req.Opts != nil && req.Opts.StatusFd != nil {
// Close status_fd as soon as we got something back from criu,
+2 -2
View File
@@ -235,7 +235,7 @@ func testCheckpoint(t *testing.T, userns bool) {
t.Fatal(err)
}
process, err = os.FindProcess(pid)
_, err = os.FindProcess(pid)
if err != nil {
t.Fatal(err)
}
@@ -255,7 +255,7 @@ func testCheckpoint(t *testing.T, userns bool) {
t.Fatal(s.String(), pid)
}
output := string(stdout.Bytes())
output := stdout.String()
if !strings.Contains(output, "Hello!") {
t.Fatal("Did not restore the pipe correctly:", output)
}
+6 -6
View File
@@ -279,10 +279,10 @@ func TestEnter(t *testing.T) {
waitProcess(&pconfig, t)
// Check that both processes live in the same pidns
pidns := string(stdout.Bytes())
pidns := stdout.String()
ok(t, err)
pidns2 := string(stdout2.Bytes())
pidns2 := stdout2.String()
ok(t, err)
if pidns != pidns2 {
@@ -325,7 +325,7 @@ func TestProcessEnv(t *testing.T) {
// Wait for process
waitProcess(&pconfig, t)
outputEnv := string(stdout.Bytes())
outputEnv := stdout.String()
// Check that the environment has the key/value pair we added
if !strings.Contains(outputEnv, "FOO=BAR") {
@@ -964,7 +964,7 @@ func TestPassExtraFiles(t *testing.T) {
waitProcess(&process, t)
out := string(stdout.Bytes())
out := stdout.String()
// fd 5 is the directory handle for /proc/$$/fd
if out != "0 1 2 3 4 5" {
t.Fatalf("expected to have the file descriptors '0 1 2 3 4 5' passed to init, got '%s'", out)
@@ -1501,7 +1501,7 @@ func TestRootfsPropagationSlaveMount(t *testing.T) {
mountPropagated = false
dir2cont = filepath.Join(dir1cont, filepath.Base(dir2host))
propagationInfo := string(stdout2.Bytes())
propagationInfo := stdout2.String()
lines := strings.Split(propagationInfo, "\n")
for _, l := range lines {
linefields := strings.Split(l, " ")
@@ -1892,7 +1892,7 @@ func TestTmpfsCopyUp(t *testing.T) {
// Wait for process
waitProcess(&pconfig, t)
outputLs := string(stdout.Bytes())
outputLs := stdout.String()
// Check that the ls output has /etc/passwd
if !strings.Contains(outputLs, "/etc/passwd") {
-1
View File
@@ -226,7 +226,6 @@ func init() {
if strings.HasPrefix(os.Args[0], "nsenter-") {
os.Exit(0)
}
return
}
func newPipe() (parent *os.File, child *os.File, err error) {
+3 -3
View File
@@ -49,7 +49,7 @@ var archs = map[string]string{
// Attempting to convert a string that is not a valid operator results in an
// error.
func ConvertStringToOperator(in string) (configs.Operator, error) {
if op, ok := operators[in]; ok == true {
if op, ok := operators[in]; ok {
return op, nil
}
return 0, fmt.Errorf("string %s is not a valid operator for seccomp", in)
@@ -62,7 +62,7 @@ func ConvertStringToOperator(in string) (configs.Operator, error) {
// Attempting to convert a string that is not a valid action results in an
// error.
func ConvertStringToAction(in string) (configs.Action, error) {
if act, ok := actions[in]; ok == true {
if act, ok := actions[in]; ok {
return act, nil
}
return 0, fmt.Errorf("string %s is not a valid action for seccomp", in)
@@ -70,7 +70,7 @@ func ConvertStringToAction(in string) (configs.Action, error) {
// ConvertStringToArch converts a string into a Seccomp comparison arch.
func ConvertStringToArch(in string) (string, error) {
if arch, ok := archs[in]; ok == true {
if arch, ok := archs[in]; ok {
return arch, nil
}
return "", fmt.Errorf("string %s is not a valid arch for seccomp", in)
+2 -2
View File
@@ -463,7 +463,7 @@ this is just some garbage data
t.Errorf("Parse(%#v) has error %v", test, err)
continue
}
sort.Sort(sort.IntSlice(gids))
sort.Ints(gids)
if !reflect.DeepEqual(gids, test.expected) {
t.Errorf("Gids(%v), expect %v from groups %v", gids, test.expected, test.groups)
}
@@ -499,7 +499,7 @@ func TestGetAdditionalGroupsNumeric(t *testing.T) {
t.Errorf("Parse(%#v) has error %v", test, err)
continue
}
sort.Sort(sort.IntSlice(gids))
sort.Ints(gids)
if !reflect.DeepEqual(gids, test.expected) {
t.Errorf("Gids(%v), expect %v from groups %v", gids, test.expected, test.groups)
}
+6 -2
View File
@@ -32,7 +32,9 @@ func TestSearchLabels(t *testing.T) {
func TestResolveRootfs(t *testing.T) {
dir := "rootfs"
os.Mkdir(dir, 0600)
if err := os.Mkdir(dir, 0600); err != nil {
t.Fatal(err)
}
defer os.Remove(dir)
path, err := ResolveRootfs(dir)
@@ -51,7 +53,9 @@ func TestResolveRootfs(t *testing.T) {
func TestResolveRootfsWithSymlink(t *testing.T) {
dir := "rootfs"
tmpDir, _ := filepath.EvalSymlinks(os.TempDir())
os.Symlink(tmpDir, dir)
if err := os.Symlink(tmpDir, dir); err != nil {
t.Fatal(err)
}
defer os.Remove(dir)
path, err := ResolveRootfs(dir)
+4 -1
View File
@@ -162,7 +162,10 @@ func (n *notifySocket) run(pid1 int) error {
// now we can inform systemd to use pid1 as the pid to monitor
newPid := "MAINPID=" + strconv.Itoa(pid1)
client.Write([]byte(newPid + "\n"))
_, err := client.Write([]byte(newPid + "\n"))
if err != nil {
return err
}
return nil
}
}
+4 -1
View File
@@ -112,7 +112,10 @@ func (t *tty) recvtty(process *libcontainer.Process, socket *os.File) (Err error
if err != nil {
return err
}
console.ClearONLCR(cons.Fd())
err = console.ClearONLCR(cons.Fd())
if err != nil {
return err
}
epoller, err := console.NewEpoller()
if err != nil {
return err