From f11e5e49a4ec85883999349b0dc6373df034397b Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Wed, 28 Sep 2022 11:42:05 +0200 Subject: [PATCH] unix: use unsafe.Slice in (*FileHandle).Bytes Change-Id: Ic2b88577ec6fd975bbba0538790d2ff312d85d3f Reviewed-on: https://go-review.googlesource.com/c/sys/+/435776 Reviewed-by: Benny Siegert TryBot-Result: Gopher Robot Auto-Submit: Tobias Klauser Run-TryBot: Tobias Klauser Reviewed-by: Dmitri Shuralyov --- 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 583ff00d..e044d5b5 100644 --- a/unix/syscall_linux.go +++ b/unix/syscall_linux.go @@ -2252,7 +2252,7 @@ func (fh *FileHandle) Bytes() []byte { if n == 0 { return nil } - return (*[1 << 30]byte)(unsafe.Pointer(uintptr(unsafe.Pointer(&fh.fileHandle.Type)) + 4))[:n:n] + return unsafe.Slice((*byte)(unsafe.Pointer(uintptr(unsafe.Pointer(&fh.fileHandle.Type))+4)), n) } // NameToHandleAt wraps the name_to_handle_at system call; it obtains