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_Datum with non-null guaran...



details:   https://anonhg.NetBSD.org/src/rev/359f52fdd6a8
branches:  trunk
changeset: 942938:359f52fdd6a8
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Aug 22 15:17:09 2020 +0000

description:
make(1): replace Lst_Datum with non-null guaranteeing Lst_DatumS

diffstat:

 usr.bin/make/arch.c  |  10 ++++----
 usr.bin/make/dir.c   |  33 ++++++++++++++---------------
 usr.bin/make/lst.c   |  17 ++++++---------
 usr.bin/make/lst.h   |   4 +-
 usr.bin/make/main.c  |  18 +++++++---------
 usr.bin/make/make.c  |  14 ++++++------
 usr.bin/make/meta.c  |   8 +++---
 usr.bin/make/parse.c |  14 ++++++------
 usr.bin/make/suff.c  |  56 ++++++++++++++++++++++++++--------------------------
 usr.bin/make/targ.c  |   8 +++---
 10 files changed, 88 insertions(+), 94 deletions(-)

diffs (truncated from 740 to 300 lines):

diff -r 2ed291a78ca2 -r 359f52fdd6a8 usr.bin/make/arch.c
--- a/usr.bin/make/arch.c       Sat Aug 22 14:56:45 2020 +0000
+++ b/usr.bin/make/arch.c       Sat Aug 22 15:17:09 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: arch.c,v 1.88 2020/08/22 14:39:12 rillig Exp $ */
+/*     $NetBSD: arch.c,v 1.89 2020/08/22 15:17:09 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: arch.c,v 1.88 2020/08/22 14:39:12 rillig Exp $";
+static char rcsid[] = "$NetBSD: arch.c,v 1.89 2020/08/22 15:17:09 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.88 2020/08/22 14:39:12 rillig Exp $");
+__RCSID("$NetBSD: arch.c,v 1.89 2020/08/22 15:17:09 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -544,7 +544,7 @@
 
     ln = Lst_Find(archives, archive, ArchFindArchive);
     if (ln != NULL) {
-       ar = (Arch *)Lst_Datum(ln);
+       ar = Lst_DatumS(ln);
 
        he = Hash_FindEntry(&ar->members, member);
 
@@ -1130,7 +1130,7 @@
        return 0;
     }
     while ((ln = Lst_NextS(gn->parents)) != NULL) {
-       pgn = (GNode *)Lst_Datum(ln);
+       pgn = Lst_DatumS(ln);
 
        if (pgn->type & OP_ARCHV) {
            /*
diff -r 2ed291a78ca2 -r 359f52fdd6a8 usr.bin/make/dir.c
--- a/usr.bin/make/dir.c        Sat Aug 22 14:56:45 2020 +0000
+++ b/usr.bin/make/dir.c        Sat Aug 22 15:17:09 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dir.c,v 1.102 2020/08/22 14:39:12 rillig Exp $ */
+/*     $NetBSD: dir.c,v 1.103 2020/08/22 15:17:09 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.102 2020/08/22 14:39:12 rillig Exp $";
+static char rcsid[] = "$NetBSD: dir.c,v 1.103 2020/08/22 15:17:09 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.102 2020/08/22 14:39:12 rillig Exp $");
+__RCSID("$NetBSD: dir.c,v 1.103 2020/08/22 15:17:09 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -484,7 +484,7 @@
 
     if (Lst_Open(dirSearchPath) == SUCCESS) {
        if ((ln = Lst_First(dirSearchPath)) != NULL) {
-           p = (Path *)Lst_Datum(ln);
+           p = Lst_DatumS(ln);
            if (p == dotLast) {
                hasLastDot = TRUE;
                Var_Append(".PATH", dotLast->name, VAR_GLOBAL);
@@ -499,7 +499,7 @@
        }
 
        while ((ln = Lst_NextS(dirSearchPath)) != NULL) {
-           p = (Path *)Lst_Datum(ln);
+           p = Lst_DatumS(ln);
            if (p == dotLast)
                continue;
            if (p == dot && hasLastDot)
@@ -795,11 +795,10 @@
 DirExpandInt(const char *word, Lst path, Lst expansions)
 {
     LstNode ln;                        /* Current node */
