summaryrefslogtreecommitdiffstats
path: root/usr.bin/ypwhich
diff options
context:
space:
mode:
authoraraujo <araujo@FreeBSD.org>2015-08-13 02:36:37 +0000
committeraraujo <araujo@FreeBSD.org>2015-08-13 02:36:37 +0000
commitbc6d0f54b1689cf5852d9dc70a464a73077fc305 (patch)
tree73cd46e1f1f99eeed373625e13c683b794fbf228 /usr.bin/ypwhich
parent2115d98b6b95b9077f77d06b950b9d525af100b3 (diff)
downloadFreeBSD-src-bc6d0f54b1689cf5852d9dc70a464a73077fc305.zip
FreeBSD-src-bc6d0f54b1689cf5852d9dc70a464a73077fc305.tar.gz
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)
Diffstat (limited to 'usr.bin/ypwhich')
-rw-r--r--usr.bin/ypwhich/ypwhich.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/usr.bin/ypwhich/ypwhich.c b/usr.bin/ypwhich/ypwhich.c
index 14fc1b3..4e2c3a0 100644
--- a/usr.bin/ypwhich/ypwhich.c
+++ b/usr.bin/ypwhich/ypwhich.c
@@ -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:
OpenPOWER on IntegriCloud