From fe09b6ce948aeab418f6bdfc2a14294e361b1655 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Thu, 22 Jan 2004 20:48:38 +0000 Subject: (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. --- src/rmdir.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/rmdir.c') 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); } } -- cgit v1.2.3-54-g00ecf