Avoid implicit brackets.

This commit is contained in:
nekral-guest 2008-01-01 16:54:18 +00:00
parent f9f420b107
commit 27ed5ec8b9
2 changed files with 49 additions and 22 deletions

View File

@ -1,3 +1,7 @@
2008-01-01 Nicolas François <nicolas.francois@centraliens.net>
* src/grpck.c: Avoid implicit brackets.
2008-01-01 Nicolas François <nicolas.francois@centraliens.net> 2008-01-01 Nicolas François <nicolas.francois@centraliens.net>
* NEWS: No functional changes were introduced by the previous pwck * NEWS: No functional changes were introduced by the previous pwck

View File

@ -119,13 +119,17 @@ static void delete_member (char **list, const char *member)
{ {
int i; int i;
for (i = 0; list[i]; i++) for (i = 0; list[i]; i++) {
if (list[i] == member) if (list[i] == member) {
break; break;
}
}
if (list[i]) if (list[i]) {
for (; list[i]; i++) for (; list[i]; i++) {
list[i] = list[i + 1]; list[i] = list[i + 1];
}
}
} }
/* /*
@ -327,8 +331,9 @@ static int check_members (const char *groupname,
*/ */
for (i = 0; members[i]; i++) { for (i = 0; members[i]; i++) {
/* local, no need for xgetpwnam */ /* local, no need for xgetpwnam */
if (getpwnam (members[i])) if (getpwnam (members[i])) {
continue; continue;
}
/* /*
* Can't find this user. Remove them * Can't find this user. Remove them
* from the list. * from the list.
@ -337,8 +342,9 @@ static int check_members (const char *groupname,
printf (fmt_info, groupname, members[i]); printf (fmt_info, groupname, members[i]);
printf (fmt_prompt, members[i]); printf (fmt_prompt, members[i]);
if (!yes_or_no (read_only)) if (!yes_or_no (read_only)) {
continue; continue;
}
SYSLOG ((LOG_INFO, fmt_syslog, members[i], groupname)); SYSLOG ((LOG_INFO, fmt_syslog, members[i], groupname));
members_changed = 1; members_changed = 1;
@ -368,8 +374,9 @@ static void compare_members_lists (const char *groupname,
for (pmem = members; *pmem; pmem++) { for (pmem = members; *pmem; pmem++) {
for (other_pmem = other_members; *other_pmem; other_pmem++) { for (other_pmem = other_members; *other_pmem; other_pmem++) {
if (strcmp (*pmem, *other_pmem) == 0) if (strcmp (*pmem, *other_pmem) == 0) {
break; break;
}
} }
if (*other_pmem == NULL) { if (*other_pmem == NULL) {
printf printf
@ -398,8 +405,9 @@ static void check_grp_file (int *errors, int *changed)
* Skip all NIS entries. * Skip all NIS entries.
*/ */
if (gre->line[0] == '+' || gre->line[0] == '-') if ((gre->line[0] == '+') || (gre->line[0] == '-')) {
continue; continue;
}
/* /*
* Start with the entries that are completely corrupt. They * Start with the entries that are completely corrupt. They
@ -419,8 +427,9 @@ static void check_grp_file (int *errors, int *changed)
/* /*
* prompt the user to delete the entry or not * prompt the user to delete the entry or not
*/ */
if (!yes_or_no (read_only)) if (!yes_or_no (read_only)) {
continue; continue;
}
/* /*
* All group file deletions wind up here. This code * All group file deletions wind up here. This code
@ -452,17 +461,20 @@ static void check_grp_file (int *errors, int *changed)
/* /*
* Don't check this entry * Don't check this entry
*/ */
if (tgre == gre) if (tgre == gre) {
continue; continue;
}
/* /*
* Don't check invalid entries. * Don't check invalid entries.
*/ */
if (!ent) if (!ent) {
continue; continue;
}
if (strcmp (grp->gr_name, ent->gr_name) != 0) if (strcmp (grp->gr_name, ent->gr_name) != 0) {
continue; continue;
}
/* /*
* Tell the user this entry is a duplicate of * Tell the user this entry is a duplicate of
@ -475,8 +487,9 @@ static void check_grp_file (int *errors, int *changed)
/* /*
* prompt the user to delete the entry or not * prompt the user to delete the entry or not
*/ */
if (yes_or_no (read_only)) if (yes_or_no (read_only)) {
goto delete_gr; goto delete_gr;
}
} }
/* /*
@ -493,8 +506,9 @@ static void check_grp_file (int *errors, int *changed)
* member "", causing grpck to fail. --marekm * member "", causing grpck to fail. --marekm
*/ */
if (grp->gr_mem[0] && !grp->gr_mem[1] if (grp->gr_mem[0] && !grp->gr_mem[1]
&& *(grp->gr_mem[0]) == '\0') && *(grp->gr_mem[0]) == '\0') {
grp->gr_mem[0] = (char *) 0; grp->gr_mem[0] = (char *) 0;
}
if (check_members (grp->gr_name, grp->gr_mem, if (check_members (grp->gr_name, grp->gr_mem,
_("group %s: no user %s\n"), _("group %s: no user %s\n"),
@ -600,8 +614,9 @@ static void check_sgr_file (int *errors, int *changed)
/* /*
* prompt the user to delete the entry or not * prompt the user to delete the entry or not
*/ */
if (!yes_or_no (read_only)) if (!yes_or_no (read_only)) {
continue; continue;
}
/* /*
* All shadow group file deletions wind up here. * All shadow group file deletions wind up here.
@ -633,17 +648,20 @@ static void check_sgr_file (int *errors, int *changed)
/* /*
* Don't check this entry * Don't check this entry
*/ */
if (tsge == sge) if (tsge == sge) {
continue; continue;
}
/* /*
* Don't check invalid entries. * Don't check invalid entries.
*/ */
if (!ent) if (!ent) {
continue; continue;
}
if (strcmp (sgr->sg_name, ent->sg_name) != 0) if (strcmp (sgr->sg_name, ent->sg_name) != 0) {
continue; continue;
}
/* /*
* Tell the user this entry is a duplicate of * Tell the user this entry is a duplicate of
@ -656,8 +674,9 @@ static void check_sgr_file (int *errors, int *changed)
/* /*
* prompt the user to delete the entry or not * prompt the user to delete the entry or not
*/ */
if (yes_or_no (read_only)) if (yes_or_no (read_only)) {
goto delete_sg; goto delete_sg;
}
} }
/* /*
@ -669,8 +688,9 @@ static void check_sgr_file (int *errors, int *changed)
grp_file); grp_file);
printf (_("delete line '%s'? "), sge->line); printf (_("delete line '%s'? "), sge->line);
*errors += 1; *errors += 1;
if (yes_or_no (read_only)) if (yes_or_no (read_only)) {
goto delete_sg; goto delete_sg;
}
} else { } else {
/** /**
* Verify that the all members defined in /etc/gshadow are also * Verify that the all members defined in /etc/gshadow are also
@ -737,8 +757,9 @@ int main (int argc, char **argv)
if (sort_mode) { if (sort_mode) {
gr_sort (); gr_sort ();
#ifdef SHADOWGRP #ifdef SHADOWGRP
if (is_shadow) if (is_shadow) {
sgr_sort (); sgr_sort ();
}
changed = 1; changed = 1;
#endif #endif
} else { } else {
@ -758,10 +779,12 @@ int main (int argc, char **argv)
/* /*
* Tell the user what we did and exit. * Tell the user what we did and exit.
*/ */
if (errors) if (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);
}
exit (errors ? E_BAD_ENTRY : E_OKAY); exit (errors ? E_BAD_ENTRY : E_OKAY);
} }