1
0
mirror of https://github.com/golang/go synced 2024-11-18 23:44:43 -07:00

go.tools/pointer: suppress warnings from unsafe.Pointer conversions in the "syscall" package.

This is a short-term usability measure.
Longer term, we need to audit each conversion to decide
whether it should be ignored or modelled by an analytic
summary.

R=crawshaw
CC=golang-dev
https://golang.org/cl/13263050
This commit is contained in:
Alan Donovan 2013-09-12 10:56:37 -04:00
parent d38c09ed22
commit 7a5597c226

View File

@ -450,9 +450,14 @@ func (a *analysis) genConv(conv *ssa.Convert) {
case *types.Pointer: case *types.Pointer:
// unsafe.Pointer -> *T? (currently unsound) // unsafe.Pointer -> *T? (currently unsound)
if utSrc == tUnsafePtr { if utSrc == tUnsafePtr {
// For now, suppress unsafe.Pointer conversion
// warnings on "syscall" package.
// TODO(adonovan): audit for soundness.
if conv.Parent().Pkg.Object.Path() != "syscall" {
a.warnf(conv.Pos(), a.warnf(conv.Pos(),
"unsound: %s contains an unsafe.Pointer conversion (to %s)", "unsound: %s contains an unsafe.Pointer conversion (to %s)",
conv.Parent(), tDst) conv.Parent(), tDst)
}
// For now, we treat unsafe.Pointer->*T // For now, we treat unsafe.Pointer->*T
// conversion like new(T) and create an // conversion like new(T) and create an