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 sure devitab is correctly handled, in ...



details:   https://anonhg.NetBSD.org/src/rev/9b28fb920fc0
branches:  trunk
changeset: 583464:9b28fb920fc0
user:      cube <cube%NetBSD.org@localhost>
date:      Sun Aug 07 15:11:12 2005 +0000

description:
- Make sure devitab is correctly handled, in case we're removing the entry
  it contains,
- Properly update the d_ihead list:  if we have remaining aliases, use them
  to fill in the gap

Thanks to Bernd Ernesti for the test cases.

diffstat:

 usr.bin/config/sem.c |  35 +++++++++++++++++++++++------------
 1 files changed, 23 insertions(+), 12 deletions(-)

diffs (62 lines):

diff -r ba18dbe6cfcb -r 9b28fb920fc0 usr.bin/config/sem.c
--- a/usr.bin/config/sem.c      Sun Aug 07 12:32:38 2005 +0000
+++ b/usr.bin/config/sem.c      Sun Aug 07 15:11:12 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sem.c,v 1.4 2005/07/25 22:31:07 cube Exp $     */
+/*     $NetBSD: sem.c,v 1.5 2005/08/07 15:11:12 cube Exp $     */
 
 /*
  * Copyright (c) 1992, 1993
@@ -1078,15 +1078,23 @@
         *      If it was the only entry, we must remove i's entry from d's
         *      list.
         */
-       if (previ != NULL)
+       if (previ != NULL) {
                previ->i_alias = i->i_alias;
-       else {
-               if (i->i_alias == NULL)
+               if (i == firsti)
+                       ht_replace(devitab, name, previ);
+       } else {
+               if (i->i_alias == NULL) {
                        /* No alias, must unlink the entry from devitab */
-                       ht_remove(devitab, i->i_name);
-               else
+                       ht_remove(devitab, name);
+                       match = i->i_bsame;
+               } else {
                        /* Or have the first alias replace i in d's list */
                        i->i_alias->i_bsame = i->i_bsame;
+                       match = i->i_alias;
+                       if (i == firsti)
+                               ht_replace(devitab, name, i->i_alias);
+               }
+
                /*
                 *   - remove/replace the instance from the devbase's list
                 *
@@ -1102,14 +1110,17 @@
                previ = *ppi;
                if (previ == i)
                        /* That implies d->d_ihead == i */
-                       *ppi = i->i_bsame;
+                       *ppi = match;
                else
-                       (*ppi)->i_bsame = i->i_bsame;
+                       (*ppi)->i_bsame = match;
                if (d->d_ipp == &i->i_bsame) {
-                       if (previ == i)
-                               d->d_ipp = &d->d_ihead;
-                       else
-                               d->d_ipp = &previ->i_bsame;
+                       if (i->i_alias == NULL) {
+                               if (previ == i)
+                                       d->d_ipp = &d->d_ihead;
+                               else
+                                       d->d_ipp = &previ->i_bsame;
+                       } else
+                               d->d_ipp = &i->i_alias->i_bsame;
                }
        }
        /*



Home | Main Index | Thread Index | Old Index