Sun Nov 22 11:11:43 2020 UTC ()
make(1): fix type of local variable in FindDepsRegular

The compiler cannot check these since all lists and list nodes are
aliases to each other.

Maybe it's time to add type-generic lists to the code, to delegate these
checks to the compiler.


(rillig)
diff -r1.289 -r1.290 src/usr.bin/make/suff.c

cvs diff -r1.289 -r1.290 src/usr.bin/make/suff.c (expand / switch to unified diff)

--- src/usr.bin/make/suff.c 2020/11/22 10:27:56 1.289
+++ src/usr.bin/make/suff.c 2020/11/22 11:11:43 1.290
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: suff.c,v 1.289 2020/11/22 10:27:56 rillig Exp $ */ 1/* $NetBSD: suff.c,v 1.290 2020/11/22 11:11:43 rillig Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1988, 1989, 1990, 1993 4 * Copyright (c) 1988, 1989, 1990, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * Adam de Boor. 8 * Adam de Boor.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -104,27 +104,27 @@ @@ -104,27 +104,27 @@
104 * Suff_FindDeps Find implicit sources for and the location of 104 * Suff_FindDeps Find implicit sources for and the location of
105 * a target based on its suffix. Returns the 105 * a target based on its suffix. Returns the
106 * bottom-most node added to the graph or NULL 106 * bottom-most node added to the graph or NULL
107 * if the target had no implicit sources. 107 * if the target had no implicit sources.
108 * 108 *
109 * Suff_FindPath Return the appropriate path to search in order to 109 * Suff_FindPath Return the appropriate path to search in order to
110 * find the node. 110 * find the node.
111 */ 111 */
112 112
113#include "make.h" 113#include "make.h"
114#include "dir.h" 114#include "dir.h"
115 115
116/* "@(#)suff.c 8.4 (Berkeley) 3/21/94" */ 116/* "@(#)suff.c 8.4 (Berkeley) 3/21/94" */
117MAKE_RCSID("$NetBSD: suff.c,v 1.289 2020/11/22 10:27:56 rillig Exp $"); 117MAKE_RCSID("$NetBSD: suff.c,v 1.290 2020/11/22 11:11:43 rillig Exp $");
118 118
119#define SUFF_DEBUG0(text) DEBUG0(SUFF, text) 119#define SUFF_DEBUG0(text) DEBUG0(SUFF, text)
120#define SUFF_DEBUG1(fmt, arg1) DEBUG1(SUFF, fmt, arg1) 120#define SUFF_DEBUG1(fmt, arg1) DEBUG1(SUFF, fmt, arg1)
121#define SUFF_DEBUG2(fmt, arg1, arg2) DEBUG2(SUFF, fmt, arg1, arg2) 121#define SUFF_DEBUG2(fmt, arg1, arg2) DEBUG2(SUFF, fmt, arg1, arg2)
122 122
123typedef List SuffixList; 123typedef List SuffixList;
124typedef ListNode SuffixListNode; 124typedef ListNode SuffixListNode;
125 125
126typedef List CandidateList; 126typedef List CandidateList;
127typedef ListNode CandidateListNode; 127typedef ListNode CandidateListNode;
128 128
129static SuffixList *sufflist; /* List of suffixes */ 129static SuffixList *sufflist; /* List of suffixes */
130#ifdef CLEANUP 130#ifdef CLEANUP
@@ -1738,27 +1738,27 @@ FindDepsRegular(GNode *gn, CandidateList @@ -1738,27 +1738,27 @@ FindDepsRegular(GNode *gn, CandidateList
1738 } 1738 }
1739 } 1739 }
1740 1740
1741 Var_Set(TARGET, GNode_Path(gn), gn); 1741 Var_Set(TARGET, GNode_Path(gn), gn);
1742 1742
1743 pref = targ != NULL ? targ->pref : gn->name; 1743 pref = targ != NULL ? targ->pref : gn->name;
1744 Var_Set(PREFIX, pref, gn); 1744 Var_Set(PREFIX, pref, gn);
1745 1745
1746 /* 1746 /*
1747 * Now we've got the important local variables set, expand any sources 1747 * Now we've got the important local variables set, expand any sources
1748 * that still contain variables or wildcards in their names. 1748 * that still contain variables or wildcards in their names.
1749 */ 1749 */
1750 { 1750 {
1751 SuffixListNode *ln, *nln; 1751 GNodeListNode *ln, *nln;
1752 for (ln = gn->children->first; ln != NULL; ln = nln) { 1752 for (ln = gn->children->first; ln != NULL; ln = nln) {
1753 nln = ln->next; 1753 nln = ln->next;
1754 ExpandChildren(ln, gn); 1754 ExpandChildren(ln, gn);
1755 } 1755 }
1756 } 1756 }
1757 1757
1758 if (targ == NULL) { 1758 if (targ == NULL) {
1759 SUFF_DEBUG1("\tNo valid suffix on %s\n", gn->name); 1759 SUFF_DEBUG1("\tNo valid suffix on %s\n", gn->name);
1760 1760
1761sfnd_abort: 1761sfnd_abort:
1762 FindDepsRegularPath(gn, targ); 1762 FindDepsRegularPath(gn, targ);
1763 goto sfnd_return; 1763 goto sfnd_return;
1764 } 1764 }