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): convert remaining Lst_AtEnd to the str...



details:   https://anonhg.NetBSD.org/src/rev/a1a739a960f2
branches:  trunk
changeset: 942929:a1a739a960f2
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Aug 22 13:28:20 2020 +0000

description:
make(1): convert remaining Lst_AtEnd to the stricter Lst_Append

The general-purpose list library that is included in make allows to call
Lst_AtEnd for invalid lists, silently ignoring this programming error.
This is a flexibility that make doesn't need.

Another unneeded "feature" is that list items can theoretically be null
pointers.  This doesn't make sense as well and is therefore not needed
by make.

These programming errors are now caught early by assertions.

diffstat:

 usr.bin/make/job.c   |   8 ++++----
 usr.bin/make/lst.c   |   8 +++++---
 usr.bin/make/lst.h   |   3 +--
 usr.bin/make/make.c  |  20 ++++++++++----------
 usr.bin/make/meta.c  |   6 +++---
 usr.bin/make/parse.c |   8 ++++----
 usr.bin/make/suff.c  |  20 ++++++++++----------
 usr.bin/make/targ.c  |  10 +++++-----
 8 files changed, 42 insertions(+), 41 deletions(-)

diffs (truncated from 349 to 300 lines):

diff -r afdfe1a14c5b -r a1a739a960f2 usr.bin/make/job.c
--- a/usr.bin/make/job.c        Sat Aug 22 13:06:39 2020 +0000
+++ b/usr.bin/make/job.c        Sat Aug 22 13:28:20 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: job.c,v 1.210 2020/08/22 11:35:00 rillig Exp $ */
+/*     $NetBSD: job.c,v 1.211 2020/08/22 13:28:20 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.210 2020/08/22 11:35:00 rillig Exp $";
+static char rcsid[] = "$NetBSD: job.c,v 1.211 2020/08/22 13:28:20 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.210 2020/08/22 11:35:00 rillig Exp $");
+__RCSID("$NetBSD: job.c,v 1.211 2020/08/22 13:28:20 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1972,7 +1972,7 @@
      * the nice side effect that it avoids a lot of other problems.
      */
     Lst lst = Lst_Init();
-    Lst_AtEnd(lst, targ);
+    Lst_AppendS(lst, targ);
     (void)Make_Run(lst);
     Lst_Destroy(lst, NULL);
     JobStart(targ, JOB_SPECIAL);
diff -r afdfe1a14c5b -r a1a739a960f2 usr.bin/make/lst.c
--- a/usr.bin/make/lst.c        Sat Aug 22 13:06:39 2020 +0000
+++ b/usr.bin/make/lst.c        Sat Aug 22 13:28:20 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lst.c,v 1.22 2020/08/22 13:06:39 rillig Exp $ */
+/* $NetBSD: lst.c,v 1.23 2020/08/22 13:28:20 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -37,11 +37,11 @@
 #include "make.h"
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: lst.c,v 1.22 2020/08/22 13:06:39 rillig Exp $";
+static char rcsid[] = "$NetBSD: lst.c,v 1.23 2020/08/22 13:28:20 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: lst.c,v 1.22 2020/08/22 13:06:39 rillig Exp $");
+__RCSID("$NetBSD: lst.c,v 1.23 2020/08/22 13:28:20 rillig Exp $");
 #endif /* not lint */
 #endif
 
@@ -71,6 +71,8 @@
     LstNode prev;              /* Previous node, if open. Used by Lst_Remove */
 };
 
