summaryrefslogtreecommitdiff
path: root/usr.bin/ypwhich
diff options
context:
space:
mode:
authorMarcelo Araujo <araujo@FreeBSD.org>2015-08-13 02:36:37 +0000
committerMarcelo Araujo <araujo@FreeBSD.org>2015-08-13 02:36:37 +0000
commit07c1d44f874553b335a6f48ef9c65ddb336a39e0 (patch)
tree73cd46e1f1f99eeed373625e13c683b794fbf228 /usr.bin/ypwhich
parent9b7147021496fa61a30cb8804c11049772731d83 (diff)
downloadsrc-test-07c1d44f874553b335a6f48ef9c65ddb336a39e0.tar.gz
src-test-07c1d44f874553b335a6f48ef9c65ddb336a39e0.zip
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)
Notes
Notes: svn path=/head/; revision=286716
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 14fc1b344125e..4e2c3a0fe67aa 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: