Skip to content

Commit

Permalink
pkg/ipc: fix reflect.SliceHeader misuse
Browse files Browse the repository at this point in the history
Pointed by golangci-lint.
For context see golang/go#40701
  • Loading branch information
dvyukov committed Feb 22, 2021
1 parent c26fb06 commit 4fb2824
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions pkg/ipc/ipc.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,12 +467,11 @@ func readUint32Array(outp *[]byte, size uint32) ([]uint32, bool) {
if int(size)*4 > len(out) {
return nil, false
}
hdr := reflect.SliceHeader{
Data: uintptr(unsafe.Pointer(&out[0])),
Len: int(size),
Cap: int(size),
}
res := *(*[]uint32)(unsafe.Pointer(&hdr))
var res []uint32
hdr := (*reflect.SliceHeader)((unsafe.Pointer(&res)))
hdr.Data = uintptr(unsafe.Pointer(&out[0]))
hdr.Len = int(size)
hdr.Cap = int(size)
*outp = out[size*4:]
return res, true
}
Expand Down

0 comments on commit 4fb2824

Please sign in to comment.