From b653c878b1ad8d1b4f8d7b04201d0cb0a4156ead Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 5 Apr 2019 11:42:37 -0700 Subject: runtime: change read and write to return negative errno value The internal read and write functions used to return -1 on error; change them to return a negative errno value instead. This will be used by later CLs in this series. For most targets this is a simplification, although for ones that call into libc it is a complication. Updates #27707 Change-Id: Id02bf9487f03e7e88e4f2b85e899e986738697ad Reviewed-on: https://go-review.googlesource.com/c/go/+/171823 Run-TryBot: Ian Lance Taylor TryBot-Result: Gobot Gobot Reviewed-by: Michael Knyszek --- src/runtime/runtime_test.go | 26 -------------------------- 1 file changed, 26 deletions(-) (limited to 'src/runtime/runtime_test.go') diff --git a/src/runtime/runtime_test.go b/src/runtime/runtime_test.go index ab7a03b2d1..26ae77456a 100644 --- a/src/runtime/runtime_test.go +++ b/src/runtime/runtime_test.go @@ -290,32 +290,6 @@ func TestTrailingZero(t *testing.T) { } } -func TestBadOpen(t *testing.T) { - if GOOS == "windows" || GOOS == "js" { - t.Skip("skipping OS that doesn't have open/read/write/close") - } - // make sure we get the correct error code if open fails. Same for - // read/write/close on the resulting -1 fd. See issue 10052. - nonfile := []byte("/notreallyafile") - fd := Open(&nonfile[0], 0, 0) - if fd != -1 { - t.Errorf("open(\"%s\")=%d, want -1", string(nonfile), fd) - } - var buf [32]byte - r := Read(-1, unsafe.Pointer(&buf[0]), int32(len(buf))) - if r != -1 { - t.Errorf("read()=%d, want -1", r) - } - w := Write(^uintptr(0), unsafe.Pointer(&buf[0]), int32(len(buf))) - if w != -1 { - t.Errorf("write()=%d, want -1", w) - } - c := Close(-1) - if c != -1 { - t.Errorf("close()=%d, want -1", c) - } -} - func TestAppendGrowth(t *testing.T) { var x []int64 check := func(want int) { -- cgit v1.3-5-g9baa