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): replace "(void)Lst_AtEnd" with stricte...



details:   https://anonhg.NetBSD.org/src/rev/fd0d2e46b730
branches:  trunk
changeset: 975134:fd0d2e46b730
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Aug 22 11:35:00 2020 +0000

description:
make(1): replace "(void)Lst_AtEnd" with stricter "Lst_AppendS"

This change ensures that there is actually something added to the list.
Lst_AtEnd had silently skipped the addition if the list was invalid
(null pointer), which was not intended in these cases.  The "(void)" is
assumed to mean "I know that this cannot fail", while it could also mean
"I don't care whether something actually happened".

Running "./build.sh -j6 tools" still succeeds after this change,
therefore chances are very low that this change breaks anything.  If
there is any change, it's an obvious assertion failure.  There is no
silent change in behavior though.

diffstat:

 usr.bin/make/arch.c   |  14 +++++++-------
 usr.bin/make/compat.c |   8 ++++----
 usr.bin/make/dir.c    |  20 ++++++++++----------
 usr.bin/make/job.c    |   8 ++++----
 usr.bin/make/main.c   |  14 +++++++-------
 usr.bin/make/make.c   |  10 +++++-----
 usr.bin/make/parse.c  |  38 +++++++++++++++++++-------------------
 usr.bin/make/suff.c   |  42 +++++++++++++++++++++---------------------
 usr.bin/make/targ.c   |  10 +++++-----
 9 files changed, 82 insertions(+), 82 deletions(-)

diffs (truncated from 661 to 300 lines):

diff -r ebb6f43776d7 -r fd0d2e46b730 usr.bin/make/arch.c
--- a/usr.bin/make/arch.c       Sat Aug 22 11:27:02 2020 +0000
+++ b/usr.bin/make/arch.c       Sat Aug 22 11:35:00 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: arch.c,v 1.86 2020/08/21 04:42:02 rillig Exp $ */
+/*     $NetBSD: arch.c,v 1.87 2020/08/22 11:35:00 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: arch.c,v 1.86 2020/08/21 04:42:02 rillig Exp $";
+static char rcsid[] = "$NetBSD: arch.c,v 1.87 2020/08/22 11:35:00 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)arch.c     8.2 (Berkeley) 1/2/94";
 #else
-__RCSID("$NetBSD: arch.c,v 1.86 2020/08/21 04:42:02 rillig Exp $");
+__RCSID("$NetBSD: arch.c,v 1.87 2020/08/22 11:35:00 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -377,7 +377,7 @@
                    return FAILURE;
                } else {
                    gn->type |= OP_ARCHV;
-                   (void)Lst_AtEnd(nodeLst, gn);
+                   Lst_AppendS(nodeLst, gn);
                }
            } else if (Arch_ParseArchive(&sacrifice, nodeLst, ctxt)!=SUCCESS) {
                /*
@@ -419,7 +419,7 @@
                     * end of the provided list.
                     */
                    gn->type |= OP_ARCHV;
-                   (void)Lst_AtEnd(nodeLst, gn);
+                   Lst_AppendS(nodeLst, gn);
                }
            }
            Lst_Destroy(members, NULL);
@@ -441,7 +441,7 @@
                 * provided list.
                 */
                gn->type |= OP_ARCHV;
