From b56cc49b3580ca2e0e6c49286dbed6c13c42e06e Mon Sep 17 00:00:00 2001 From: Ted Yu Date: Thu, 27 Feb 2020 16:59:01 -0800 Subject: [PATCH] Use named error return for initProcess#start Signed-off-by: Ted Yu --- libcontainer/process_linux.go | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/libcontainer/process_linux.go b/libcontainer/process_linux.go index de989b5bceb..937b392fd31 100644 --- a/libcontainer/process_linux.go +++ b/libcontainer/process_linux.go @@ -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 @@ -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 { @@ -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") }