Use nitems instead of "sizeof ypaliases/sizeof ypaliases[0]".
Make the if statement more expressive. Differential Revision: D3366 Reviewed by: ed Approved by: bapt, rodrigc (mentor)
This commit is contained in:
parent
2115d98b6b
commit
bc6d0f54b1
@ -96,7 +96,7 @@ main(int argc, char *argv[])
|
||||
while ((c = getopt(argc, argv, "xd:kt")) != -1)
|
||||
switch (c) {
|
||||
case 'x':
|
||||
for (i=0; i<sizeof ypaliases/sizeof ypaliases[0]; i++)
|
||||
for (i = 0; i < nitems(ypaliases); i++)
|
||||
printf("Use \"%s\" for \"%s\"\n",
|
||||
ypaliases[i].alias, ypaliases[i].name);
|
||||
exit(0);
|
||||
@ -120,8 +120,8 @@ main(int argc, char *argv[])
|
||||
yp_get_default_domain(&domain);
|
||||
|
||||
inmap = argv[optind];
|
||||
if (!notrans) {
|
||||
for (i=0; i<sizeof ypaliases/sizeof ypaliases[0]; i++)
|
||||
if (notrans == 0) {
|
||||
for (i = 0; i < nitems(ypaliases); i++)
|
||||
if (strcmp(inmap, ypaliases[i].alias) == 0)
|
||||
inmap = ypaliases[i].name;
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ main(int argc, char *argv[])
|
||||
while ((c = getopt(argc, argv, "xd:mt")) != -1)
|
||||
switch (c) {
|
||||
case 'x':
|
||||
for (i = 0; i<sizeof ypaliases/sizeof ypaliases[0]; i++)
|
||||
for (i = 0; i < nitems(ypaliases); i++)
|
||||
printf("\"%s\" is an alias for \"%s\"\n",
|
||||
ypaliases[i].alias,
|
||||
ypaliases[i].name);
|
||||
@ -169,7 +169,7 @@ main(int argc, char *argv[])
|
||||
usage();
|
||||
}
|
||||
|
||||
if (!domnam)
|
||||
if (domnam == NULL)
|
||||
yp_get_default_domain(&domnam);
|
||||
|
||||
if (mode == 0) {
|
||||
@ -206,9 +206,11 @@ main(int argc, char *argv[])
|
||||
|
||||
if (argv[optind]) {
|
||||
map = argv[optind];
|
||||
for (i = 0; (!notrans) && i<sizeof ypaliases/sizeof ypaliases[0]; i++)
|
||||
if (strcmp(map, ypaliases[i].alias) == 0)
|
||||
map = ypaliases[i].name;
|
||||
if (notrans == 0) {
|
||||
for (i = 0; i < nitems(ypaliases); i++)
|
||||
if (strcmp(map, ypaliases[i].alias) == 0)
|
||||
map = ypaliases[i].name;
|
||||
}
|
||||
r = yp_master(domnam, map, &master);
|
||||
switch (r) {
|
||||
case 0:
|
||||
|
Loading…
Reference in New Issue
Block a user