Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/config Refactor attr definition and initialization a...



details:   https://anonhg.NetBSD.org/src/rev/111db783b1af
branches:  trunk
changeset: 332806:111db783b1af
user:      uebayasi <uebayasi%NetBSD.org@localhost>
date:      Fri Oct 10 05:27:28 2014 +0000

description:
Refactor attr definition and initialization a little.

diffstat:

 usr.bin/config/defs.h |  14 +++++++++-----
 usr.bin/config/sem.c  |  28 +++++++++++++---------------
 2 files changed, 22 insertions(+), 20 deletions(-)

diffs (89 lines):

diff -r a10edec6f0ce -r 111db783b1af usr.bin/config/defs.h
--- a/usr.bin/config/defs.h     Fri Oct 10 05:10:59 2014 +0000
+++ b/usr.bin/config/defs.h     Fri Oct 10 05:27:28 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: defs.h,v 1.53 2014/10/09 19:27:04 uebayasi Exp $       */
+/*     $NetBSD: defs.h,v 1.54 2014/10/10 05:27:28 uebayasi Exp $       */
 
 /*
  * Copyright (c) 1992, 1993
@@ -166,15 +166,19 @@
  */
 struct attr {
        const char *a_name;             /* name of this attribute */
+       struct  attrlist *a_deps;       /* we depend on these other attrs */
+       int     a_expanding;            /* to detect cycles in attr graph */
+       TAILQ_HEAD(, files) a_files;    /* files in this attr */
+
+       /* "interface attribute" */
        int     a_iattr;                /* true => allows children */
-       const char *a_devclass;         /* device class described */
        struct  loclist *a_locs;        /* locators required */
        int     a_loclen;               /* length of above list */
        struct  nvlist *a_devs;         /* children */
        struct  nvlist *a_refs;         /* parents */
-       struct  attrlist *a_deps;       /* we depend on these other attrs */
-       int     a_expanding;            /* to detect cycles in attr graph */
-       TAILQ_HEAD(, files) a_files;    /* files in this attr */
+
+       /* "device class" */
+       const char *a_devclass;         /* device class described */
 };
 
 /*
diff -r a10edec6f0ce -r 111db783b1af usr.bin/config/sem.c
--- a/usr.bin/config/sem.c      Fri Oct 10 05:10:59 2014 +0000
+++ b/usr.bin/config/sem.c      Fri Oct 10 05:27:28 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sem.c,v 1.47 2014/10/09 16:08:36 uebayasi Exp $        */
+/*     $NetBSD: sem.c,v 1.48 2014/10/10 05:27:28 uebayasi Exp $        */
 
 /*
  * Copyright (c) 1992, 1993
@@ -240,16 +240,24 @@
        }
 
        a->a_name = name;
+       a->a_deps = deps;
+       a->a_expanding = 0;
+       TAILQ_INIT(&a->a_files);
+
+       /* "interface attribute" initialization */
        if (locs != NULL) {
                a->a_iattr = 1;
                /* unwrap */
                a->a_locs = locs->ll_next;
                locs->ll_next = NULL;
                loclist_destroy(locs);
-       } else {
-               a->a_iattr = 0;
-               a->a_locs = NULL;
+               len = 0;
+               for (ll = a->a_locs; ll != NULL; ll = ll->ll_next)
+                       len++;
+               a->a_loclen = len;
        }
+
+       /* "device class" initialization */
        if (devclass) {
                char classenum[256], *cp;
                int errored = 0;
@@ -266,17 +274,7 @@
                        *cp = toupper((unsigned char)*cp);
                }
                a->a_devclass = intern(classenum);
-       } else
-               a->a_devclass = NULL;
-       len = 0;
-       for (ll = a->a_locs; ll != NULL; ll = ll->ll_next)
-               len++;
-       a->a_loclen = len;
-       a->a_devs = NULL;
-       a->a_refs = NULL;
-       a->a_deps = deps;
-       a->a_expanding = 0;
-       TAILQ_INIT(&a->a_files);
+       }
 
        /* Expand the attribute to check for cycles in the graph. */
        expandattr(a, NULL);



Home | Main Index | Thread Index | Old Index