From ac88ce4f7f19be1aae1fdf390fa870b4be8dc3f5 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Sat, 2 May 2020 17:32:01 +0200 Subject: 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. --- sys/src/cmd/ndb/cs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sys/src/cmd/ndb/cs.c') diff --git a/sys/src/cmd/ndb/cs.c b/sys/src/cmd/ndb/cs.c index c508ee1a2..bb85080d4 100644 --- a/sys/src/cmd/ndb/cs.c +++ b/sys/src/cmd/ndb/cs.c @@ -310,7 +310,7 @@ mountinit(char *service, char *mntpt) * put ourselves into the file system */ close(p[0]); - if(mount(p[1], -1, mntpt, MAFTER, "") < 0) + if(mount(p[1], -1, mntpt, MAFTER, "") == -1) error("mount failed"); _exits(0); } @@ -1675,7 +1675,7 @@ err: qunlock(&mountlock); return -1; } - if(mount(fd, -1, mntpt, MAFTER, "") < 0){ + if(mount(fd, -1, mntpt, MAFTER, "") == -1){ close(fd); goto err; } -- cgit v1.2.3