Sun Aug 23 18:53:13 2020 UTC ()
make(1): make Arch_MemMTime ready for WARNS=6


(rillig)
diff -r1.93 -r1.94 src/usr.bin/make/arch.c

cvs diff -r1.93 -r1.94 src/usr.bin/make/arch.c (expand / switch to unified diff)

--- src/usr.bin/make/arch.c 2020/08/23 17:49:37 1.93
+++ src/usr.bin/make/arch.c 2020/08/23 18:53:13 1.94
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: arch.c,v 1.93 2020/08/23 17:49:37 rillig Exp $ */ 1/* $NetBSD: arch.c,v 1.94 2020/08/23 18:53:13 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.
@@ -59,34 +59,34 @@ @@ -59,34 +59,34 @@
59 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 59 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
60 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 60 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
61 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 61 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
62 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 62 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
63 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 63 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
64 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 64 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 65 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
66 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 66 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
67 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 67 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
68 * SUCH DAMAGE. 68 * SUCH DAMAGE.
69 */ 69 */
70 70
71#ifndef MAKE_NATIVE 71#ifndef MAKE_NATIVE
72static char rcsid[] = "$NetBSD: arch.c,v 1.93 2020/08/23 17:49:37 rillig Exp $"; 72static char rcsid[] = "$NetBSD: arch.c,v 1.94 2020/08/23 18:53:13 rillig Exp $";
73#else 73#else
74#include <sys/cdefs.h> 74#include <sys/cdefs.h>
75#ifndef lint 75#ifndef lint
76#if 0 76#if 0
77static char sccsid[] = "@(#)arch.c 8.2 (Berkeley) 1/2/94"; 77static char sccsid[] = "@(#)arch.c 8.2 (Berkeley) 1/2/94";
78#else 78#else
79__RCSID("$NetBSD: arch.c,v 1.93 2020/08/23 17:49:37 rillig Exp $"); 79__RCSID("$NetBSD: arch.c,v 1.94 2020/08/23 18:53:13 rillig Exp $");
80#endif 80#endif
81#endif /* not lint */ 81#endif /* not lint */
82#endif 82#endif
83 83
84/*- 84/*-
85 * arch.c -- 85 * arch.c --
86 * Functions to manipulate libraries, archives and their members. 86 * Functions to manipulate libraries, archives and their members.
87 * 87 *
88 * Once again, cacheing/hashing comes into play in the manipulation 88 * Once again, cacheing/hashing comes into play in the manipulation
89 * of archives. The first time an archive is referenced, all of its members' 89 * of archives. The first time an archive is referenced, all of its members'
90 * headers are read and hashed and the archive closed again. All hashed 90 * headers are read and hashed and the archive closed again. All hashed
91 * archives are kept on a list which is searched each time an archive member 91 * archives are kept on a list which is searched each time an archive member
92 * is referenced. 92 * is referenced.
@@ -1116,47 +1116,46 @@ Arch_MTime(GNode *gn) @@ -1116,47 +1116,46 @@ Arch_MTime(GNode *gn)
1116 * Results: 1116 * Results:
1117 * The modification time. 1117 * The modification time.
1118 * 1118 *
1119 * Side Effects: 1119 * Side Effects:
1120 * The mtime field is filled in. 1120 * The mtime field is filled in.
1121 * 1121 *
1122 *----------------------------------------------------------------------- 1122 *-----------------------------------------------------------------------
1123 */ 1123 */
1124time_t 1124time_t
1125Arch_MemMTime(GNode *gn) 1125Arch_MemMTime(GNode *gn)
1126{ 1126{
1127 LstNode ln; 1127 LstNode ln;
1128 GNode *pgn; 1128 GNode *pgn;
1129 char *nameStart, 
1130 *nameEnd; 
1131 1129
1132 Lst_OpenS(gn->parents); 1130 Lst_OpenS(gn->parents);
1133 while ((ln = Lst_NextS(gn->parents)) != NULL) { 1131 while ((ln = Lst_NextS(gn->parents)) != NULL) {
1134 pgn = Lst_DatumS(ln); 1132 pgn = Lst_DatumS(ln);
1135 1133
1136 if (pgn->type & OP_ARCHV) { 1134 if (pgn->type & OP_ARCHV) {
1137 /* 1135 /*
1138 * If the parent is an archive specification and is being made 1136 * If the parent is an archive specification and is being made
1139 * and its member's name matches the name of the node we were 1137 * and its member's name matches the name of the node we were
1140 * given, record the modification time of the parent in the 1138 * given, record the modification time of the parent in the
1141 * child. We keep searching its parents in case some other 1139 * child. We keep searching its parents in case some other
1142 * parent requires this child to exist... 1140 * parent requires this child to exist...
1143 */ 1141 */
1144 nameStart = strchr(pgn->name, '(') + 1; 1142 const char *nameStart = strchr(pgn->name, '(') + 1;
1145 nameEnd = strchr(nameStart, ')'); 1143 const char *nameEnd = strchr(nameStart, ')');
 1144 size_t nameLen = (size_t)(nameEnd - nameStart);
1146 1145
1147 if ((pgn->flags & REMAKE) && 1146 if ((pgn->flags & REMAKE) &&
1148 strncmp(nameStart, gn->name, nameEnd - nameStart) == 0) { 1147 strncmp(nameStart, gn->name, nameLen) == 0) {
1149 gn->mtime = Arch_MTime(pgn); 1148 gn->mtime = Arch_MTime(pgn);
1150 } 1149 }
1151 } else if (pgn->flags & REMAKE) { 1150 } else if (pgn->flags & REMAKE) {
1152 /* 1151 /*
1153 * Something which isn't a library depends on the existence of 1152 * Something which isn't a library depends on the existence of
1154 * this target, so it needs to exist. 1153 * this target, so it needs to exist.
1155 */ 1154 */
1156 gn->mtime = 0; 1155 gn->mtime = 0;
1157 break; 1156 break;
1158 } 1157 }
1159 } 1158 }
1160 1159
1161 Lst_CloseS(gn->parents); 1160 Lst_CloseS(gn->parents);
1162 1161