aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2009-12-09 14:18:32 -0800
committerRob Pike <r@golang.org>2009-12-09 14:18:32 -0800
commit51f2932082ecfc7c92aad774be3ebea6436d662b (patch)
tree707508cc09538407a7300fd3c98d8c6116f5a65b
parentd55abfd2c9cd96f8e4c1b61a9b57c88d3f3bcd37 (diff)
downloadgo-51f2932082ecfc7c92aad774be3ebea6436d662b.tar.gz
go-51f2932082ecfc7c92aad774be3ebea6436d662b.zip
syscalls can return negative i/o counts. fix bugs in ReadAt and WriteAt not to include
negative counts in return values. R=rsc CC=golang-dev https://golang.org/cl/170044
-rw-r--r--src/pkg/os/file.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/pkg/os/file.go b/src/pkg/os/file.go
index 03c6d57018..459b78cc22 100644
--- a/src/pkg/os/file.go
+++ b/src/pkg/os/file.go
@@ -141,11 +141,11 @@ func (file *File) ReadAt(b []byte, off int64) (n int, err Error) {
if m == 0 && e == 0 {
return n, EOF
}
- n += m;
if e != 0 {
err = &PathError{"read", file.name, Errno(e)};
break;
}
+ n += m;
b = b[m:];
off += int64(m);
}
@@ -186,11 +186,11 @@ func (file *File) WriteAt(b []byte, off int64) (n int, err Error) {
}
for len(b) > 0 {
m, e := syscall.Pwrite(file.fd, b, off);
- n += m;
if e != 0 {
err = &PathError{"write", file.name, Errno(e)};
break;
}
+ n += m;
b = b[m:];
off += int64(m);
}