From 3ef7f7c65081ad354b0b949b33557f86b0e8867a Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Mon, 5 Aug 2019 16:56:38 -0700 Subject: [PATCH] daemon/monitor: rm redundant if The last check for err != nil is not needed as err is always non-nil there. Remove the check. Also, no need to explicitly define `var err error` here. Signed-off-by: Kir Kolyshkin --- daemon/monitor.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/daemon/monitor.go b/daemon/monitor.go index c294742884..b8d32c39a9 100644 --- a/daemon/monitor.go +++ b/daemon/monitor.go @@ -202,15 +202,13 @@ func (daemon *Daemon) autoRemove(c *container.Container) { return } - var err error - if err = daemon.ContainerRm(c.ID, &types.ContainerRmConfig{ForceRemove: true, RemoveVolume: true}); err == nil { + err := daemon.ContainerRm(c.ID, &types.ContainerRmConfig{ForceRemove: true, RemoveVolume: true}) + if err == nil { return } if c := daemon.containers.Get(c.ID); c == nil { return } - if err != nil { - logrus.WithError(err).WithField("container", c.ID).Error("error removing container") - } + logrus.WithError(err).WithField("container", c.ID).Error("error removing container") }