From 8f23c528ad5a943b9ffec5dcaf332fd0f614006e Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Mon, 22 Feb 2021 20:35:43 +0100 Subject: pkg/ipc: fix reflect.SliceHeader misuse Pointed by golangci-lint. For context see https://github.com/golang/go/issues/40701 --- pkg/ipc/ipc.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'pkg') diff --git a/pkg/ipc/ipc.go b/pkg/ipc/ipc.go index 633f639c8..643f16582 100644 --- a/pkg/ipc/ipc.go +++ b/pkg/ipc/ipc.go @@ -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 } -- cgit mrf-deployment