* src/pwck.c: Use a bool when possible instead of int integers.

* src/pwck.c: Avoid implicit conversion of integers to booleans.
This commit is contained in:
nekral-guest 2008-06-10 22:09:12 +00:00
parent d7ffaf94b1
commit ce6dca81bc
2 changed files with 22 additions and 17 deletions

View File

@ -1,3 +1,8 @@
2008-06-10 Nicolas François <nicolas.francois@centraliens.net>
* src/pwck.c: Use a bool when possible instead of int integers.
* src/pwck.c: Avoid implicit conversion of integers to booleans.
2008-06-10 Nicolas François <nicolas.francois@centraliens.net> 2008-06-10 Nicolas François <nicolas.francois@centraliens.net>
* src/su.c: Use a bool when possible instead of int integers. * src/su.c: Use a bool when possible instead of int integers.

View File

@ -80,9 +80,9 @@ static bool quiet = false; /* don't report warnings, only errors */
static void usage (void); static void usage (void);
static void process_flags (int argc, char **argv); static void process_flags (int argc, char **argv);
static void open_files (void); static void open_files (void);
static void close_files (int changed); static void close_files (bool changed);
static void check_pw_file (int *errors, int *changed); static void check_pw_file (int *errors, bool *changed);
static void check_spw_file (int *errors, int *changed); static void check_spw_file (int *errors, bool *changed);
/* /*
* usage - print syntax message and exit * usage - print syntax message and exit
@ -217,7 +217,7 @@ static void open_files (void)
* changes are committed in the databases. The databases are * changes are committed in the databases. The databases are
* unlocked anyway. * unlocked anyway.
*/ */
static void close_files (int changed) static void close_files (bool changed)
{ {
/* /*
* All done. If there were no change we can just abandon any * All done. If there were no change we can just abandon any
@ -252,7 +252,7 @@ static void close_files (int changed)
/* /*
* check_pw_file - check the content of the passwd file * check_pw_file - check the content of the passwd file
*/ */
static void check_pw_file (int *errors, int *changed) static void check_pw_file (int *errors, bool *changed)
{ {
struct commonio_entry *pfe, *tpfe; struct commonio_entry *pfe, *tpfe;
struct passwd *pwd; struct passwd *pwd;
@ -266,7 +266,7 @@ static void check_pw_file (int *errors, int *changed)
* If this is a NIS line, skip it. You can't "know" what NIS * If this is a NIS line, skip it. You can't "know" what NIS
* is going to do without directly asking NIS ... * is going to do without directly asking NIS ...
*/ */
if ((pfe->line[0] == '+') || (pfe->line[0] == '-')) { if (('+' == pfe->line[0]) || ('-' == pfe->line[0])) {
continue; continue;
} }
@ -300,7 +300,7 @@ static void check_pw_file (int *errors, int *changed)
delete_pw: delete_pw:
SYSLOG ((LOG_INFO, "delete passwd line `%s'", SYSLOG ((LOG_INFO, "delete passwd line `%s'",
pfe->line)); pfe->line));
*changed = 1; *changed = true;
__pw_del_entry (pfe); __pw_del_entry (pfe);
continue; continue;
@ -407,7 +407,7 @@ static void check_pw_file (int *errors, int *changed)
if (is_shadow) { if (is_shadow) {
spw = (struct spwd *) spw_locate (pwd->pw_name); spw = (struct spwd *) spw_locate (pwd->pw_name);
if (spw == NULL) { if (NULL == spw) {
printf (_("no matching password file entry in %s\n"), printf (_("no matching password file entry in %s\n"),
spw_file); spw_file);
printf (_("add user '%s' in %s? "), printf (_("add user '%s' in %s? "),
@ -430,7 +430,7 @@ static void check_pw_file (int *errors, int *changed)
sp.sp_flag = -1; sp.sp_flag = -1;
sp.sp_lstchg = sp.sp_lstchg =
time ((time_t *) 0) / (24L * 3600L); time ((time_t *) 0) / (24L * 3600L);
*changed = 1; *changed = true;
if (spw_update (&sp) == 0) { if (spw_update (&sp) == 0) {
fprintf (stderr, fprintf (stderr,
@ -456,7 +456,7 @@ static void check_pw_file (int *errors, int *changed)
/* /*
* check_spw_file - check the content of the shadowed password file (shadow) * check_spw_file - check the content of the shadowed password file (shadow)
*/ */
static void check_spw_file (int *errors, int *changed) static void check_spw_file (int *errors, bool *changed)
{ {
struct commonio_entry *spe, *tspe; struct commonio_entry *spe, *tspe;
struct spwd *spw; struct spwd *spw;
@ -469,7 +469,7 @@ static void check_spw_file (int *errors, int *changed)
* Do not treat lines which were missing in shadow * Do not treat lines which were missing in shadow
* and were added earlier. * and were added earlier.
*/ */
if (spe->line == NULL) { if (NULL == spe->line) {
continue; continue;
} }
@ -477,7 +477,7 @@ static void check_spw_file (int *errors, int *changed)
* If this is a NIS line, skip it. You can't "know" what NIS * If this is a NIS line, skip it. You can't "know" what NIS
* is going to do without directly asking NIS ... * is going to do without directly asking NIS ...
*/ */
if ((spe->line[0] == '+') || (spe->line[0] == '-')) { if (('+' == spe->line[0]) || ('-' == spe->line[0])) {
continue; continue;
} }
@ -511,7 +511,7 @@ static void check_spw_file (int *errors, int *changed)
delete_spw: delete_spw:
SYSLOG ((LOG_INFO, "delete shadow line `%s'", SYSLOG ((LOG_INFO, "delete shadow line `%s'",
spe->line)); spe->line));
*changed = 1; *changed = true;
__spw_del_entry (spe); __spw_del_entry (spe);
continue; continue;
@ -602,7 +602,7 @@ static void check_spw_file (int *errors, int *changed)
int main (int argc, char **argv) int main (int argc, char **argv)
{ {
int errors = 0; int errors = 0;
int changed = 0; bool changed = false;
/* /*
* Get my name so that I can use it to report errors. * Get my name so that I can use it to report errors.
@ -625,7 +625,7 @@ int main (int argc, char **argv)
if (is_shadow) { if (is_shadow) {
spw_sort (); spw_sort ();
} }
changed = 1; changed = true;
} else { } else {
check_pw_file (&errors, &changed); check_pw_file (&errors, &changed);
@ -641,13 +641,13 @@ int main (int argc, char **argv)
/* /*
* Tell the user what we did and exit. * Tell the user what we did and exit.
*/ */
if (errors != 0) { if (0 != errors) {
printf (changed ? printf (changed ?
_("%s: the files have been updated\n") : _("%s: the files have been updated\n") :
_("%s: no changes\n"), Prog); _("%s: no changes\n"), Prog);
} }
closelog (); closelog ();
exit (errors ? E_BADENTRY : E_OKAY); exit ((0 != errors) ? E_BADENTRY : E_OKAY);
} }