Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/config - make the level computation consistent



details:   https://anonhg.NetBSD.org/src/rev/4bd62793b7ba
branches:  trunk
changeset: 357807:4bd62793b7ba
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Nov 28 15:31:33 2017 +0000

description:
- make the level computation consistent
- keep going only if things changed.

diffstat:

 usr.bin/config/main.c |  18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)

diffs (72 lines):

diff -r 9e137f9dd95f -r 4bd62793b7ba usr.bin/config/main.c
--- a/usr.bin/config/main.c     Tue Nov 28 13:09:05 2017 +0000
+++ b/usr.bin/config/main.c     Tue Nov 28 15:31:33 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.96 2017/11/27 00:25:46 christos Exp $       */
+/*     $NetBSD: main.c,v 1.97 2017/11/28 15:31:33 christos Exp $       */
 
 /*
  * Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: main.c,v 1.96 2017/11/27 00:25:46 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.97 2017/11/28 15:31:33 christos Exp $");
 
 #ifndef MAKE_BOOTSTRAP
 #include <sys/cdefs.h>
@@ -1876,21 +1876,22 @@
        struct devbase *p;
 
        if (d == parent) {
-               if (d->d_level++ > 1)
+               if (d->d_level > 1)
                        return 0;
                return 1;
        }
 
        if (d->d_levelparent) {
-               if (d->d_level++ > 1)
+               if (d->d_level > 1)
                        return 0;
                return 1;
        }
 
        for (p = parent; p != NULL; p = p->d_levelparent)
-               if (d == p && d->d_level++ > 1)
+               if (d == p && d->d_level > 1)
                        return 0;
        d->d_levelparent = p ? p : &root; 
+       d->d_level++;
        return 1;
 }
 
@@ -1926,6 +1927,7 @@
                }
        } else {
                int seen = 0;
+               int changed = 0;
 
                for (i = d->d_ihead; i != NULL; i = i->i_bsame) {
                        for (j = i; j != NULL; j = j->i_alias) {
@@ -1958,6 +1960,7 @@
                                                seen = 1;
                                                continue;
                                        }
+                                       changed |= j->i_active != state;
                                        j->i_active = active = state;
                                        if (p != NULL) {
                                                if (state == DEVI_ACTIVE ||
@@ -1997,8 +2000,9 @@
                                CFGDBG(5, "`%s' at '%s' ignored", d->d_name,
                                    parent ? parent->d_name : "(root)");
 
-                       }
-               }
+                       } else if (!changed)
+                               goto out;
+               } 
        }
 
        for (al = d->d_attrs; al != NULL; al = al->al_next) {



Home | Main Index | Thread Index | Old Index