diff options
author | Jim Meyering <jim@meyering.net> | 2004-01-22 20:48:38 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2004-01-22 20:48:38 +0000 |
commit | fe09b6ce948aeab418f6bdfc2a14294e361b1655 (patch) | |
tree | 2a12b06e418832f62b875b77227b7c64b1834b97 | |
parent | 57a460665c96d702f9133ee83d258b6f6f29fcf6 (diff) | |
download | coreutils-fe09b6ce948aeab418f6bdfc2a14294e361b1655.tar.xz |
(usage): Use EXIT_SUCCESS, not 0, for clarity.
(remove_parents): Don't set 'fail' to a negative number.
(main): Avoid integer overflow when seeing whether errors occurred.
-rw-r--r-- | src/rmdir.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/rmdir.c b/src/rmdir.c index f21092ddf..1c29700b6 100644 --- a/src/rmdir.c +++ b/src/rmdir.c @@ -1,5 +1,5 @@ /* rmdir -- remove directories - Copyright (C) 90, 91, 1995-2002 Free Software Foundation, Inc. + Copyright (C) 90, 91, 1995-2002, 2004 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -91,7 +91,8 @@ errno_rmdir_non_empty (int error_number) /* Remove any empty parent directories of PATH. If PATH contains slash characters, at least one of them - (beginning with the rightmost) is replaced with a NUL byte. */ + (beginning with the rightmost) is replaced with a NUL byte. + Return zero if successful. */ static int remove_parents (char *path) @@ -115,7 +116,7 @@ remove_parents (char *path) if (verbose) error (0, 0, _("removing directory, %s"), path); - fail = rmdir (path); + fail = (rmdir (path) != 0); if (fail) { @@ -138,7 +139,7 @@ remove_parents (char *path) void usage (int status) { - if (status != 0) + if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), program_name); else @@ -230,7 +231,7 @@ main (int argc, char **argv) } else if (empty_paths) { - errors += remove_parents (dir); + errors |= remove_parents (dir); } } |