Skip to content

Commit

Permalink
.golangci.yml: disable staticcheck nil pointer deref check
Browse files Browse the repository at this point in the history
Currently it produces false reports with Go1.16:

tools/syz-runtest/runtest.go:271:6: SA5011: possible nil pointer dereference
	req.Output = a.Output
	    ^
tools/syz-runtest/runtest.go:272:6: SA5011: possible nil pointer dereference
	req.Info = a.Info
	    ^
sys/fuchsia/fidlgen/main.go:27:17: SA5011: possible nil pointer dereference
	arch := target.KernelHeaderArch
	               ^

All these are preceeded with log.Fatalf, which is strange...

Update #2446
  • Loading branch information
dvyukov committed Feb 20, 2021
1 parent f689d40 commit c8f51f5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ linters:
- gocognit
- funlen
- dupl
- staticcheck
- syz-linter
disable:
- bodyclose
Expand Down Expand Up @@ -102,6 +103,9 @@ issues:
- "exported .* should have comment"
- "comment on .* should be of the form"
- "at least one file in a package should have a package comment"
# 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"
exclude-rules:
- path: (pkg/csource/generated.go|pkg/build/linux_generated.go)
linters:
Expand Down

5 comments on commit c8f51f5

@dominikh
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works fine with the staticcheck command, so I'm blaming golangci-lint.

@dvyukov
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for checking. I guess we need to file a golangci-lint issue. How can I run staticcheck command itself on a package? Or, if you already reproduced it, do you mind filing an issue?

@dvyukov
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also wonder how did you find this commit? :)

@dominikh
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can I run staticcheck command itself on a package?

$ go install honnef.co/go/tools/cmd/staticcheck@latest
$ staticcheck ./sys/fuchsia/fidlgen

I get no SA5011 report with the existing code, and do get it if I comment out the first call to tool.Failf, which suggests to me that it is working.

Or, if you already reproduced it, do you mind filing an issue?

I actually can't reproduce the problem. Running golangci-lint 1.36.0 against ./sys/fuchsia/fidlgen produces no errors, unless I comment out the call to tool.Failf.

Also wonder how did you find this commit? :)

Every once in a while I search GitHub for commits and issues mentioning Staticcheck, to find issues like these.

@dvyukov
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.