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): fix obvious bugs in -DCLEANUP mode



details:   https://anonhg.NetBSD.org/src/rev/1123873ec14b
branches:  trunk
changeset: 943072:1123873ec14b
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue Aug 25 16:50:02 2020 +0000

description:
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.

diffstat:

 usr.bin/make/main.c  |  8 ++++----
 usr.bin/make/parse.c |  8 ++++----
 usr.bin/make/suff.c  |  9 +++++----
 3 files changed, 13 insertions(+), 12 deletions(-)

diffs (114 lines):

diff -r 3e2a518c6d62 -r 1123873ec14b usr.bin/make/main.c
--- a/usr.bin/make/main.c       Tue Aug 25 16:39:19 2020 +0000
+++ b/usr.bin/make/main.c       Tue Aug 25 16:50:02 2020 +0000
@@ -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 @@
 #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 @@
 #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 */
diff -r 3e2a518c6d62 -r 1123873ec14b usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Tue Aug 25 16:39:19 2020 +0000
+++ b/usr.bin/make/parse.c      Tue Aug 25 16:50:02 2020 +0000
@@ -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 @@
 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);
diff -r 3e2a518c6d62 -r 1123873ec14b usr.bin/make/suff.c
--- a/usr.bin/make/suff.c       Tue Aug 25 16:39:19 2020 +0000
+++ b/usr.bin/make/suff.c       Tue Aug 25 16:50:02 2020 +0000
@@ -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 @@
 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 @@
 {
 #ifdef CLEANUP
     suffClean = Lst_Init();
+    sufflist = Lst_Init();
 #endif
     srclist = Lst_Init();
     transforms = Lst_Init();



Home | Main Index | Thread Index | Old Index