Module Name: src
Committed By: rillig
Date: Fri Aug 21 07:04:31 UTC 2020
Modified Files:
src/usr.bin/make: lst.c
Log Message:
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'.
To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/usr.bin/make/lst.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/make/lst.c
diff -u src/usr.bin/make/lst.c:1.16 src/usr.bin/make/lst.c:1.17
--- src/usr.bin/make/lst.c:1.16 Fri Aug 21 07:00:32 2020
+++ src/usr.bin/make/lst.c Fri Aug 21 07:04:31 2020
@@ -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 @@ Lst_Duplicate(Lst list, DuplicateProc *c
}
newList = Lst_Init();
- if (newList == NULL) {
- return NULL;
- }
node = list->first;
while (node != NULL) {
@@ -240,7 +237,7 @@ Lst_InsertBefore(Lst list, LstNode node,
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 @@ Lst_InsertAfter(Lst list, LstNode node,
}
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 @@ Lst_ForEachFrom(Lst list, LstNode node,
*/
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.