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 Lst_Open with simple iteration...



details:   https://anonhg.NetBSD.org/src/rev/c1e218e0c10a
branches:  trunk
changeset: 956131:c1e218e0c10a
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Oct 22 17:20:35 2020 +0000

description:
make(1): replace Lst_Open with simple iteration in Make_Update

This iteration is safe from concurrent modification.

diffstat:

 usr.bin/make/make.c |  26 +++++++++++++-------------
 1 files changed, 13 insertions(+), 13 deletions(-)

diffs (78 lines):

diff -r c1b363a2fd24 -r c1e218e0c10a usr.bin/make/make.c
--- a/usr.bin/make/make.c       Thu Oct 22 09:28:30 2020 +0000
+++ b/usr.bin/make/make.c       Thu Oct 22 17:20:35 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: make.c,v 1.167 2020/10/22 05:50:02 rillig Exp $        */
+/*     $NetBSD: make.c,v 1.168 2020/10/22 17:20:35 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -107,7 +107,7 @@
 #include    "job.h"
 
 /*     "@(#)make.c     8.1 (Berkeley) 6/6/93"  */
-MAKE_RCSID("$NetBSD: make.c,v 1.167 2020/10/22 05:50:02 rillig Exp $");
+MAKE_RCSID("$NetBSD: make.c,v 1.168 2020/10/22 17:20:35 rillig Exp $");
 
 /* Sequence # to detect recursion. */
 static unsigned int checked = 1;
@@ -581,19 +581,20 @@
 void
 Make_Update(GNode *cgn)
 {
-    GNode *pgn;                        /* the parent node */
     const char *cname;         /* the child's name */
     GNodeListNode *ln;
     time_t     mtime = -1;
-    char       *p1;
     GNodeList *parents;
     GNode      *centurion;
 
     /* It is save to re-examine any nodes again */
     checked++;
 
-    cname = Var_Value(TARGET, cgn, &p1);
-    bmake_free(p1);
+    {
+        char *cname_freeIt;
+       cname = Var_Value(TARGET, cgn, &cname_freeIt);
+       assert(cname_freeIt == NULL);
+    }
 
     DEBUG2(MAKE, "Make_Update: %s%s\n", cgn->name, cgn->cohort_num);
 
@@ -627,7 +628,7 @@
     /* Now mark all the parents as having one less unmade child */
     Lst_Open(parents);
     while ((ln = Lst_Next(parents)) != NULL) {
-       pgn = ln->datum;
+       GNode *pgn = ln->datum;
        if (DEBUG(MAKE))
            debug_printf("inspect parent %s%s: flags %x, "
                         "type %x, made %d, unmade %d ",
@@ -718,20 +719,19 @@
      * Set the .PREFIX and .IMPSRC variables for all the implied parents
      * of this node.
      */
-    Lst_Open(cgn->implicitParents);
     {
-       const char *cpref = Var_Value(PREFIX, cgn, &p1);
+        char *cpref_freeIt;
+       const char *cpref = Var_Value(PREFIX, cgn, &cpref_freeIt);
 
-       while ((ln = Lst_Next(cgn->implicitParents)) != NULL) {
-           pgn = ln->datum;
+       for (ln = cgn->implicitParents->first; ln != NULL; ln = ln->next) {
+           GNode *pgn = ln->datum;
            if (pgn->flags & REMAKE) {
                Var_Set(IMPSRC, cname, pgn);
                if (cpref != NULL)
                    Var_Set(PREFIX, cpref, pgn);
            }
        }
-       bmake_free(p1);
-       Lst_Close(cgn->implicitParents);
+       bmake_free(cpref_freeIt);
     }
 }
 



Home | Main Index | Thread Index | Old Index