Index: common/yplib_host.c
===================================================================
RCS file: /cvs/src/usr.sbin/ypserv/common/yplib_host.c,v
retrieving revision 1.19
diff -u -p -r1.19 yplib_host.c
--- common/yplib_host.c 11 Sep 2015 12:42:47 -0000      1.19
+++ common/yplib_host.c 18 Sep 2015 04:20:46 -0000
@@ -115,10 +115,8 @@ yp_bind_local(u_long program, u_long ver
        tv.tv_usec = 0;
 
        client = clntudp_create(&rsrv_sin, program, version, tv, &rsrv_sock);
-       if (client == NULL) {
-               fprintf(stderr,"clntudp_create: no contact with localhost.\n");
-               exit(1);
-       }
+       if (client == NULL)
+               errx(1, "clntudp_create: no contact with localhost.");
        return(client);
 }
 
Index: revnetgroup/parse_netgroup.c
===================================================================
RCS file: /cvs/src/usr.sbin/ypserv/revnetgroup/parse_netgroup.c,v
retrieving revision 1.12
diff -u -p -r1.12 parse_netgroup.c
--- revnetgroup/parse_netgroup.c        27 Oct 2009 23:59:58 -0000      1.12
+++ revnetgroup/parse_netgroup.c        18 Sep 2015 04:20:46 -0000
@@ -151,12 +151,9 @@ __endnetgrent(void)
        while (gp) {
                ogp = gp;
                gp = gp->ng_next;
-               if (ogp->ng_str[NG_HOST])
-                       free(ogp->ng_str[NG_HOST]);
-               if (ogp->ng_str[NG_USER])
-                       free(ogp->ng_str[NG_USER]);
-               if (ogp->ng_str[NG_DOM])
-                       free(ogp->ng_str[NG_DOM]);
+               free(ogp->ng_str[NG_HOST]);
+               free(ogp->ng_str[NG_USER]);
+               free(ogp->ng_str[NG_DOM]);
                free(ogp);
        }
        grouphead.gr = NULL;
Index: stdhosts/stdhosts.c
===================================================================
RCS file: /cvs/src/usr.sbin/ypserv/stdhosts/stdhosts.c,v
retrieving revision 1.16
diff -u -p -r1.16 stdhosts.c
--- stdhosts/stdhosts.c 27 Oct 2009 23:59:58 -0000      1.16
+++ stdhosts/stdhosts.c 18 Sep 2015 04:20:46 -0000
@@ -77,10 +77,8 @@ main(int argc, char *argv[])
        struct in_addr host_addr;
        FILE    *data_file;
 
-       if (argc > 2) {
-               fprintf(stderr, "usage: stdhosts [file]\n");
-               exit(1);
-       }
+       if (argc > 2)
+               errx(1, "usage: stdhosts [file]");
 
        if (argc == 2) {
                if ((data_file = fopen(argv[argc-1], "r")) == NULL)
Index: yppush/yppush.c
===================================================================
RCS file: /cvs/src/usr.sbin/ypserv/yppush/yppush.c,v
retrieving revision 1.31
diff -u -p -r1.31 yppush.c
--- yppush/yppush.c     16 Jan 2015 06:40:23 -0000      1.31
+++ yppush/yppush.c     18 Sep 2015 04:20:46 -0000
@@ -95,8 +95,7 @@ my_svc_run(void)
                        free(pfd);
                        return;
                case 0:
-                       fprintf(stderr, "yppush: Callback timed out.\n");
-                       exit(0);
+                       errx(0, "yppush: Callback timed out.");
                default:
                        svc_getreq_poll(pfd, nready);
                        break;
@@ -184,8 +183,7 @@ push(int inlen, char *indata)
 
        switch (pid=fork()) {
        case -1:
-               fprintf(stderr, "yppush: Cannot fork.\n");
-               exit(1);
+               errx(1, "yppush: Cannot fork.");
        case 0:
                my_svc_run();
                exit(0);
@@ -258,18 +256,14 @@ main(int argc, char *argv[])
 
        /* Check domain */
        snprintf(map_path, sizeof map_path, "%s/%s", YP_DB_PATH, domain);
-       if (!((stat(map_path, &finfo) == 0) && S_ISDIR(finfo.st_mode))) {
-               fprintf(stderr, "yppush: Map does not exist.\n");
-               exit(1);
-       }
+       if (!((stat(map_path, &finfo) == 0) && S_ISDIR(finfo.st_mode)))
+               errx(1, "yppush: Map does not exist.");
 
        /* Check map */
        snprintf(map_path, sizeof map_path, "%s/%s/%s%s",
            YP_DB_PATH, domain, Map, YPDB_SUFFIX);
-       if (!(stat(map_path, &finfo) == 0)) {
-               fprintf(stderr, "yppush: Map does not exist.\n");
-               exit(1);
-       }
+       if (!(stat(map_path, &finfo) == 0))
+               errx(1, "yppush: Map does not exist.");
 
        snprintf(map_path, sizeof map_path, "%s/%s/%s",
            YP_DB_PATH, domain, Map);
@@ -305,10 +299,8 @@ main(int argc, char *argv[])
        yp_bind(Domain);
 
        r = yp_master(Domain, ypmap, &master);
-       if (r != 0) {
-               fprintf(stderr, "yppush: could not get ypservers map\n");
-               exit(1);
-       }
+       if (r != 0)
+               errx(1, "yppush: could not get ypservers map");
 
        if (hostname != NULL) {
                push(strlen(hostname), hostname);
Index: ypserv/ypserv_db.c
===================================================================
RCS file: /cvs/src/usr.sbin/ypserv/ypserv/ypserv_db.c,v
retrieving revision 1.29
diff -u -p -r1.29 ypserv_db.c
--- ypserv/ypserv_db.c  16 Jan 2015 06:40:23 -0000      1.29
+++ ypserv/ypserv_db.c  18 Sep 2015 04:20:46 -0000
@@ -301,8 +301,7 @@ ypdb_open_db(domainname domain, mapname 
                if (d == NULL || d->domain == NULL) {
                        yplog("  ypdb_open_db: MALLOC failed");
                        ypdb_close(db);
-                       if (d)
-                               free(d);
+                       free(d);
                        return(NULL);
                }
                LIST_INIT(&d->dmaps);
@@ -320,8 +319,7 @@ ypdb_open_db(domainname domain, mapname 
        if (m)
                m->map = strdup(map);
        if (m == NULL || m->map == NULL) {
-               if (m)
-                       free(m);
+               free(m);
                yplog("  ypdb_open_db: MALLOC failed");
                ypdb_close(db);
                return(NULL);

Reply via email to