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/libauth/newns.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sys/src/libauth') diff --git a/sys/src/libauth/newns.c b/sys/src/libauth/newns.c index 172692cc2..fd5d6cb59 100644 --- a/sys/src/libauth/newns.c +++ b/sys/src/libauth/newns.c @@ -184,7 +184,7 @@ nsop(char *fn, int argc, char *argv[], AuthRpc *rpc) }else if(strcmp(argv0, "clear") == 0 && argc == 0){ rfork(RFCNAMEG); }else if(strcmp(argv0, "bind") == 0 && argc == 2){ - if(bind(argv[0], argv[1], flags) < 0 && newnsdebug) + if(bind(argv[0], argv[1], flags) == -1 && newnsdebug) fprint(2, "%s: bind: %s %s: %r\n", fn, argv[0], argv[1]); }else if(strcmp(argv0, "unmount") == 0){ if(argc == 1) @@ -199,10 +199,10 @@ nsop(char *fn, int argc, char *argv[], AuthRpc *rpc) return 0; } if(argc == 2){ - if(famount(fd, rpc, argv[1], flags, "") < 0 && newnsdebug) + if(famount(fd, rpc, argv[1], flags, "") == -1 && newnsdebug) fprint(2, "%s: mount: %s %s: %r\n", fn, argv[0], argv[1]); }else if(argc == 3){ - if(famount(fd, rpc, argv[1], flags, argv[2]) < 0 && newnsdebug) + if(famount(fd, rpc, argv[1], flags, argv[2]) == -1 && newnsdebug) fprint(2, "%s: mount: %s %s %s: %r\n", fn, argv[0], argv[1], argv[2]); } close(fd); -- cgit v1.2.3