summaryrefslogtreecommitdiff
path: root/sys/src/cmd/aux
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2020-05-02 17:32:01 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2020-05-02 17:32:01 +0200
commitac88ce4f7f19be1aae1fdf390fa870b4be8dc3f5 (patch)
tree47df6acf41dd8d2dc607b89af9d4667935d0c952 /sys/src/cmd/aux
parent7ff6ea0f70307d4b82e6df69eb1310a6e27aa4ad (diff)
make bind(2) error handling consistent
The mount() and bind() syscalls return -1 on error, and the mountid sequence number on success. The manpage states that the mountid sequence number is a positive integer, but the kernels implementation currently uses a unsigned 32-bit integer and does not guarantee that the mountid will not become negative. Most code just cares about the error, so test for the -1 error value only.
Diffstat (limited to 'sys/src/cmd/aux')
-rw-r--r--sys/src/cmd/aux/depend.c2
-rw-r--r--sys/src/cmd/aux/searchfs.c2
-rw-r--r--sys/src/cmd/aux/timesync.c2
3 files changed, 3 insertions, 3 deletions
diff --git a/sys/src/cmd/aux/depend.c b/sys/src/cmd/aux/depend.c
index 36d63149e..90da99add 100644
--- a/sys/src/cmd/aux/depend.c
+++ b/sys/src/cmd/aux/depend.c
@@ -300,7 +300,7 @@ realmain(void *a)
close(pfd[1]);
time(nil); /* open fd for time before losing / */
- if(bind(argv[1], "/", MREPL) == 0)
+ if(bind(argv[1], "/", MREPL) == -1)
fatal("can't bind %s to /", argv[1]);
fs = emalloc(sizeof(Fs));
diff --git a/sys/src/cmd/aux/searchfs.c b/sys/src/cmd/aux/searchfs.c
index 4a617f8e2..be5ff9238 100644
--- a/sys/src/cmd/aux/searchfs.c
+++ b/sys/src/cmd/aux/searchfs.c
@@ -216,7 +216,7 @@ main(int argc, char **argv)
exits(nil);
}
- if(mount(p[1], -1, mnt, MREPL, "") < 0){
+ if(mount(p[1], -1, mnt, MREPL, "") == -1){
close(p[1]);
fatal("mount failed");
}
diff --git a/sys/src/cmd/aux/timesync.c b/sys/src/cmd/aux/timesync.c
index 6ee46118d..71370d45e 100644
--- a/sys/src/cmd/aux/timesync.c
+++ b/sys/src/cmd/aux/timesync.c
@@ -303,7 +303,7 @@ main(int argc, char **argv)
fd = open(timeserver, ORDWR);
if(fd < 0)
sysfatal("opening %s: %r", timeserver);
- if(amount(fd, "/n/boot", MREPL, "") < 0)
+ if(amount(fd, "/n/boot", MREPL, "") == -1)
sysfatal("mounting %s: %r", timeserver);
close(fd);
break;