From d97fd533cfaf6e4fe728bab13971c7f438a2f446 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 28 Jan 2022 12:48:36 +0100 Subject: [PATCH] integration-cli: SA5011: possible nil pointer dereference (staticcheck) I think the original intent here was to make passing t optional (62a856e9129c9d5cf7db9ea6322c9073d68e3ea4), but it looks like that's not done anywhere, so let's remove it. integration-cli/docker_utils_test.go:81:2: SA5011: possible nil pointer dereference (staticcheck) c.Helper() ^ integration-cli/docker_utils_test.go:84:5: SA5011(related information): this check suggests that the pointer can be nil (staticcheck) if c != nil { ^ integration-cli/docker_utils_test.go:106:2: SA5011: possible nil pointer dereference (staticcheck) c.Helper() ^ integration-cli/docker_utils_test.go:108:5: SA5011(related information): this check suggests that the pointer can be nil (staticcheck) if c != nil { ^ integration-cli/docker_utils_test.go:116:2: SA5011: possible nil pointer dereference (staticcheck) c.Helper() ^ integration-cli/docker_utils_test.go:118:5: SA5011(related information): this check suggests that the pointer can be nil (staticcheck) if c != nil { ^ integration-cli/docker_utils_test.go:126:2: SA5011: possible nil pointer dereference (staticcheck) c.Helper() ^ integration-cli/docker_utils_test.go:128:5: SA5011(related information): this check suggests that the pointer can be nil (staticcheck) if c != nil { ^ Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 89f63f476bdcf7cad00d5721cef3e7774ac1d71b) Signed-off-by: Sebastiaan van Stijn --- integration-cli/docker_utils_test.go | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/integration-cli/docker_utils_test.go b/integration-cli/docker_utils_test.go index b442673898..f1791f5006 100644 --- a/integration-cli/docker_utils_test.go +++ b/integration-cli/docker_utils_test.go @@ -82,9 +82,7 @@ func inspectFieldAndUnmarshall(c *testing.T, name, field string, output interfac c.Helper() str := inspectFieldJSON(c, name, field) err := json.Unmarshal([]byte(str), output) - if c != nil { - assert.Assert(c, err == nil, "failed to unmarshal: %v", err) - } + assert.Assert(c, err == nil, "failed to unmarshal: %v", err) } // Deprecated: use cli.Inspect @@ -106,9 +104,7 @@ func inspectFieldWithError(name, field string) (string, error) { func inspectField(c *testing.T, name, field string) string { c.Helper() out, err := inspectFilter(name, fmt.Sprintf(".%s", field)) - if c != nil { - assert.NilError(c, err) - } + assert.NilError(c, err) return out } @@ -116,9 +112,7 @@ func inspectField(c *testing.T, name, field string) string { func inspectFieldJSON(c *testing.T, name, field string) string { c.Helper() out, err := inspectFilter(name, fmt.Sprintf("json .%s", field)) - if c != nil { - assert.NilError(c, err) - } + assert.NilError(c, err) return out } @@ -126,9 +120,7 @@ func inspectFieldJSON(c *testing.T, name, field string) string { func inspectFieldMap(c *testing.T, name, path, field string) string { c.Helper() out, err := inspectFilter(name, fmt.Sprintf("index .%s %q", path, field)) - if c != nil { - assert.NilError(c, err) - } + assert.NilError(c, err) return out }