Skip to content

Commit

Permalink
various cleanups to address linter issues
Browse files Browse the repository at this point in the history
Signed-off-by: Dominik Süß <dominik@suess.wtf>
  • Loading branch information
theSuess committed Oct 13, 2018
1 parent 398f670 commit 0b412e9
Show file tree
Hide file tree
Showing 16 changed files with 23 additions and 78 deletions.
5 changes: 1 addition & 4 deletions checkpoint.go
Expand Up @@ -71,10 +71,7 @@ checkpointed.`,
if err := setEmptyNsMask(context, options); err != nil {
return err
}
if err := container.Checkpoint(options); err != nil {
return err
}
return nil
return container.Checkpoint(options)
},
}

Expand Down
3 changes: 1 addition & 2 deletions delete.go
Expand Up @@ -80,9 +80,8 @@ status of "ubuntu01" as "stopped" the following will delete resources held for
default:
if force {
return killContainer(container)
} else {
return fmt.Errorf("cannot delete container %s that is not stopped: %s\n", id, s)
}
return fmt.Errorf("cannot delete container %s that is not stopped: %s\n", id, s)
}

return nil
Expand Down
5 changes: 1 addition & 4 deletions kill.go
Expand Up @@ -51,10 +51,7 @@ signal to the init process of the "ubuntu01" container:
if err != nil {
return err
}
if err := container.Signal(signal, context.Bool("all")); err != nil {
return err
}
return nil
return container.Signal(signal, context.Bool("all"))
},
}

Expand Down
12 changes: 2 additions & 10 deletions libcontainer/cgroups/fs/cpu.go
Expand Up @@ -46,11 +46,7 @@ func (s *CpuGroup) ApplyDir(path string, cgroup *configs.Cgroup, pid int) error
}
// because we are not using d.join we need to place the pid into the procs file
// unlike the other subsystems
if err := cgroups.WriteCgroupProc(path, pid); err != nil {
return err
}

return nil
return cgroups.WriteCgroupProc(path, pid)
}

func (s *CpuGroup) SetRtSched(path string, cgroup *configs.Cgroup) error {
Expand Down Expand Up @@ -83,11 +79,7 @@ func (s *CpuGroup) Set(path string, cgroup *configs.Cgroup) error {
return err
}
}
if err := s.SetRtSched(path, cgroup); err != nil {
return err
}

return nil
return s.SetRtSched(path, cgroup)
}

func (s *CpuGroup) Remove(d *cgroupData) error {
Expand Down
6 changes: 1 addition & 5 deletions libcontainer/cgroups/fs/cpuset.go
Expand Up @@ -84,11 +84,7 @@ func (s *CpusetGroup) ApplyDir(dir string, cgroup *configs.Cgroup, pid int) erro

// because we are not using d.join we need to place the pid into the procs file
// unlike the other subsystems
if err := cgroups.WriteCgroupProc(dir, pid); err != nil {
return err
}

return nil
return cgroups.WriteCgroupProc(dir, pid)
}

func (s *CpusetGroup) getSubsystemSettings(parent string) (cpus []byte, mems []byte, err error) {
Expand Down
5 changes: 1 addition & 4 deletions libcontainer/container_linux.go
Expand Up @@ -399,10 +399,7 @@ func (c *linuxContainer) createExecFifo() error {
return err
}
unix.Umask(oldMask)
if err := os.Chown(fifoName, rootuid, rootgid); err != nil {
return err
}
return nil
return os.Chown(fifoName, rootuid, rootgid)
}

func (c *linuxContainer) deleteExecFifo() {
Expand Down
12 changes: 2 additions & 10 deletions libcontainer/init_linux.go
Expand Up @@ -218,11 +218,7 @@ func syncParentReady(pipe io.ReadWriter) error {
}

// Wait for parent to give the all-clear.
if err := readSync(pipe, procRun); err != nil {
return err
}

return nil
return readSync(pipe, procRun)
}

// syncParentHooks sends to the given pipe a JSON payload which indicates that
Expand All @@ -235,11 +231,7 @@ func syncParentHooks(pipe io.ReadWriter) error {
}

// Wait for parent to give the all-clear.
if err := readSync(pipe, procResume); err != nil {
return err
}

return nil
return readSync(pipe, procResume)
}

// setupUser changes the groups, gid, and uid for the user inside the container
Expand Down
5 changes: 1 addition & 4 deletions libcontainer/integration/exec_test.go
Expand Up @@ -1263,10 +1263,7 @@ func TestSTDIOPermissions(t *testing.T) {
}

func unmountOp(path string) error {
if err := unix.Unmount(path, unix.MNT_DETACH); err != nil {
return err
}
return nil
return unix.Unmount(path, unix.MNT_DETACH)
}

// Launch container with rootfsPropagation in rslave mode. Also
Expand Down
6 changes: 1 addition & 5 deletions libcontainer/keys/keyctl.go
Expand Up @@ -44,9 +44,5 @@ func ModKeyringPerm(ringId KeySerial, mask, setbits uint32) error {

perm := (uint32(perm64) & mask) | setbits

if err := unix.KeyctlSetperm(int(ringId), perm); err != nil {
return err
}

return nil
return unix.KeyctlSetperm(int(ringId), perm)
}
5 changes: 1 addition & 4 deletions libcontainer/rootfs_linux.go
Expand Up @@ -828,10 +828,7 @@ func remount(m *configs.Mount, rootfs string) error {
if !strings.HasPrefix(dest, rootfs) {
dest = filepath.Join(rootfs, dest)
}
if err := unix.Mount(m.Source, dest, m.Device, uintptr(m.Flags|unix.MS_REMOUNT), ""); err != nil {
return err
}
return nil
return unix.Mount(m.Source, dest, m.Device, uintptr(m.Flags|unix.MS_REMOUNT), "")
}

// Do the mount operation followed by additional mounts required to take care
Expand Down
2 changes: 1 addition & 1 deletion libcontainer/standard_init_linux.go
Expand Up @@ -52,7 +52,7 @@ func (l *linuxStandardInit) Init() error {
// If keyrings aren't supported then it is likely we are on an
// older kernel (or inside an LXC container). While we could bail,
// the security feature we are using here is best-effort (it only
// really provides marignal protection since VFS credentials are
// really provides marginal protection since VFS credentials are
// the only significant protection of keyrings).
//
// TODO(cyphar): Log this so people know what's going on, once we
Expand Down
5 changes: 1 addition & 4 deletions libcontainer/sync.go
Expand Up @@ -41,10 +41,7 @@ type syncT struct {
// writeSync is used to write to a synchronisation pipe. An error is returned
// if there was a problem writing the payload.
func writeSync(pipe io.Writer, sync syncType) error {
if err := utils.WriteJSON(pipe, syncT{sync}); err != nil {
return err
}
return nil
return utils.WriteJSON(pipe, syncT{sync})
}

// readSync is used to read from a synchronisation pipe. An error is returned
Expand Down
10 changes: 5 additions & 5 deletions notify_socket.go
Expand Up @@ -37,8 +37,8 @@ func newNotifySocket(context *cli.Context, notifySocketHost string, id string) *
return notifySocket
}

func (ns *notifySocket) Close() error {
return ns.socket.Close()
func (s *notifySocket) Close() error {
return s.socket.Close()
}

// If systemd is supporting sd_notify protocol, this function will add support
Expand Down Expand Up @@ -66,16 +66,16 @@ func (s *notifySocket) setupSocket() error {

// pid1 must be set only with -d, as it is used to set the new process as the main process
// for the service in systemd
func (notifySocket *notifySocket) run(pid1 int) {
func (s *notifySocket) run(pid1 int) {
buf := make([]byte, 512)
notifySocketHostAddr := net.UnixAddr{Name: notifySocket.host, Net: "unixgram"}
notifySocketHostAddr := net.UnixAddr{Name: s.host, Net: "unixgram"}
client, err := net.DialUnix("unixgram", nil, &notifySocketHostAddr)
if err != nil {
logrus.Error(err)
return
}
for {
r, err := notifySocket.socket.Read(buf)
r, err := s.socket.Read(buf)
if err != nil {
break
}
Expand Down
12 changes: 2 additions & 10 deletions pause.go
Expand Up @@ -22,11 +22,7 @@ Use runc list to identiy instances of containers and their current status.`,
if err != nil {
return err
}
if err := container.Pause(); err != nil {
return err
}

return nil
return container.Pause()
},
}

Expand All @@ -48,10 +44,6 @@ Use runc list to identiy instances of containers and their current status.`,
if err != nil {
return err
}
if err := container.Resume(); err != nil {
return err
}

return nil
return container.Resume()
},
}
3 changes: 1 addition & 2 deletions signals.go
Expand Up @@ -69,9 +69,8 @@ func (h *signalHandler) forward(process *libcontainer.Process, tty *tty, detach
if detach {
h.notifySocket.run(pid1)
return 0, nil
} else {
go h.notifySocket.run(0)
}
go h.notifySocket.run(0)
}

// Perform the initial tty resize. Always ignore errors resizing because
Expand Down
5 changes: 1 addition & 4 deletions spec.go
Expand Up @@ -107,10 +107,7 @@ generate a proper rootless spec file.`,
if err != nil {
return err
}
if err := ioutil.WriteFile(specConfig, data, 0666); err != nil {
return err
}
return nil
return ioutil.WriteFile(specConfig, data, 0666)
},
}

Expand Down

0 comments on commit 0b412e9

Please sign in to comment.