From 17fce3ac51c732365758df960c2bdc25763f53f9 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 26 Jan 2023 10:42:08 -0500 Subject: [PATCH] unix: avoid false positive in vet shift check A uint64 >> 64 is reported as a mistake by the vet shift check. This is arguably a bug in vet, but we can't fix the old releases, so work around it. Works around golang/go#58030. Change-Id: Ic6b9ee2eb4bf01c77d9f7fcedb35562f733fce60 Reviewed-on: https://go-review.googlesource.com/c/sys/+/463675 TryBot-Result: Gopher Robot Run-TryBot: Russ Cox Reviewed-by: Ian Lance Taylor --- unix/syscall_linux.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unix/syscall_linux.go b/unix/syscall_linux.go index d839962e..bea511fc 100644 --- a/unix/syscall_linux.go +++ b/unix/syscall_linux.go @@ -1999,7 +1999,7 @@ func appendBytes(vecs []Iovec, bs [][]byte) []Iovec { // offs2lohi splits offs into its low and high order bits. func offs2lohi(offs int64) (lo, hi uintptr) { const longBits = SizeofLong * 8 - return uintptr(offs), uintptr(uint64(offs) >> longBits) + return uintptr(offs), uintptr(uint64(offs) >> (longBits - 1) >> 1) // two shifts to avoid false positive in vet } func Readv(fd int, iovs [][]byte) (n int, err error) {