Merge pull request #1537 from tklauser/staticcheck
Fix issues found by staticcheck
This commit is contained in:
commit
882d8eaba6
|
@ -353,7 +353,6 @@ func joinCgroups(c *configs.Cgroup, pid int) error {
|
||||||
switch name {
|
switch name {
|
||||||
case "name=systemd":
|
case "name=systemd":
|
||||||
// let systemd handle this
|
// let systemd handle this
|
||||||
break
|
|
||||||
case "cpuset":
|
case "cpuset":
|
||||||
path, err := getSubsystemPath(c, name)
|
path, err := getSubsystemPath(c, name)
|
||||||
if err != nil && !cgroups.IsNotFound(err) {
|
if err != nil && !cgroups.IsNotFound(err) {
|
||||||
|
@ -363,7 +362,6 @@ func joinCgroups(c *configs.Cgroup, pid int) error {
|
||||||
if err := s.ApplyDir(path, c, pid); err != nil {
|
if err := s.ApplyDir(path, c, pid); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
break
|
|
||||||
default:
|
default:
|
||||||
_, err := join(c, name, pid)
|
_, err := join(c, name, pid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -596,6 +596,9 @@ func (c *linuxContainer) checkCriuVersion(minVersion string) error {
|
||||||
_, err := fmt.Sscanf(minVersion, "%d.%d.%d\n", &x, &y, &z) // 1.5.2
|
_, err := fmt.Sscanf(minVersion, "%d.%d.%d\n", &x, &y, &z) // 1.5.2
|
||||||
if err != nil {
|
if err != nil {
|
||||||
_, err = fmt.Sscanf(minVersion, "Version: %d.%d\n", &x, &y) // 1.6
|
_, err = fmt.Sscanf(minVersion, "Version: %d.%d\n", &x, &y) // 1.6
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Unable to parse the CRIU min version: %s", minVersion)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
versionReq = x*10000 + y*100 + z
|
versionReq = x*10000 + y*100 + z
|
||||||
|
|
||||||
|
@ -800,7 +803,6 @@ func (c *linuxContainer) Checkpoint(criuOpts *CriuOpts) error {
|
||||||
switch m.Device {
|
switch m.Device {
|
||||||
case "bind":
|
case "bind":
|
||||||
c.addCriuDumpMount(req, m)
|
c.addCriuDumpMount(req, m)
|
||||||
break
|
|
||||||
case "cgroup":
|
case "cgroup":
|
||||||
binds, err := getCgroupMounts(m)
|
binds, err := getCgroupMounts(m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -809,7 +811,6 @@ func (c *linuxContainer) Checkpoint(criuOpts *CriuOpts) error {
|
||||||
for _, b := range binds {
|
for _, b := range binds {
|
||||||
c.addCriuDumpMount(req, b)
|
c.addCriuDumpMount(req, b)
|
||||||
}
|
}
|
||||||
break
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -862,9 +863,8 @@ func (c *linuxContainer) restoreNetwork(req *criurpc.CriuReq, criuOpts *CriuOpts
|
||||||
veth.IfOut = proto.String(iface.HostInterfaceName)
|
veth.IfOut = proto.String(iface.HostInterfaceName)
|
||||||
veth.IfIn = proto.String(iface.Name)
|
veth.IfIn = proto.String(iface.Name)
|
||||||
req.Opts.Veths = append(req.Opts.Veths, veth)
|
req.Opts.Veths = append(req.Opts.Veths, veth)
|
||||||
break
|
|
||||||
case "loopback":
|
case "loopback":
|
||||||
break
|
// Do nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, i := range criuOpts.VethPairs {
|
for _, i := range criuOpts.VethPairs {
|
||||||
|
@ -954,7 +954,6 @@ func (c *linuxContainer) Restore(process *Process, criuOpts *CriuOpts) error {
|
||||||
switch m.Device {
|
switch m.Device {
|
||||||
case "bind":
|
case "bind":
|
||||||
c.addCriuRestoreMount(req, m)
|
c.addCriuRestoreMount(req, m)
|
||||||
break
|
|
||||||
case "cgroup":
|
case "cgroup":
|
||||||
binds, err := getCgroupMounts(m)
|
binds, err := getCgroupMounts(m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -963,7 +962,6 @@ func (c *linuxContainer) Restore(process *Process, criuOpts *CriuOpts) error {
|
||||||
for _, b := range binds {
|
for _, b := range binds {
|
||||||
c.addCriuRestoreMount(req, b)
|
c.addCriuRestoreMount(req, b)
|
||||||
}
|
}
|
||||||
break
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1153,7 +1151,6 @@ func (c *linuxContainer) criuSwrk(process *Process, req *criurpc.CriuReq, opts *
|
||||||
case t == criurpc.CriuReqType_FEATURE_CHECK:
|
case t == criurpc.CriuReqType_FEATURE_CHECK:
|
||||||
logrus.Debugf("Feature check says: %s", resp)
|
logrus.Debugf("Feature check says: %s", resp)
|
||||||
criuFeatures = resp.GetFeatures()
|
criuFeatures = resp.GetFeatures()
|
||||||
break
|
|
||||||
case t == criurpc.CriuReqType_NOTIFY:
|
case t == criurpc.CriuReqType_NOTIFY:
|
||||||
if err := c.criuNotifications(resp, process, opts, extFds, oob[:oobn]); err != nil {
|
if err := c.criuNotifications(resp, process, opts, extFds, oob[:oobn]); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -1295,6 +1292,9 @@ func (c *linuxContainer) criuNotifications(resp *criurpc.CriuResp, process *Proc
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
fds, err := unix.ParseUnixRights(&scm[0])
|
fds, err := unix.ParseUnixRights(&scm[0])
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
master := os.NewFile(uintptr(fds[0]), "orphan-pts-master")
|
master := os.NewFile(uintptr(fds[0]), "orphan-pts-master")
|
||||||
defer master.Close()
|
defer master.Close()
|
||||||
|
|
|
@ -807,7 +807,13 @@ func TestPassExtraFiles(t *testing.T) {
|
||||||
|
|
||||||
var stdout bytes.Buffer
|
var stdout bytes.Buffer
|
||||||
pipeout1, pipein1, err := os.Pipe()
|
pipeout1, pipein1, err := os.Pipe()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
pipeout2, pipein2, err := os.Pipe()
|
pipeout2, pipein2, err := os.Pipe()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
process := libcontainer.Process{
|
process := libcontainer.Process{
|
||||||
Cwd: "/",
|
Cwd: "/",
|
||||||
Args: []string{"sh", "-c", "cd /proc/$$/fd; echo -n *; echo -n 1 >3; echo -n 2 >4"},
|
Args: []string{"sh", "-c", "cd /proc/$$/fd; echo -n *; echo -n 1 >3; echo -n 2 >4"},
|
||||||
|
|
|
@ -431,7 +431,13 @@ func TestExecinPassExtraFiles(t *testing.T) {
|
||||||
|
|
||||||
var stdout bytes.Buffer
|
var stdout bytes.Buffer
|
||||||
pipeout1, pipein1, err := os.Pipe()
|
pipeout1, pipein1, err := os.Pipe()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
pipeout2, pipein2, err := os.Pipe()
|
pipeout2, pipein2, err := os.Pipe()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
inprocess := &libcontainer.Process{
|
inprocess := &libcontainer.Process{
|
||||||
Cwd: "/",
|
Cwd: "/",
|
||||||
Args: []string{"sh", "-c", "cd /proc/$$/fd; echo -n *; echo -n 1 >3; echo -n 2 >4"},
|
Args: []string{"sh", "-c", "cd /proc/$$/fd; echo -n *; echo -n 1 >3; echo -n 2 >4"},
|
||||||
|
|
Loading…
Reference in New Issue