From 23b3e06c44b1a387e4c76502a5405080c201f3ef Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Wed, 21 Jan 2004 23:10:54 +0000 Subject: (usage): Use EXIT_SUCCESS, not 0, for clarity. (usage): Don't bother normalizing exit status since the arg is already the correct exit status now. (main): Don't assume EXIT_FAILURE == 1, as POSIX doesn't require it. (problems): Now a boolean int, not a counter, so that we don't have to worry about int overflow. All uses changed. --- src/id.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/id.c b/src/id.c index 9cd426a2e..db4883c83 100644 --- a/src/id.c +++ b/src/id.c @@ -1,5 +1,5 @@ /* id -- print real and effective UIDs and GIDs - Copyright (C) 1989-2003 Free Software Foundation, Inc. + Copyright (C) 1989-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 @@ -60,7 +60,7 @@ static int use_name = 0; static uid_t ruid, euid; static gid_t rgid, egid; -/* The number of errors encountered so far. */ +/* Nonzero if errors have been encountered. */ static int problems = 0; static struct option const longopts[] = @@ -78,7 +78,7 @@ static struct option const longopts[] = void usage (int status) { - if (status != 0) + if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), program_name); else @@ -194,7 +194,7 @@ main (int argc, char **argv) print_full_info (argv[optind]); putchar ('\n'); - exit (problems != 0); + exit (problems == 0 ? EXIT_SUCCESS : EXIT_FAILURE); } /* Print the name or value of user ID UID. */ @@ -210,7 +210,7 @@ print_user (uid_t uid) if (pwd == NULL) { error (0, 0, _("cannot find name for user ID %u"), uid); - problems++; + problems = 1; } } @@ -233,7 +233,7 @@ print_group (gid_t gid) if (grp == NULL) { error (0, 0, _("cannot find name for group ID %u"), gid); - problems++; + problems = 1; } } @@ -293,7 +293,7 @@ print_group_list (const char *username) pwd = getpwuid (ruid); if (pwd == NULL) - problems++; + problems = 1; print_group (rgid); if (egid != rgid) @@ -311,7 +311,7 @@ print_group_list (const char *username) if (xgetgroups (username, (pwd ? pwd->pw_gid : (gid_t) -1), &n_groups, &groups)) { - ++problems; + problems = 1; return; } @@ -337,14 +337,14 @@ print_full_info (const char *username) printf ("uid=%u", (unsigned) ruid); pwd = getpwuid (ruid); if (pwd == NULL) - problems++; + problems = 1; else printf ("(%s)", pwd->pw_name); printf (" gid=%u", (unsigned) rgid); grp = getgrgid (rgid); if (grp == NULL) - problems++; + problems = 1; else printf ("(%s)", grp->gr_name); @@ -353,7 +353,7 @@ print_full_info (const char *username) printf (" euid=%u", (unsigned) euid); pwd = getpwuid (euid); if (pwd == NULL) - problems++; + problems = 1; else printf ("(%s)", pwd->pw_name); } @@ -363,7 +363,7 @@ print_full_info (const char *username) printf (" egid=%u", (unsigned) egid); grp = getgrgid (egid); if (grp == NULL) - problems++; + problems = 1; else printf ("(%s)", grp->gr_name); } @@ -377,7 +377,7 @@ print_full_info (const char *username) if (xgetgroups (username, (pwd ? pwd->pw_gid : (gid_t) -1), &n_groups, &groups)) { - ++problems; + problems = 1; return; } @@ -390,7 +390,7 @@ print_full_info (const char *username) printf ("%u", (unsigned) groups[i]); grp = getgrgid (groups[i]); if (grp == NULL) - problems++; + problems = 1; else printf ("(%s)", grp->gr_name); } -- cgit v1.2.3-70-g09d2