Sat Nov 1 04:34:27 2014 UTC ()
config(1): KNF


(uebayasi)
diff -r1.66 -r1.67 src/usr.bin/config/sem.c

cvs diff -r1.66 -r1.67 src/usr.bin/config/sem.c (expand / switch to unified diff)

--- src/usr.bin/config/sem.c 2014/10/31 07:38:36 1.66
+++ src/usr.bin/config/sem.c 2014/11/01 04:34:27 1.67
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: sem.c,v 1.66 2014/10/31 07:38:36 uebayasi Exp $ */ 1/* $NetBSD: sem.c,v 1.67 2014/11/01 04:34:27 uebayasi Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1992, 1993 4 * Copyright (c) 1992, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * This software was developed by the Computer Systems Engineering group 7 * This software was developed by the Computer Systems Engineering group
8 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 8 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
9 * contributed to Berkeley. 9 * contributed to Berkeley.
10 * 10 *
11 * All advertising materials mentioning features or use of this software 11 * All advertising materials mentioning features or use of this software
12 * must display the following acknowledgement: 12 * must display the following acknowledgement:
13 * This product includes software developed by the University of 13 * This product includes software developed by the University of
14 * California, Lawrence Berkeley Laboratories. 14 * California, Lawrence Berkeley Laboratories.
@@ -35,27 +35,27 @@ @@ -35,27 +35,27 @@
35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 * SUCH DAMAGE. 38 * SUCH DAMAGE.
39 * 39 *
40 * from: @(#)sem.c 8.1 (Berkeley) 6/6/93 40 * from: @(#)sem.c 8.1 (Berkeley) 6/6/93
41 */ 41 */
42 42
43#if HAVE_NBTOOL_CONFIG_H 43#if HAVE_NBTOOL_CONFIG_H
44#include "nbtool_config.h" 44#include "nbtool_config.h"
45#endif 45#endif
46 46
47#include <sys/cdefs.h> 47#include <sys/cdefs.h>
48__RCSID("$NetBSD: sem.c,v 1.66 2014/10/31 07:38:36 uebayasi Exp $"); 48__RCSID("$NetBSD: sem.c,v 1.67 2014/11/01 04:34:27 uebayasi Exp $");
49 49
50#include <sys/param.h> 50#include <sys/param.h>
51#include <ctype.h> 51#include <ctype.h>
52#include <stdio.h> 52#include <stdio.h>
53#include <stdlib.h> 53#include <stdlib.h>
54#include <string.h> 54#include <string.h>
55#include <util.h> 55#include <util.h>
56#include "defs.h" 56#include "defs.h"
57#include "sem.h" 57#include "sem.h"
58 58
59/* 59/*
60 * config semantics. 60 * config semantics.
61 */ 61 */
@@ -1319,76 +1319,79 @@ remove_devi(struct devi *i) @@ -1319,76 +1319,79 @@ remove_devi(struct devi *i)
1319 /* 1319 /*
1320 * We have the device instance, i. 1320 * We have the device instance, i.
1321 * We have to: 1321 * We have to:
1322 * - delete the alias 1322 * - delete the alias
1323 * 1323 *
1324 * If the devi was an alias of an already listed devi, all is 1324 * If the devi was an alias of an already listed devi, all is
1325 * good we don't have to do more. 1325 * good we don't have to do more.
1326 * If it was the first alias, we have to replace i's entry in 1326 * If it was the first alias, we have to replace i's entry in
1327 * d's list by its first alias. 1327 * d's list by its first alias.
1328 * If it was the only entry, we must remove i's entry from d's 1328 * If it was the only entry, we must remove i's entry from d's
1329 * list. 1329 * list.
1330 */ 1330 */
1331 if (i != f) { 1331 if (i != f) {
1332 for (j = f; j->i_alias != i; j = j->i_alias); 1332 for (j = f; j->i_alias != i; j = j->i_alias)
 1333 continue;
1333 j->i_alias = i->i_alias; 1334 j->i_alias = i->i_alias;
1334 } else { 1335 } else {
1335 if (i->i_alias == NULL) { 1336 if (i->i_alias == NULL) {
1336 /* No alias, must unlink the entry from devitab */ 1337 /* No alias, must unlink the entry from devitab */
1337 ht_remove(devitab, i->i_name); 1338 ht_remove(devitab, i->i_name);
1338 j = i->i_bsame; 1339 j = i->i_bsame;
1339 } else { 1340 } else {
1340 /* Or have the first alias replace i in d's list */ 1341 /* Or have the first alias replace i in d's list */
1341 i->i_alias->i_bsame = i->i_bsame; 1342 i->i_alias->i_bsame = i->i_bsame;
1342 j = i->i_alias; 1343 j = i->i_alias;
1343 if (i == f) 1344 if (i == f)
1344 ht_replace(devitab, i->i_name, i->i_alias); 1345 ht_replace(devitab, i->i_name, i->i_alias);
1345 } 1346 }
1346 1347
1347 /* 1348 /*
1348 * - remove/replace the instance from the devbase's list 1349 * - remove/replace the instance from the devbase's list
1349 * 1350 *
1350 * A double-linked list would make this much easier. Oh, well, 1351 * A double-linked list would make this much easier. Oh, well,
1351 * what is done is done. 1352 * what is done is done.
1352 */ 1353 */
1353 for (ppi = &d->d_ihead; 1354 for (ppi = &d->d_ihead;
1354 *ppi != NULL && *ppi != i && (*ppi)->i_bsame != i; 1355 *ppi != NULL && *ppi != i && (*ppi)->i_bsame != i;
1355 ppi = &(*ppi)->i_bsame); 1356 ppi = &(*ppi)->i_bsame)
 1357 continue;
1356 if (*ppi == NULL) 1358 if (*ppi == NULL)
1357 panic("deldev: dev (%s) doesn't list the devi" 1359 panic("deldev: dev (%s) doesn't list the devi"
1358 " (%s at %s)", d->d_name, i->i_name, i->i_at); 1360 " (%s at %s)", d->d_name, i->i_name, i->i_at);
1359 f = *ppi; 1361 f = *ppi;
1360 if (f == i) 1362 if (f == i)
1361 /* That implies d->d_ihead == i */ 1363 /* That implies d->d_ihead == i */
1362 *ppi = j; 1364 *ppi = j;
1363 else 1365 else
1364 (*ppi)->i_bsame = j; 1366 (*ppi)->i_bsame = j;
1365 if (d->d_ipp == &i->i_bsame) { 1367 if (d->d_ipp == &i->i_bsame) {
1366 if (i->i_alias == NULL) { 1368 if (i->i_alias == NULL) {
1367 if (f == i) 1369 if (f == i)
1368 d->d_ipp = &d->d_ihead; 1370 d->d_ipp = &d->d_ihead;
1369 else 1371 else
1370 d->d_ipp = &f->i_bsame; 1372 d->d_ipp = &f->i_bsame;
1371 } else 1373 } else
1372 d->d_ipp = &i->i_alias->i_bsame; 1374 d->d_ipp = &i->i_alias->i_bsame;
1373 } 1375 }
1374 } 1376 }
1375 /* 1377 /*
1376 * - delete the attachment instance 1378 * - delete the attachment instance
1377 */ 1379 */
1378 iba = i->i_atdeva; 1380 iba = i->i_atdeva;
1379 for (ppi = &iba->d_ihead; 1381 for (ppi = &iba->d_ihead;
1380 *ppi != NULL && *ppi != i && (*ppi)->i_asame != i; 1382 *ppi != NULL && *ppi != i && (*ppi)->i_asame != i;
1381 ppi = &(*ppi)->i_asame); 1383 ppi = &(*ppi)->i_asame)
 1384 continue;