-               (void)Lst_AtEnd(nodeLst, gn);
+               Lst_AppendS(nodeLst, gn);
            }
        }
        if (doSubst) {
@@ -694,7 +694,7 @@
 
     fclose(arch);
 
-    (void)Lst_AtEnd(archives, ar);
+    Lst_AppendS(archives, ar);
 
     /*
      * Now that the archive has been read and cached, we can look into
diff -r ebb6f43776d7 -r fd0d2e46b730 usr.bin/make/compat.c
--- a/usr.bin/make/compat.c     Sat Aug 22 11:27:02 2020 +0000
+++ b/usr.bin/make/compat.c     Sat Aug 22 11:35:00 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat.c,v 1.121 2020/08/22 10:07:29 rillig Exp $      */
+/*     $NetBSD: compat.c,v 1.122 2020/08/22 11:35:00 rillig Exp $      */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: compat.c,v 1.121 2020/08/22 10:07:29 rillig Exp $";
+static char rcsid[] = "$NetBSD: compat.c,v 1.122 2020/08/22 11:35:00 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)compat.c   8.2 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: compat.c,v 1.121 2020/08/22 10:07:29 rillig Exp $");
+__RCSID("$NetBSD: compat.c,v 1.122 2020/08/22 11:35:00 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -250,7 +250,7 @@
     Lst_ReplaceS(cmdNode, cmdStart);
 
     if ((gn->type & OP_SAVE_CMDS) && (gn != ENDNode)) {
-       (void)Lst_AtEnd(ENDNode->commands, cmdStart);
+       Lst_AppendS(ENDNode->commands, cmdStart);
        return 0;
     }
     if (strcmp(cmdStart, "...") == 0) {
diff -r ebb6f43776d7 -r fd0d2e46b730 usr.bin/make/dir.c
--- a/usr.bin/make/dir.c        Sat Aug 22 11:27:02 2020 +0000
+++ b/usr.bin/make/dir.c        Sat Aug 22 11:35:00 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dir.c,v 1.99 2020/08/22 09:40:18 rillig Exp $  */
+/*     $NetBSD: dir.c,v 1.100 2020/08/22 11:35:00 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: dir.c,v 1.99 2020/08/22 09:40:18 rillig Exp $";
+static char rcsid[] = "$NetBSD: dir.c,v 1.100 2020/08/22 11:35:00 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)dir.c      8.2 (Berkeley) 1/2/94";
 #else
-__RCSID("$NetBSD: dir.c,v 1.99 2020/08/22 09:40:18 rillig Exp $");
+__RCSID("$NetBSD: dir.c,v 1.100 2020/08/22 11:35:00 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -641,9 +641,9 @@
            ((entry->name[0] != '.') ||
             (pattern[0] == '.')))
        {
-           (void)Lst_AtEnd(expansions,
-                           (isDot ? bmake_strdup(entry->name) :
-                            str_concat3(p->name, "/", entry->name)));
+           Lst_AppendS(expansions,
+                       (isDot ? bmake_strdup(entry->name) :
+                        str_concat3(p->name, "/", entry->name)));
        }
     }
 }
@@ -1582,7 +1582,7 @@
        p = (Path *)Lst_Datum(ln);
        if (path && Lst_Member(path, p) == NULL) {
            p->refCount += 1;
-           (void)Lst_AtEnd(path, p);
+           Lst_AppendS(path, p);
        }
     } else {
        DIR_DEBUG1("Caching %s ...", name);
@@ -1608,9 +1608,9 @@
                (void)Hash_CreateEntry(&p->files, dp->d_name, NULL);
            }
            (void)closedir(d);
-           (void)Lst_AtEnd(openDirectories, p);
+           Lst_AppendS(openDirectories, p);
            if (path != NULL)
-               (void)Lst_AtEnd(path, p);
+               Lst_AppendS(path, p);
        }
        DIR_DEBUG0("done\n");
     }
@@ -1773,7 +1773,7 @@
        p = (Path *)Lst_Datum(ln);
        if (Lst_Member(path1, p) == NULL) {
            p->refCount += 1;
-           (void)Lst_AtEnd(path1, p);
+           Lst_AppendS(path1, p);
        }
     }
 }
diff -r ebb6f43776d7 -r fd0d2e46b730 usr.bin/make/job.c
--- a/usr.bin/make/job.c        Sat Aug 22 11:27:02 2020 +0000
+++ b/usr.bin/make/job.c        Sat Aug 22 11:35:00 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: job.c,v 1.209 2020/08/22 09:51:57 rillig Exp $ */
+/*     $NetBSD: job.c,v 1.210 2020/08/22 11:35:00 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: job.c,v 1.209 2020/08/22 09:51:57 rillig Exp $";
+static char rcsid[] = "$NetBSD: job.c,v 1.210 2020/08/22 11:35:00 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)job.c      8.2 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: job.c,v 1.209 2020/08/22 09:51:57 rillig Exp $");
+__RCSID("$NetBSD: job.c,v 1.210 2020/08/22 11:35:00 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -918,7 +918,7 @@
 JobSaveCommand(void *cmd, void *gn)
 {
     cmd = Var_Subst((char *)cmd, (GNode *)gn, VARE_WANTRES);
-    (void)Lst_AtEnd(postCommands->commands, cmd);
+    Lst_AppendS(postCommands->commands, cmd);
     return 0;
 }
 
diff -r ebb6f43776d7 -r fd0d2e46b730 usr.bin/make/main.c
--- a/usr.bin/make/main.c       Sat Aug 22 11:27:02 2020 +0000
+++ b/usr.bin/make/main.c       Sat Aug 22 11:35:00 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.306 2020/08/22 00:48:02 rillig Exp $        */
+/*     $NetBSD: main.c,v 1.307 2020/08/22 11:35:00 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.306 2020/08/22 00:48:02 rillig Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.307 2020/08/22 11:35:00 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.306 2020/08/22 00:48:02 rillig Exp $");
+__RCSID("$NetBSD: main.c,v 1.307 2020/08/22 11:35:00 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -543,7 +543,7 @@
                case 'v':
                        if (argvalue == NULL) goto noarg;
                        printVars = c == 'v' ? EXPAND_VARS : COMPAT_VARS;
-                       (void)Lst_AtEnd(variables, argvalue);
+                       Lst_AppendS(variables, argvalue);
                        Var_Append(MAKEFLAGS, "-V", VAR_GLOBAL);
                        Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL);
                        break;
@@ -571,7 +571,7 @@
                        break;
                case 'f':
                        if (argvalue == NULL) goto noarg;
-                       (void)Lst_AtEnd(makefiles, argvalue);
+                       Lst_AppendS(makefiles, argvalue);
                        break;
                case 'i':
                        ignoreErrors = TRUE;
@@ -660,7 +660,7 @@
                                Punt("illegal (null) argument.");
                        if (*argv[1] == '-' && !dashDash)
                                goto rearg;
-                       (void)Lst_AtEnd(create, bmake_strdup(argv[1]));
+                       Lst_AppendS(create, bmake_strdup(argv[1]));
                }
 
        return;
@@ -810,7 +810,7 @@
        sep = " \t";
 
     for (n = 0, cp = strtok(str, sep); cp; cp = strtok(NULL, sep)) {
-       (void)Lst_AtEnd(lp, cp);
+       Lst_AppendS(lp, cp);
        n++;
     }
     return n;
diff -r ebb6f43776d7 -r fd0d2e46b730 usr.bin/make/make.c
--- a/usr.bin/make/make.c       Sat Aug 22 11:27:02 2020 +0000
+++ b/usr.bin/make/make.c       Sat Aug 22 11:35:00 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: make.c,v 1.109 2020/08/22 08:40:03 rillig Exp $        */
+/*     $NetBSD: make.c,v 1.110 2020/08/22 11:35:00 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: make.c,v 1.109 2020/08/22 08:40:03 rillig Exp $";
+static char rcsid[] = "$NetBSD: make.c,v 1.110 2020/08/22 11:35:00 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)make.c     8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: make.c,v 1.109 2020/08/22 08:40:03 rillig Exp $");
+__RCSID("$NetBSD: make.c,v 1.110 2020/08/22 11:35:00 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -479,8 +479,8 @@
                    gn = tgn;
            }
 
-           (void)Lst_AtEnd(pgn->children, gn);
-           (void)Lst_AtEnd(gn->parents, pgn);
+           Lst_AppendS(pgn->children, gn);
+           Lst_AppendS(gn->parents, pgn);
            pgn->unmade += 1;
        }



Home | Main Index | Thread Index | Old Index