From bc9a7bda583e0fe8501e9359cbc854dbc579c43d Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 30 Sep 2020 23:38:29 +0200 Subject: [PATCH] setFreezer: explicitly return nil errors.Wrap(err, "some error") returns nil if err is nil, so it's slightly clearer to just return early than to set the error to nil and call errors.Wrap(). This is also somewhat defensive in case we decide to replace `errors.Wrap()` for golang's native `%w` wrapping. Signed-off-by: Sebastiaan van Stijn --- libcontainer/cgroups/fs2/freezer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcontainer/cgroups/fs2/freezer.go b/libcontainer/cgroups/fs2/freezer.go index 213ff65a1..441531fd7 100644 --- a/libcontainer/cgroups/fs2/freezer.go +++ b/libcontainer/cgroups/fs2/freezer.go @@ -19,7 +19,7 @@ func setFreezer(dirPath string, state configs.FreezerState) error { // freeze the container (since without the freezer cgroup, that's a // no-op). if state == configs.Undefined || state == configs.Thawed { - err = nil + return nil } return errors.Wrap(err, "freezer not supported") }