-    Path *p;                   /* Directory in the node */
 
     if (Lst_Open(path) == SUCCESS) {
        while ((ln = Lst_NextS(path)) != NULL) {
-           p = (Path *)Lst_Datum(ln);
+           Path *p = Lst_DatumS(ln);
            DirMatchFiles(word, p, expansions);
        }
        Lst_CloseS(path);
@@ -1137,7 +1136,7 @@
     }
 
     if ((ln = Lst_First(path)) != NULL) {
-       p = (Path *)Lst_Datum(ln);
+       p = Lst_DatumS(ln);
        if (p == dotLast) {
            hasLastDot = TRUE;
            DIR_DEBUG0("[dot last]...");
@@ -1171,7 +1170,7 @@
        }
 
        while ((ln = Lst_NextS(path)) != NULL) {
-           p = (Path *)Lst_Datum(ln);
+           p = Lst_DatumS(ln);
            if (p == dotLast)
                continue;
            if ((file = DirLookup(p, name, cp, hasSlash)) != NULL) {
@@ -1229,7 +1228,7 @@
 
        Lst_OpenS(path);
        while ((ln = Lst_NextS(path)) != NULL) {
-           p = (Path *)Lst_Datum(ln);
+           p = Lst_DatumS(ln);
            if (p == dotLast)
                continue;
            if (p == dot) {
@@ -1287,7 +1286,7 @@
 
        Lst_OpenS(path);
        while ((ln = Lst_NextS(path)) != NULL) {
-           p = (Path *)Lst_Datum(ln);
+           p = Lst_DatumS(ln);
            if (p == dotLast)
                continue;
            if ((file = DirLookupAbs(p, name, cp)) != NULL) {
@@ -1342,7 +1341,7 @@
     if (ln == NULL) {
        return NULL;
     } else {
-       p = (Path *)Lst_Datum(ln);
+       p = Lst_DatumS(ln);
     }
 
     if (Hash_FindEntry(&p->files, cp) != NULL) {
@@ -1564,7 +1563,7 @@
     if (strcmp(name, ".DOTLAST") == 0) {
        ln = Lst_Find(path, name, DirFindName);
        if (ln != NULL)
-           return (Path *)Lst_Datum(ln);
+           return Lst_DatumS(ln);
        else {
            dotLast->refCount += 1;
            (void)Lst_AtFront(path, dotLast);
@@ -1574,7 +1573,7 @@
     if (path)
        ln = Lst_Find(openDirectories, name, DirFindName);
     if (ln != NULL) {
-       p = (Path *)Lst_Datum(ln);
+       p = Lst_DatumS(ln);
        if (path && Lst_Member(path, p) == NULL) {
            p->refCount += 1;
            Lst_AppendS(path, p);
@@ -1665,7 +1664,7 @@
 
     if (Lst_Open(path) == SUCCESS) {
        while ((ln = Lst_NextS(path)) != NULL) {
-           Path *p = (Path *)Lst_Datum(ln);
+           Path *p = Lst_DatumS(ln);
            Buf_AddStr(&buf, " ");
            Buf_AddStr(&buf, flag);
            Buf_AddStr(&buf, p->name);
@@ -1764,7 +1763,7 @@
     Path *p;
 
     for (ln = Lst_First(path2); ln != NULL; ln = Lst_Succ(ln)) {
-       p = (Path *)Lst_Datum(ln);
+       p = Lst_DatumS(ln);
        if (Lst_Member(path1, p) == NULL) {
            p->refCount += 1;
            Lst_AppendS(path1, p);
@@ -1788,7 +1787,7 @@
     fprintf(debug_file, "# %-20s referenced\thits\n", "directory");
     if (Lst_Open(openDirectories) == SUCCESS) {
        while ((ln = Lst_NextS(openDirectories)) != NULL) {
-           p = (Path *)Lst_Datum(ln);
+           p = Lst_DatumS(ln);
            fprintf(debug_file, "# %-20s %10d\t%4d\n", p->name, p->refCount,
                    p->hits);
        }
diff -r 2ed291a78ca2 -r 359f52fdd6a8 usr.bin/make/lst.c
--- a/usr.bin/make/lst.c        Sat Aug 22 14:56:45 2020 +0000
+++ b/usr.bin/make/lst.c        Sat Aug 22 15:17:09 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lst.c,v 1.27 2020/08/22 14:56:45 rillig Exp $ */
+/* $NetBSD: lst.c,v 1.28 2020/08/22 15:17:09 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.27 2020/08/22 14:56:45 rillig Exp $";
+static char rcsid[] = "$NetBSD: lst.c,v 1.28 2020/08/22 15:17:09 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: lst.c,v 1.27 2020/08/22 14:56:45 rillig Exp $");
+__RCSID("$NetBSD: lst.c,v 1.28 2020/08/22 15:17:09 rillig Exp $");
 #endif /* not lint */
 #endif
 
@@ -465,15 +465,12 @@
     }
 }
 
-/* Return the datum stored in the given node, or NULL if the node is invalid. */
+/* Return the datum stored in the given node. */
 void *
-Lst_Datum(LstNode node)
+Lst_DatumS(LstNode node)
 {
-    if (node != NULL) {
-       return node->datum;
-    } else {
-       return NULL;
-    }
+    assert(LstNodeIsValid(node));
+    return node->datum;
 }
 
 
diff -r 2ed291a78ca2 -r 359f52fdd6a8 usr.bin/make/lst.h
--- a/usr.bin/make/lst.h        Sat Aug 22 14:56:45 2020 +0000
+++ b/usr.bin/make/lst.h        Sat Aug 22 15:17:09 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lst.h,v 1.33 2020/08/22 14:56:45 rillig Exp $  */
+/*     $NetBSD: lst.h,v 1.34 2020/08/22 15:17:09 rillig Exp $  */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -141,7 +141,7 @@
 /* Return predecessor to given element */
 LstNode                Lst_Prev(LstNode);
 /* Get datum from LstNode */
-void           *Lst_Datum(LstNode);
+void           *Lst_DatumS(LstNode);
 
 /*
  * Functions for entire lists
diff -r 2ed291a78ca2 -r 359f52fdd6a8 usr.bin/make/main.c
--- a/usr.bin/make/main.c       Sat Aug 22 14:56:45 2020 +0000
+++ b/usr.bin/make/main.c       Sat Aug 22 15:17:09 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.307 2020/08/22 11:35:00 rillig Exp $        */
+/*     $NetBSD: main.c,v 1.308 2020/08/22 15:17:09 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.307 2020/08/22 11:35:00 rillig Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.308 2020/08/22 15:17:09 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.307 2020/08/22 11:35:00 rillig Exp $");
+__RCSID("$NetBSD: main.c,v 1.308 2020/08/22 15:17:09 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -873,7 +873,7 @@
 
        for (ln = Lst_First(variables); ln != NULL;
            ln = Lst_Succ(ln)) {
-               char *var = (char *)Lst_Datum(ln);
+               char *var = Lst_DatumS(ln);
                const char *value;
                char *p1;
 
@@ -1281,10 +1281,8 @@
        if (!Lst_IsEmpty(create)) {
                LstNode ln;
 
-               for (ln = Lst_First(create); ln != NULL;
-                   ln = Lst_Succ(ln)) {
-                       char *name = (char *)Lst_Datum(ln);
-
+               for (ln = Lst_First(create); ln != NULL; ln = Lst_Succ(ln)) {
+                       char *name = Lst_DatumS(ln);
                        Var_Append(".TARGETS", name, VAR_GLOBAL);
                }



Home | Main Index | Thread Index | Old Index