-
Notifications
You must be signed in to change notification settings - Fork 53
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
Fix possible misuse of reflect.SliceHeader vet error #465
Comments
robbertvanginkel
added a commit
that referenced
this issue
Feb 17, 2021
Fixes #465. According to https://golang.org/pkg/unsafe/#Pointer (6), one of the only safe ways to use pointers: > Conversion of a reflect.SliceHeader or reflect.StringHeader Data field to or from Pointer. ... > In general, reflect.SliceHeader and reflect.StringHeader should be used only as *reflect.SliceHeader and *reflect.StringHeader pointing at actual slices or strings, never as plain structs. A program should not declare or allocate variables of these struct types. This rewrites the unsafe to only modify to not allocate a `reflect.SliceHeader ` manually making the vet check happy.
r-hang
pushed a commit
that referenced
this issue
Feb 18, 2021
Fixes #465. According to https://golang.org/pkg/unsafe/#Pointer (6), one of the only safe ways to use pointers: > Conversion of a reflect.SliceHeader or reflect.StringHeader Data field to or from Pointer. ... > In general, reflect.SliceHeader and reflect.StringHeader should be used only as *reflect.SliceHeader and *reflect.StringHeader pointing at actual slices or strings, never as plain structs. A program should not declare or allocate variables of these struct types. This rewrites the unsafe to only modify to not allocate a `reflect.SliceHeader ` manually making the vet check happy.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A new check was added to vet in go1.16 (golang/go#40701), lint now fails with:
thriftrw-go/wire/unsafe.go
Lines 28 to 39 in b7d2a80
Currently failing #464. Should fix and rebase.
The text was updated successfully, but these errors were encountered: