Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/make make(1): clean up list handling



details:   https://anonhg.NetBSD.org/src/rev/5466edad0c13
branches:  trunk
changeset: 937558:5466edad0c13
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Aug 21 07:04:31 2020 +0000

description:
make(1): clean up list handling

Lst_Init never returns NULL.  Casting postfix increment to void is
unnecessary since that is quite common.  Found a last instance of a
local variable named 'nlnode'.

diffstat:

 usr.bin/make/lst.c |  33 +++++++++++++++------------------
 1 files changed, 15 insertions(+), 18 deletions(-)

diffs (86 lines):

diff -r 5047e8d39df2 -r 5466edad0c13 usr.bin/make/lst.c
--- a/usr.bin/make/lst.c        Fri Aug 21 07:00:32 2020 +0000
+++ b/usr.bin/make/lst.c        Fri Aug 21 07:04:31 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lst.c,v 1.16 2020/08/21 07:00:32 rillig Exp $ */
+/* $NetBSD: lst.c,v 1.17 2020/08/21 07:04:31 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -38,11 +38,11 @@
 #include "make_malloc.h"
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: lst.c,v 1.16 2020/08/21 07:00:32 rillig Exp $";
+static char rcsid[] = "$NetBSD: lst.c,v 1.17 2020/08/21 07:04:31 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: lst.c,v 1.16 2020/08/21 07:00:32 rillig Exp $");
+__RCSID("$NetBSD: lst.c,v 1.17 2020/08/21 07:04:31 rillig Exp $");
 #endif /* not lint */
 #endif
 
@@ -136,9 +136,6 @@
     }
 
     newList = Lst_Init();
-    if (newList == NULL) {
-       return NULL;
-    }
 
     node = list->first;
     while (node != NULL) {
@@ -240,7 +237,7 @@
 ReturnStatus
 Lst_InsertAfter(Lst list, LstNode node, void *datum)
 {
-    LstNode nLNode;
+    LstNode newNode;
 
     if (LstValid(list) && (node == NULL && LstIsEmpty(list))) {
        goto ok;
@@ -251,22 +248,22 @@
     }
     ok:
 
-    nLNode = LstNodeNew(datum);
+    newNode = LstNodeNew(datum);
 
     if (node == NULL) {
-       nLNode->next = nLNode->prev = NULL;
-       list->first = list->last = nLNode;
+       newNode->next = newNode->prev = NULL;
+       list->first = list->last = newNode;
     } else {
-       nLNode->prev = node;
-       nLNode->next = node->next;
+       newNode->prev = node;
+       newNode->next = node->next;
 
-       node->next = nLNode;
-       if (nLNode->next != NULL) {
-           nLNode->next->prev = nLNode;
+       node->next = newNode;
+       if (newNode->next != NULL) {
+           newNode->next->prev = newNode;
        }
 
        if (node == list->last) {
-           list->last = nLNode;
+           list->last = newNode;
        }
     }
 
@@ -521,9 +518,9 @@
         */
        done = (next == NULL || next == list->first);
 
-       (void)tln->useCount++;
+       tln->useCount++;
        result = (*proc)(tln->datum, procData);
-       (void)tln->useCount--;
+       tln->useCount--;
 
        /*
         * Now check whether a node has been added.



Home | Main Index | Thread Index | Old Index