From 6f571dbfc6a01612c5a634cf19f11ec3c8093ec4 Mon Sep 17 00:00:00 2001 From: nekral-guest Date: Sat, 26 Jul 2008 16:24:27 +0000 Subject: [PATCH] * src/groupmems.c: Really use booleans. * src/groupmems.c: Change isroot() to a macro that returns a boolean. --- ChangeLog | 6 ++++++ src/groupmems.c | 21 ++++++++------------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index f69f0373..fe066e84 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-07-26 Nicolas François + + * src/groupmems.c: Really use booleans. + * src/groupmems.c: Change isroot() to a macro that returns a + boolean. + 2008-07-26 Nicolas François * lib/defines.h: Make sure the booleans are defined before using diff --git a/src/groupmems.c b/src/groupmems.c index a04f6a3a..e4a27060 100644 --- a/src/groupmems.c +++ b/src/groupmems.c @@ -57,24 +57,18 @@ #define EXIT_INVALID_USER 8 /* specified user does not exist */ #define EXIT_INVALID_GROUP 9 /* specified group does not exist */ -#define TRUE 1 -#define FALSE 0 - /* * Global variables */ static char *adduser = NULL; static char *deluser = NULL; static char *thisgroup = NULL; -static int purge = FALSE; -static int list = FALSE; +static bool purge = false; +static bool list = false; static int exclusive = 0; static char *Prog; -static int isroot (void) -{ - return getuid ()? FALSE : TRUE; -} +#define isroot () (getuid () == 0) static int isgroup (void) { @@ -117,12 +111,12 @@ static void addtogroup (char *user, char **members) static void rmfromgroup (char *user, char **members) { int i; - int found = FALSE; + bool found = false; i = 0; while (!found && NULL != members[i]) { if (0 == strcmp (user, members[i])) { - found = TRUE; + found = true; } else { i++; } @@ -212,14 +206,14 @@ int main (int argc, char **argv) ++exclusive; break; case 'p': - purge = TRUE; + purge = true; ++exclusive; break; case 'g': thisgroup = strdup (optarg); break; case 'l': - list = TRUE; + list = true; ++exclusive; break; default: @@ -231,6 +225,7 @@ int main (int argc, char **argv) usage (); } + /* local, no need for xgetpwnam */ if (getpwnam(adduser) == NULL) { fprintf (stderr, _("%s: user `%s' does not exist\n") Prog, adduser);