+static ReturnStatus Lst_AtEnd(Lst, void *);
+
 static Boolean
 LstIsValid(Lst list)
 {
diff -r afdfe1a14c5b -r a1a739a960f2 usr.bin/make/lst.h
--- a/usr.bin/make/lst.h        Sat Aug 22 13:06:39 2020 +0000
+++ b/usr.bin/make/lst.h        Sat Aug 22 13:28:20 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lst.h,v 1.29 2020/08/22 13:06:39 rillig Exp $  */
+/*     $NetBSD: lst.h,v 1.30 2020/08/22 13:28:20 rillig Exp $  */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -121,7 +121,6 @@
 ReturnStatus   Lst_AtFront(Lst, void *);
 void           Lst_PrependS(Lst, void *);
 /* Place an element at the end of a lst. */
-ReturnStatus   Lst_AtEnd(Lst, void *);
 void           Lst_AppendS(Lst, void *);
 /* Remove an element */
 void           Lst_RemoveS(Lst, LstNode);
diff -r afdfe1a14c5b -r a1a739a960f2 usr.bin/make/make.c
--- a/usr.bin/make/make.c       Sat Aug 22 13:06:39 2020 +0000
+++ b/usr.bin/make/make.c       Sat Aug 22 13:28:20 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: make.c,v 1.112 2020/08/22 13:06:39 rillig Exp $        */
+/*     $NetBSD: make.c,v 1.113 2020/08/22 13:28:20 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: make.c,v 1.112 2020/08/22 13:06:39 rillig Exp $";
+static char rcsid[] = "$NetBSD: make.c,v 1.113 2020/08/22 13:28:20 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.112 2020/08/22 13:06:39 rillig Exp $");
+__RCSID("$NetBSD: make.c,v 1.113 2020/08/22 13:28:20 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1013,7 +1013,7 @@
 
     cn->made = REQUESTED;
     if (toBeMade_next == NULL)
-       Lst_AtEnd(toBeMade, cn);
+       Lst_AppendS(toBeMade, cn);
     else
        Lst_InsertBefore(toBeMade, toBeMade_next, cn);
 
@@ -1347,8 +1347,8 @@
     GNode *cn = cnp;
     GNode *pn = pnp;
 
-    Lst_AtEnd(pn->children, cn);
-    Lst_AtEnd(cn->parents, pn);
+    Lst_AppendS(pn->children, cn);
+    Lst_AppendS(cn->parents, pn);
     pn->unmade++;
     return 0;
 }
@@ -1370,9 +1370,9 @@
         fprintf(debug_file, ".WAIT: add dependency %s%s -> %s\n",
                cn->name, cn->cohort_num, wn->name);
 
-    Lst_AtEnd(wn->children, cn);
+    Lst_AppendS(wn->children, cn);
     wn->unmade++;
-    Lst_AtEnd(cn->parents, wn);
+    Lst_AppendS(cn->parents, wn);
     return 0;
 }
 
@@ -1403,7 +1403,7 @@
     MakeBuildChild(pgn, NULL);
 
     examine = Lst_Init();
-    Lst_AtEnd(examine, pgn);
+    Lst_AppendS(examine, pgn);
 
     while (!Lst_IsEmpty (examine)) {
        pgn = Lst_DeQueue(examine);
@@ -1432,7 +1432,7 @@
                Lst_ForEachFrom(pgn->children, owln, add_wait_dep, cgn);
                owln = ln;
            } else {
-               Lst_AtEnd(examine, cgn);
+               Lst_AppendS(examine, cgn);
            }
        }
        Lst_CloseS(pgn->children);
diff -r afdfe1a14c5b -r a1a739a960f2 usr.bin/make/meta.c
--- a/usr.bin/make/meta.c       Sat Aug 22 13:06:39 2020 +0000
+++ b/usr.bin/make/meta.c       Sat Aug 22 13:28:20 2020 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: meta.c,v 1.94 2020/08/21 03:36:03 rillig Exp $ */
+/*      $NetBSD: meta.c,v 1.95 2020/08/22 13:28:20 rillig Exp $ */
 
 /*
  * Implement 'meta' mode.
@@ -1410,7 +1410,7 @@
                        (link_src == NULL && cached_stat(p, &fs) < 0)) {
                        if (!meta_ignore(gn, p)) {
                            if (Lst_Find(missingFiles, p, string_match) == NULL)
-                               Lst_AtEnd(missingFiles, bmake_strdup(p));
+                               Lst_AppendS(missingFiles, bmake_strdup(p));
                        }
                    }
                    break;
@@ -1496,7 +1496,7 @@
                             * We cannot catch every eventuality here...
                             */
                            if (Lst_Find(missingFiles, p, string_match) == NULL)
-                                   Lst_AtEnd(missingFiles, bmake_strdup(p));
+                               Lst_AppendS(missingFiles, bmake_strdup(p));
                        }
                    }
                    if (buf[0] == 'E') {
diff -r afdfe1a14c5b -r a1a739a960f2 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Sat Aug 22 13:06:39 2020 +0000
+++ b/usr.bin/make/parse.c      Sat Aug 22 13:28:20 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parse.c,v 1.253 2020/08/22 11:35:00 rillig Exp $       */
+/*     $NetBSD: parse.c,v 1.254 2020/08/22 13:28:20 rillig Exp $       */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: parse.c,v 1.253 2020/08/22 11:35:00 rillig Exp $";
+static char rcsid[] = "$NetBSD: parse.c,v 1.254 2020/08/22 13:28:20 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.253 2020/08/22 11:35:00 rillig Exp $");
+__RCSID("$NetBSD: parse.c,v 1.254 2020/08/22 13:28:20 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -3135,7 +3135,7 @@
                        cp = bmake_strdup(cp);
                        Lst_ForEach(targets, ParseAddCmd, cp);
 #ifdef CLEANUP
-                       Lst_AtEnd(targCmds, cp);
+                       Lst_AppendS(targCmds, cp);
 #endif
                    }
                }
