diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2020-05-02 17:32:01 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2020-05-02 17:32:01 +0200 |
commit | ac88ce4f7f19be1aae1fdf390fa870b4be8dc3f5 (patch) | |
tree | 47df6acf41dd8d2dc607b89af9d4667935d0c952 /sys/src/cmd/telco | |
parent | 7ff6ea0f70307d4b82e6df69eb1310a6e27aa4ad (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/telco')
-rw-r--r-- | sys/src/cmd/telco/telco.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/sys/src/cmd/telco/telco.c b/sys/src/cmd/telco/telco.c index e754ca30d..4e20904e8 100644 --- a/sys/src/cmd/telco/telco.c +++ b/sys/src/cmd/telco/telco.c @@ -381,7 +381,7 @@ main(int argc, char *argv[]) if(write(fd, buf, strlen(buf)) < 0) error("writing /srv/telco"); close(fd); - if(mount(p[1], -1, "/net", MBEFORE, "") < 0) + if(mount(p[1], -1, "/net", MBEFORE, "") == -1) error("mount failed"); exits(0); } @@ -1400,11 +1400,10 @@ receiver(Dev *d) syslog(0, LOGFILE, "can't open telco: %r"); exits(0); } - if(mount(fd, -1, "/net", MAFTER, "") < 0){ + if(mount(fd, -1, "/net", MAFTER, "") == -1){ syslog(0, LOGFILE, "can't mount: %r"); exits(0); } - close(fd); /* open connection through the file system interface */ sprint(file, "/net/telco/%zd/data", d - dev); |