Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong if condition in schemas.go #147

Closed
lukedirtwalker opened this issue Aug 10, 2019 · 2 comments · Fixed by #148
Closed

Wrong if condition in schemas.go #147

lukedirtwalker opened this issue Aug 10, 2019 · 2 comments · Fixed by #148

Comments

@lukedirtwalker
Copy link

The following if condition
https://github.com/capnproto/go-capnproto2/blob/4a2d721f0c4b15f3e369dc4a82d604ef605d7da5/schemas/schemas.go#L114-L115
is wrong. The error is assigned to r.err but the check below is on err which was previously checked.
Not sure what the correct solution would be, probably the if should just check for r.err, or is the assignment to r.err wrong in the first place?

Found with go nilness analyzer (https://godoc.org/golang.org/x/tools/go/analysis/passes/nilness)

@zombiezen
Copy link
Contributor

Thanks for the report! You are correct that r.err is what should be checked there, want to send a PR?

lukedirtwalker added a commit to lukedirtwalker/go-capnproto2 that referenced this issue Aug 12, 2019
The error is assigned to r.err but checked is err, fix this by checking r.err.
Found with nilness analyzer.

Fixes capnproto#147
@lukedirtwalker
Copy link
Author

@zombiezen opened #148

lukedirtwalker added a commit to lukedirtwalker/go-capnproto2 that referenced this issue Aug 12, 2019
The error is assigned to r.err but checked is err, fix this by checking r.err.
Found with nilness analyzer.

Fixes capnproto#147

Also delete unreachable return nil in marshal.go
zombiezen pushed a commit that referenced this issue Aug 13, 2019
The error is assigned to r.err but checked is err, fix this by checking r.err.
Found with nilness analyzer.

Also delete unreachable return nil in encoding/text/marshal.go.

Fixes #147
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants