summaryrefslogtreecommitdiff
path: root/src
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
commit642a169746796701b79e4110a460bdf56c2e9343 (patch)
treecb2ad6295b008be83773d68a38f4894c09bd448a /src
parent10650b718e9020238b9db8ebdb34f674189709c5 (diff)
downloadgolang-642a169746796701b79e4110a460bdf56c2e9343.tar.gz
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 http://codereview.appspot.com/170044
Diffstat (limited to 'src')
-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 03c6d5701..459b78cc2 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);
}