aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSabyrzhan Tasbolatov <snovitoll@gmail.com>2024-10-27 20:05:29 +0500
committerAleksandr Nogikh <nogikh@google.com>2024-10-28 11:16:43 +0000
commit9efb3cc7d524771b347fdd278c089ee920df8da4 (patch)
tree39983d86a082c45ed25647cf8dfd42bed3b1f57c
parentb2c9a639e38a90a60395aed730b2971525c7fc7d (diff)
lint: fix lint issues
Fix linter reported issue with "err != nil" is always true and add "this check suggests that the pointer can be nil" to the exclusion rules as the false-positives due to non-standard/standard package's Fatalf() exiting. ``` $ make lint bin/golangci-lint run ./... pkg/cover/backend/dwarf.go:180:8: SA4023: this comparison is always true if err != nil { ^ sys/fuchsia/fidlgen/main.go:24:5: SA5011(related information): this check suggests that the pointer can be nil if target == nil { tools/syz-declextract/run.go:95:6: SA5011(related information): this check suggests that the pointer can be nil if parse == nil { ^ tools/syz-declextract/run.go:234:5: SA5011(related information): this check suggests that the pointer can be nil if netlinkUnionParsed == nil { ^ prog/encodingexec_test.go:60:6: SA5011(related information): this check suggests that the pointer can be nil if c == nil { ^ sys/fuchsia/fidlgen/main.go:24:5: SA5011(related information): this check suggests that the pointer can be nil if target == nil { ^ pkg/compiler/compiler_test.go:339:5: SA5011(related information): this check suggests that the pointer can be nil if p == nil { ^ pkg/compiler/compiler_test.go:379:5: SA5011(related information): this check suggests that the pointer can be nil if p == nil { ^ pkg/ast/parser_test.go:32:7: SA5011(related information): this check suggests that the pointer can be nil if desc == nil { ^ pkg/ast/parser_test.go:37:7: SA5011(related information): this check suggests that the pointer can be nil if desc2 == nil { ^ pkg/report/report_test.go:308:5: SA5011(related information): this check suggests that the pointer can be nil if rep == nil { ^ pkg/bisect/bisect_test.go:205:5: SA5011(related information): this check suggests that the pointer can be nil if sc == nil { ^ make: *** [Makefile:293: lint] Error 1 ```
-rw-r--r--.golangci.yml1
-rw-r--r--pkg/cover/backend/dwarf.go6
2 files changed, 3 insertions, 4 deletions
diff --git a/.golangci.yml b/.golangci.yml
index f668cf65a..02b1c66f4 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -107,6 +107,7 @@ issues:
# This check gives false positives related to the standard log.Fatalf
# (which is strange, standard log package should be supported).#
- "SA5011: possible nil pointer dereference"
+ - "this check suggests that the pointer can be nil"
exclude-rules:
- path: (pkg/csource/generated.go|pkg/build/linux_generated.go)
linters:
diff --git a/pkg/cover/backend/dwarf.go b/pkg/cover/backend/dwarf.go
index e7fe333c0..375a82dcc 100644
--- a/pkg/cover/backend/dwarf.go
+++ b/pkg/cover/backend/dwarf.go
@@ -177,10 +177,8 @@ func makeDWARFUnsafe(params *dwarfParams) (*Impl, error) {
}
if module.Name == "" && len(result.CoverPoints[0]) == 0 {
err = fmt.Errorf("%v doesn't contain coverage callbacks (set CONFIG_KCOV=y on linux)", module.Path)
- if err != nil {
- binC <- binResult{err: err}
- return
- }
+ binC <- binResult{err: err}
+ return
}
ranges, units, err := params.readTextRanges(module)
if err != nil {