From c8395b6e535214cd559fb8567810d65cd08081cc Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Wed, 10 Jul 2024 16:03:34 -0700 Subject: [PATCH] Enable govet nilness, fix an issue The code already checked if err == nil above, so the linter complains: > libcontainer/container_linux.go:534:18: nilness: tautological condition: non-nil != nil (govet) > } else if err != nil { > ^ Fix the issue, enable the check. Signed-off-by: Kir Kolyshkin --- .golangci.yml | 5 +++++ libcontainer/container_linux.go | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.golangci.yml b/.golangci.yml index c088117d2..25d94ecf4 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -11,3 +11,8 @@ linters: - errorlint - unconvert - unparam + +linters-settings: + govet: + enable: + - nilness diff --git a/libcontainer/container_linux.go b/libcontainer/container_linux.go index e3e2cf2bd..6242c1ba2 100644 --- a/libcontainer/container_linux.go +++ b/libcontainer/container_linux.go @@ -531,7 +531,7 @@ func (c *Container) newParentProcess(p *Process) (parentProcess, error) { logrus.Debug("runc-dmz: using runc-dmz") // used for tests } else if errors.Is(err, dmz.ErrNoDmzBinary) { logrus.Debug("runc-dmz binary not embedded in runc binary, falling back to /proc/self/exe clone") - } else if err != nil { + } else { return nil, fmt.Errorf("failed to create runc-dmz binary clone: %w", err) } } else {