diff -r afdfe1a14c5b -r a1a739a960f2 usr.bin/make/suff.c
--- a/usr.bin/make/suff.c       Sat Aug 22 13:06:39 2020 +0000
+++ b/usr.bin/make/suff.c       Sat Aug 22 13:28:20 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: suff.c,v 1.102 2020/08/22 11:35:00 rillig Exp $        */
+/*     $NetBSD: suff.c,v 1.103 2020/08/22 13:28:20 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: suff.c,v 1.102 2020/08/22 11:35:00 rillig Exp $";
+static char rcsid[] = "$NetBSD: suff.c,v 1.103 2020/08/22 13:28:20 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.102 2020/08/22 11:35:00 rillig Exp $");
+__RCSID("$NetBSD: suff.c,v 1.103 2020/08/22 13:28:20 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1213,7 +1213,7 @@
        Lst_AppendS(ls->l, s2);
 #ifdef DEBUG_SRC
        s2->cp = Lst_Init();
-       Lst_AtEnd(targ->cp, s2);
+       Lst_AppendS(targ->cp, s2);
        fprintf(debug_file, "1 add %p %p to %p:", targ, s2, ls->l);
        Lst_ForEach(ls->l, PrintAddr, NULL);
        fprintf(debug_file, "\n");
@@ -1231,7 +1231,7 @@
     Lst_AppendS(ls->l, s2);
 #ifdef DEBUG_SRC
     s2->cp = Lst_Init();
-    Lst_AtEnd(targ->cp, s2);
+    Lst_AppendS(targ->cp, s2);
     fprintf(debug_file, "2 add %p %p to %p:", targ, s2, ls->l);
     Lst_ForEach(ls->l, PrintAddr, NULL);
     fprintf(debug_file, "\n");
@@ -1390,7 +1390,7 @@
        }
 
        SuffAddLevel(srcs, s);
-       Lst_AtEnd(slst, s);
+       Lst_AppendS(slst, s);
     }
 
     if (DEBUG(SUFF) && rs) {
@@ -1496,9 +1496,9 @@
 #ifdef DEBUG_SRC
     ret->cp = Lst_Init();
     fprintf(debug_file, "3 add %p %p\n", targ, ret);
-    Lst_AtEnd(targ->cp, ret);
+    Lst_AppendS(targ->cp, ret);
 #endif
-    Lst_AtEnd(slst, ret);
+    Lst_AppendS(slst, ret);
     if (DEBUG(SUFF)) {
        fprintf(debug_file, "\tusing existing source %s\n", s->name);
     }
@@ -2312,7 +2312,7 @@
             */
            while (bottom && bottom->parent != NULL) {
                if (Lst_Member(slst, bottom) == NULL) {
-                   Lst_AtEnd(slst, bottom);
+                   Lst_AppendS(slst, bottom);
                }
                bottom = bottom->parent;
            }
@@ -2388,7 +2388,7 @@
 sfnd_return:
     if (bottom)
        if (Lst_Member(slst, bottom) == NULL)



Home | Main Index | Thread Index | Old Index