Module Name:    src
Committed By:   rillig
Date:           Tue Aug 25 16:50:02 UTC 2020

Modified Files:
        src/usr.bin/make: main.c parse.c suff.c

Log Message:
make(1): fix obvious bugs in -DCLEANUP mode

The outdated type name FreeProc had been renamed to LstFreeProc.
Casting the function free to it is not necessary since the type of this
function is already exactly the correct type.  Anything else would be
undefined behavior anyway.

The uninitialized sufflist in Suff_ClearSuffixes was ok until now
because the Lst functions had silently skipped any calls with invalid
arguments.  This silent skipping is a good argument to have strict
argument validation since it detects these unintended control flows.


To generate a diff of this commit:
cvs rdiff -u -r1.312 -r1.313 src/usr.bin/make/main.c
cvs rdiff -u -r1.261 -r1.262 src/usr.bin/make/parse.c
cvs rdiff -u -r1.114 -r1.115 src/usr.bin/make/suff.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/main.c
diff -u src/usr.bin/make/main.c:1.312 src/usr.bin/make/main.c:1.313
--- src/usr.bin/make/main.c:1.312	Sun Aug 23 18:26:35 2020
+++ src/usr.bin/make/main.c	Tue Aug 25 16:50:02 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.312 2020/08/23 18:26:35 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.313 2020/08/25 16:50:02 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.312 2020/08/23 18:26:35 rillig Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.313 2020/08/25 16:50:02 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
@@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19
 #if 0
 static char sccsid[] = "@(#)main.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: main.c,v 1.312 2020/08/23 18:26:35 rillig Exp $");
+__RCSID("$NetBSD: main.c,v 1.313 2020/08/25 16:50:02 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1469,7 +1469,7 @@ main(int argc, char **argv)
 #ifdef CLEANUP
 	Lst_Destroy(variables, NULL);
 	Lst_Destroy(makefiles, NULL);
-	Lst_Destroy(create, (FreeProc *)free);
+	Lst_Destroy(create, free);
 #endif
 
 	/* print the graph now it's been processed if the user requested it */

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.261 src/usr.bin/make/parse.c:1.262
--- src/usr.bin/make/parse.c:1.261	Sat Aug 22 22:41:42 2020
+++ src/usr.bin/make/parse.c	Tue Aug 25 16:50:02 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.261 2020/08/22 22:41:42 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.262 2020/08/25 16:50:02 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: parse.c,v 1.261 2020/08/22 22:41:42 rillig Exp $";
+static char rcsid[] = "$NetBSD: parse.c,v 1.262 2020/08/25 16:50:02 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)parse.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: parse.c,v 1.261 2020/08/22 22:41:42 rillig Exp $");
+__RCSID("$NetBSD: parse.c,v 1.262 2020/08/25 16:50:02 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -3295,7 +3295,7 @@ void
 Parse_End(void)
 {
 #ifdef CLEANUP
-    Lst_Destroy(targCmds, (FreeProc *)free);
+    Lst_Destroy(targCmds, free);
     if (targets)
 	Lst_Destroy(targets, NULL);
     Lst_Destroy(defIncPath, Dir_Destroy);

Index: src/usr.bin/make/suff.c
diff -u src/usr.bin/make/suff.c:1.114 src/usr.bin/make/suff.c:1.115
--- src/usr.bin/make/suff.c:1.114	Sun Aug 23 16:58:02 2020
+++ src/usr.bin/make/suff.c	Tue Aug 25 16:50:02 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: suff.c,v 1.114 2020/08/23 16:58:02 rillig Exp $	*/
+/*	$NetBSD: suff.c,v 1.115 2020/08/25 16:50:02 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: suff.c,v 1.114 2020/08/23 16:58:02 rillig Exp $";
+static char rcsid[] = "$NetBSD: suff.c,v 1.115 2020/08/25 16:50:02 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)suff.c	8.4 (Berkeley) 3/21/94";
 #else
-__RCSID("$NetBSD: suff.c,v 1.114 2020/08/23 16:58:02 rillig Exp $");
+__RCSID("$NetBSD: suff.c,v 1.115 2020/08/25 16:50:02 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -548,7 +548,7 @@ void
 Suff_ClearSuffixes(void)
 {
 #ifdef CLEANUP
-    Lst_Concat(suffClean, sufflist, LST_CONCLINK);
+    Lst_MoveAllS(suffClean, sufflist);
 #endif
     sufflist = Lst_Init();
     sNum = 0;
@@ -2552,6 +2552,7 @@ Suff_Init(void)
 {
 #ifdef CLEANUP
     suffClean = Lst_Init();
+    sufflist = Lst_Init();
 #endif
     srclist = Lst_Init();
     transforms = Lst_Init();

Reply via email to