1382 if (*ppi == NULL) 1385 if (*ppi == NULL)
1383 panic("deldev: deva (%s) doesn't list the devi (%s)", 1386 panic("deldev: deva (%s) doesn't list the devi (%s)",
1384 iba->d_name, i->i_name); 1387 iba->d_name, i->i_name);
1385 f = *ppi; 1388 f = *ppi;
1386 if (f == i) 1389 if (f == i)
1387 /* That implies iba->d_ihead == i */ 1390 /* That implies iba->d_ihead == i */
1388 *ppi = i->i_asame; 1391 *ppi = i->i_asame;
1389 else 1392 else
1390 (*ppi)->i_asame = i->i_asame; 1393 (*ppi)->i_asame = i->i_asame;
1391 if (iba->d_ipp == &i->i_asame) { 1394 if (iba->d_ipp == &i->i_asame) {
1392 if (f == i) 1395 if (f == i)
1393 iba->d_ipp = &iba->d_ihead; 1396 iba->d_ipp = &iba->d_ihead;
1394 else 1397 else
@@ -1432,27 +1435,28 @@ remove_devi(struct devi *i) @@ -1432,27 +1435,28 @@ remove_devi(struct devi *i)
1432 * removal of its parent. 1435 * removal of its parent.
1433 * 1436 *
1434 * For active instances, i_level contains the number of devi removed so 1437 * For active instances, i_level contains the number of devi removed so
1435 * far, and for dead devis, it contains its index. 1438 * far, and for dead devis, it contains its index.
1436 */ 1439 */
1437 i->i_level = devilevel++; 1440 i->i_level = devilevel++;
1438 i->i_alias = NULL; 1441 i->i_alias = NULL;
1439 f = ht_lookup(deaddevitab, i->i_name); 1442 f = ht_lookup(deaddevitab, i->i_name);
1440 if (f == NULL) { 1443 if (f == NULL) {
1441 if (ht_insert(deaddevitab, i->i_name, i)) 1444 if (ht_insert(deaddevitab, i->i_name, i))
1442 panic("remove_devi(%s) - can't add to deaddevitab", 1445 panic("remove_devi(%s) - can't add to deaddevitab",
1443 i->i_name); 1446 i->i_name);
1444 } else { 1447 } else {
1445 for (j = f; j->i_alias != NULL; j = j->i_alias); 1448 for (j = f; j->i_alias != NULL; j = j->i_alias)
 1449 continue;
1446 j->i_alias = i; 1450 j->i_alias = i;
1447 } 1451 }
1448 /* 1452 /*
1449 * - reconstruct d->d_umax 1453 * - reconstruct d->d_umax
1450 */ 1454 */
1451 d->d_umax = 0; 1455 d->d_umax = 0;
1452 for (i = d->d_ihead; i != NULL; i = i->i_bsame) 1456 for (i = d->d_ihead; i != NULL; i = i->i_bsame)
1453 if (i->i_unit >= d->d_umax) 1457 if (i->i_unit >= d->d_umax)
1454 d->d_umax = i->i_unit + 1; 1458 d->d_umax = i->i_unit + 1;
1455} 1459}
1456 1460
1457void 1461void
1458deldeva(const char *at) 1462deldeva(const char *at)