Skip to content

Commit

Permalink
Use named error return for initProcess#start
Browse files Browse the repository at this point in the history
Signed-off-by: Ted Yu <[email protected]>
  • Loading branch information
tedyu committed Feb 28, 2020
1 parent 688cf6d commit b56cc49
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions libcontainer/process_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ func (p *initProcess) waitForChildExit(childPid int) error {
return nil
}

func (p *initProcess) start() error {
func (p *initProcess) start() (retErr error) {
defer p.messageSockPair.parent.Close()
err := p.cmd.Start()
p.process.ops = p
Expand All @@ -302,7 +302,7 @@ func (p *initProcess) start() error {
}
}
defer func() {
if err != nil {
if retErr != nil {
// TODO: should not be the responsibility to call here
p.manager.Destroy()
if p.intelRdtManager != nil {
Expand Down Expand Up @@ -349,15 +349,6 @@ func (p *initProcess) start() error {
return newSystemErrorWithCause(err, "waiting for our first child to exit")
}

defer func() {
if err != nil {
// TODO: should not be the responsibility to call here
p.manager.Destroy()
if p.intelRdtManager != nil {
p.intelRdtManager.Destroy()
}
}
}()
if err := p.createNetworkInterfaces(); err != nil {
return newSystemErrorWithCause(err, "creating network interfaces")
}
Expand Down

0 comments on commit b56cc49

Please sign in to comment.