Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/mount_portal KNF: blank lines after declarations, retu...



details:   https://anonhg.NetBSD.org/src/rev/c15f4dcd49dd
branches:  trunk
changeset: 456673:c15f4dcd49dd
user:      kre <kre%NetBSD.org@localhost>
date:      Thu May 23 02:39:06 2019 +0000

description:
KNF:  blank lines after declarations, return (x) -> return x, and
      eliminate spaces between cast and value being cast (most were OK already)
NFCI.

diffstat:

 sbin/mount_portal/conf.c |  46 +++++++++++++++++++++++++++-------------------
 1 files changed, 27 insertions(+), 19 deletions(-)

diffs (154 lines):

diff -r 2f557c32f730 -r c15f4dcd49dd sbin/mount_portal/conf.c
--- a/sbin/mount_portal/conf.c  Wed May 22 23:22:24 2019 +0000
+++ b/sbin/mount_portal/conf.c  Thu May 23 02:39:06 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: conf.c,v 1.12 2007/07/02 16:33:05 pooka Exp $  */
+/*     $NetBSD: conf.c,v 1.13 2019/05/23 02:39:06 kre Exp $    */
 
 /*
  * Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: conf.c,v 1.12 2007/07/02 16:33:05 pooka Exp $");
+__RCSID("$NetBSD: conf.c,v 1.13 2019/05/23 02:39:06 kre Exp $");
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -109,8 +109,10 @@
 xmalloc(size_t siz)
 {
        void *p = malloc(siz);
+
        if (p)
-               return (p);
+               return p;
+
        syslog(LOG_ERR, "malloc: failed to get %lu bytes", (u_long)siz);
        exit(1);
 }
@@ -128,15 +130,16 @@
        qelem *q;
 
        if (p0->p_argc == 0)
-               return (0);
+               return 0;
 
        for (q = q0->q_forw; q != q0; q = q->q_forw) {
-               path *p = (path *) q;
+               path *p = (path *)q;
+
                if (strcmp(p->p_key, p0->p_key) == 0)
-                       return (0);
+                       return 0;
        }
        ins_que(&p0->p_q, q0->q_back);
-       return (1);
+       return 1;
        
 }
 
@@ -164,6 +167,7 @@
        key = strdup(cline);
        for (s = key; s != NULL; ) {
                char *val;
+
                while ((val = strsep(&s, " \t\n")) != NULL && *val == '\0')
                        ;
                if (val)
@@ -173,7 +177,7 @@
        free(key);
 
        if (c <= 1)
-               return (0);
+               return 0;
 
        /*
         * Now do another pass and generate a new path structure
@@ -185,6 +189,7 @@
        ap = p->p_argv;
        for (s = p->p_args; s != NULL; ) {
                char *val;
+
                while ((val = strsep(&s, " \t\n")) != NULL && *val == '\0')
                        ;
                if (val) {
@@ -215,7 +220,7 @@
        }
        p->p_lno = lno;
 
-       return (p);
+       return p;
 }
 
 /*
@@ -225,10 +230,10 @@
 pfree(path *p)
 {
        free(p->p_args);
-       free((char *) p->p_argv);
+       free((char *)p->p_argv);
        if (p->p_use_re)
                regfree(&p->p_re);
-       free((char *) p);
+       free((char *)p);
 }
 
 /*
@@ -246,7 +251,7 @@
        while (q0->q_forw != q0) {
                qelem *q = q0->q_forw;
                rem_que(q);
-               pfree((path *) q);
+               pfree((path *)q);
        }
        while (xq->q_forw != xq) {
                qelem *q = xq->q_forw;
@@ -276,6 +281,7 @@
         */
        while (fgets(cline, sizeof(cline), fp)) {
                path *p = palloc(cline, nread+1, conf_file);
+
                if (p && !pinsert(p, &q))
                        pfree(p);
                nread++;
@@ -299,13 +305,14 @@
 conf_read(qelem *q, const char *conf)
 {
        FILE *fp = fopen(conf, "r");
-       int sverrno;
+
        if (fp) {
                readfp(q, fp, conf);
-               (void) fclose(fp);
+               (void)fclose(fp);
                return 0;
        } else {
-               sverrno = errno;
+               int sverrno = errno;
+
                syslog(LOG_WARNING, "open config file \"%s\": %m", conf);
                errno = sverrno;
                return -1;
@@ -319,15 +326,16 @@
        qelem *q;
 
        for (q = q0->q_forw; q != q0; q = q->q_forw) {
-               path *p = (path *) q;
+               path *p = (path *)q;
+
                if (p->p_use_re) {
                        if (regexec(&p->p_re, key, 0, NULL, 0) == 0)
-                               return (p->p_argv+1);
+                               return p->p_argv + 1;
                } else {
                        if (strncmp(p->p_key, key, strlen(p->p_key)) == 0)
-                               return (p->p_argv+1);
+                               return p->p_argv + 1;
                }
        }
 
-       return (0);
+       return 0;
 }



Home | Main Index | Thread Index | Old Index