Skip to contentSkip to conversation

nfsstats: fix some exit codes.

PATCH In review NeilBrown 2 participants 2 messages Jan 4, 2017 – Jan 11, 2017

Subsystems (2)
lore
Share & tools
lore

NeilBrown

author
#0 lore raw

PATCH 1/1 nfsstats: fix some exit codes.

"nfsstat -m" always exits with "1" (unless there is an error opening /proc/mounts). It should exist "0".

Also, a few usage errors cause an exit of "255" when it should probably be "1".

---
 utils/nfsstat/nfsstat.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
utils/nfsstat/nfsstat.c +3 -3
index 8376347d5af4..eddbe9a14f25 100644
@@ -389,7 +389,7 @@ main(int argc, char **argv)
 		switch (c) {
 		case 'a':
 			fprintf(stderr, "nfsstat: nfs acls are not yet supported.\n");
-			return -1;
+			return 1;
 		case 'c':
 			opt_clt = 1;
 			break;
@@ -455,7 +455,7 @@ main(int argc, char **argv)
 					"not yet supported\n");
 			return 2;
 		case 'm':
-			return mounts(MOUNTSFILE);
+			return ! mounts(MOUNTSFILE);
 		case '\1':
 			usage(progname);
 			return 0;
@@ -464,7 +464,7 @@ main(int argc, char **argv)
 			return 0;
 		default:
 			printf("Try `%s --help' for more information.\n", progname);
-			return -1;
+			return 1;
 		}
 	}
 
Signature · 1 line
2.11.0
#1 lore raw
Quoted 7 lines · NeilBrown

"nfsstat -m" always exits with "1" (unless there is an error opening /proc/mounts). It should exist "0".

Also, a few usage errors cause an exit of "255" when it should probably be "1".

Committed....

steved.

Quoted 35 lines
---
 utils/nfsstat/nfsstat.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
utils/nfsstat/nfsstat.c +3 -3
index 8376347d5af4..eddbe9a14f25 100644
@@ -389,7 +389,7 @@ main(int argc, char **argv)
 		switch (c) {
 		case 'a':
 			fprintf(stderr, "nfsstat: nfs acls are not yet supported.\n");
-			return -1;
+			return 1;
 		case 'c':
 			opt_clt = 1;
 			break;
@@ -455,7 +455,7 @@ main(int argc, char **argv)
 					"not yet supported\n");
 			return 2;
 		case 'm':
-			return mounts(MOUNTSFILE);
+			return ! mounts(MOUNTSFILE);
 		case '\1':
 			usage(progname);
 			return 0;
@@ -464,7 +464,7 @@ main(int argc, char **argv)
 			return 0;
 		default:
 			printf("Try `%s --help' for more information.\n", progname);
-			return -1;
+			return 1;
 		}
 	}