From 0e7d023f34ab812f6c2313d80f4516fefc95342b Mon Sep 17 00:00:00 2001 From: Bruce Evans Date: Tue, 3 Jun 2003 11:54:42 +0000 Subject: [PATCH] Fixed exit code in previous commit. "var++" to set a flag to nonzero is a style bug at best. When the variable isn't a flag, it potentially overflows after a large number of settings. Here the number of settings is limited by ARG_MAX, but the variable is the exit code so it became bogus after the second setting and effectively overflowed to 0 after approx. 128 settings. Fixed some style bugs involving comments in and near previous commit. Clarification of previous commit message: df -t didn't give undefined behaviour, and the behaviour used to conform perfectly with the man page, since the buggy behaviour is documented in the BUGS section. -t just worked when no files or file systems were specified, and was just ignored if a file or file system was specified. --- bin/df/df.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/bin/df/df.c b/bin/df/df.c index bb12fd46c7bc..cdb2083b8085 100644 --- a/bin/df/df.c +++ b/bin/df/df.c @@ -271,6 +271,7 @@ main(int argc, char *argv[]) } } else mntpt = *argv; + /* * Statfs does not take a `wait' flag, so we cannot * implement nflag here. @@ -280,15 +281,18 @@ main(int argc, char *argv[]) rv = 1; continue; } - /* Check to make sure the arguments we've been - * given are satisfied. Return an error if we - * have been asked to list a mount point that does - * not match the other args we've been given (-l, -t, etc.) + + /* + * Check to make sure the arguments we've been given are + * satisfied. Return an error if we have been asked to + * list a mount point that does not match the other args + * we've been given (-l, -t, etc.). */ if (checkvfsname(statfsbuf.f_fstypename, vfslist)) { - rv++; + rv = 1; continue; } + if (argc == 1) { bzero(&maxwidths, sizeof(maxwidths)); update_maxwidths(&maxwidths, &statfsbuf);