From e3ec1ca17e339e21ca50fbdb375b4294783bc385 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Tue, 2 Apr 2024 00:10:47 +0200 Subject: [PATCH] os: define wrapSyscallError only on linux wrapSyscallError by now is only used on linux in the methods defined in os/zero_copy_linux.go. Move the definition there. Change-Id: I0ca5749adaac44e8d095b8452458b647f595d3c8 Reviewed-on: https://go-review.googlesource.com/c/go/+/575595 Reviewed-by: Dmitri Shuralyov LUCI-TryBot-Result: Go LUCI Reviewed-by: Ian Lance Taylor Auto-Submit: Tobias Klauser --- src/os/error_posix.go | 18 ------------------ src/os/zero_copy_linux.go | 9 +++++++++ 2 files changed, 9 insertions(+), 18 deletions(-) delete mode 100644 src/os/error_posix.go diff --git a/src/os/error_posix.go b/src/os/error_posix.go deleted file mode 100644 index b159c036c1..0000000000 --- a/src/os/error_posix.go +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build unix || (js && wasm) || wasip1 || windows - -package os - -import "syscall" - -// wrapSyscallError takes an error and a syscall name. If the error is -// a syscall.Errno, it wraps it in an os.SyscallError using the syscall name. -func wrapSyscallError(name string, err error) error { - if _, ok := err.(syscall.Errno); ok { - err = NewSyscallError(name, err) - } - return err -} diff --git a/src/os/zero_copy_linux.go b/src/os/zero_copy_linux.go index 7c45aefeee..d9cf18c22f 100644 --- a/src/os/zero_copy_linux.go +++ b/src/os/zero_copy_linux.go @@ -16,6 +16,15 @@ var ( pollSendFile = poll.SendFile ) +// wrapSyscallError takes an error and a syscall name. If the error is +// a syscall.Errno, it wraps it in an os.SyscallError using the syscall name. +func wrapSyscallError(name string, err error) error { + if _, ok := err.(syscall.Errno); ok { + err = NewSyscallError(name, err) + } + return err +} + func (f *File) writeTo(w io.Writer) (written int64, handled bool, err error) { pfd, network := getPollFDAndNetwork(w) // TODO(panjf2000): same as File.spliceToFile. -- 2.48.1