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

false positives in cgo generated expressions #16

Closed
mdempsky opened this issue Aug 3, 2016 · 2 comments
Closed

false positives in cgo generated expressions #16

mdempsky opened this issue Aug 3, 2016 · 2 comments

Comments

@mdempsky
Copy link
Owner

mdempsky commented Aug 3, 2016

cgo rewrites code like:

return statusToError(C.DBIterError(r.iter))

to:

    return statusToError(_Cfunc_DBIterError(_cgoCheckPointer((*_Ctype_struct_DBIterator)(r.iter)).(*_Ctype_struct_DBIterator)))

In this case, r.iter is already of type *_Ctype_struct_DBIterator, and the conversion didn't exist in the original source, so we shouldn't warn about it.

Repro with unconvert github.com/cockroachdb/cockroach/storage/engine.

@tamird
Copy link
Contributor

tamird commented Aug 3, 2016

Alternatively, is this an improvement that can be made in cgo itself?

@mdempsky
Copy link
Owner Author

mdempsky commented Aug 3, 2016

@tamird Possibly. I actually think the conversions are technically erroneous anyway (they're only enforcing that pointer arguments to C functions are convertible to their corresponding parameter types, whereas for consistency with the Go language they should be required to be assignable), but I think it's easy enough to just fix in unconvert.

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

No branches or pull requests

2 participants