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): change return type of Dir_MTime to void
details: https://anonhg.NetBSD.org/src/rev/0845f7e2b8ca
branches: trunk
changeset: 956827:0845f7e2b8ca
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Nov 08 09:34:55 2020 +0000
description:
make(1): change return type of Dir_MTime to void
Only some callers actually needed the updated time, and because of the
many branches, it was difficult to see that the return value was indeed
gn->mtime all the time.
diffstat:
usr.bin/make/dir.c | 51 ++++++++++++++++++++-------------------------------
usr.bin/make/dir.h | 4 ++--
usr.bin/make/job.c | 7 ++++---
usr.bin/make/make.c | 17 ++++++++++-------
4 files changed, 36 insertions(+), 43 deletions(-)
diffs (221 lines):
diff -r 03d72cc0e320 -r 0845f7e2b8ca usr.bin/make/dir.c
--- a/usr.bin/make/dir.c Sun Nov 08 09:15:19 2020 +0000
+++ b/usr.bin/make/dir.c Sun Nov 08 09:34:55 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dir.c,v 1.200 2020/11/08 09:15:19 rillig Exp $ */
+/* $NetBSD: dir.c,v 1.201 2020/11/08 09:34:55 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -100,9 +100,9 @@
* then all the directories above it in turn until
* the path is found or we reach the root ("/").
*
- * Dir_MTime Return the modification time of a node. The file
- * is searched for along the default search path.
- * The path and mtime fields of the node are filled in.
+ * Dir_UpdateMTime
+ * Update the modification time and path of a node with
+ * data from the file corresponding to the node.
*
* Dir_AddDir Add a directory to a search path.
*
@@ -134,7 +134,7 @@
#include "job.h"
/* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */
-MAKE_RCSID("$NetBSD: dir.c,v 1.200 2020/11/08 09:15:19 rillig Exp $");
+MAKE_RCSID("$NetBSD: dir.c,v 1.201 2020/11/08 09:34:55 rillig Exp $");
#define DIR_DEBUG0(text) DEBUG0(DIR, text)
#define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1)
@@ -204,7 +204,7 @@
* Given that an access() is essentially a stat() without the copyout() call,
* and that the same filesystem overhead would have to be incurred in
* Dir_MTime, it made sense to replace the access() with a stat() and record
- * the mtime in a cache for when Dir_MTime was actually called.
+ * the mtime in a cache for when Dir_UpdateMTime was actually called.
*/
typedef List CachedDirList;
@@ -1276,26 +1276,12 @@
return NULL;
}
-/*-
- *-----------------------------------------------------------------------
- * Dir_MTime --
- * Find the modification time of the file described by gn along the
- * search path dirSearchPath.
- *
- * Input:
- * gn the file whose modification time is desired
+/* Search gn along dirSearchPath and store its modification time in gn->mtime.
+ * If no file is found, store 0 instead.
*
- * Results:
- * The modification time or 0 if it doesn't exist
- *
- * Side Effects:
- * The modification time is placed in the node's mtime slot.
- * If the node didn't have a path entry before, and Dir_FindFile
- * found one for it, the full name is placed in the path slot.
- *-----------------------------------------------------------------------
- */
-time_t
-Dir_MTime(GNode *gn, Boolean recheck)
+ * The found file is stored in gn->path, unless the node already had a path. */
+void
+Dir_UpdateMTime(GNode *gn, Boolean recheck)
{
char *fullName; /* the full pathname of name */
struct make_stat mst; /* buffer for finding the mod time */
@@ -1303,11 +1289,15 @@
if (gn->type & OP_ARCHV) {
Arch_UpdateMTime(gn);
- return gn->mtime;
- } else if (gn->type & OP_PHONY) {
+ return;
+ }
+
+ if (gn->type & OP_PHONY) {
gn->mtime = 0;
- return 0;
- } else if (gn->path == NULL) {
+ return;
+ }
+
+ if (gn->path == NULL) {
if (gn->type & OP_NOPATH)
fullName = NULL;
else {
@@ -1356,7 +1346,7 @@
if (fullName != gn->path)
free(fullName);
Arch_UpdateMemberMTime(gn);
- return gn->mtime;
+ return;
}
mst.mst_mtime = 0;
@@ -1366,7 +1356,6 @@
gn->path = fullName;
gn->mtime = mst.mst_mtime;
- return gn->mtime;
}
/* Read the list of filenames in the directory and store the result
diff -r 03d72cc0e320 -r 0845f7e2b8ca usr.bin/make/dir.h
--- a/usr.bin/make/dir.h Sun Nov 08 09:15:19 2020 +0000
+++ b/usr.bin/make/dir.h Sun Nov 08 09:34:55 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dir.h,v 1.32 2020/10/25 10:00:20 rillig Exp $ */
+/* $NetBSD: dir.h,v 1.33 2020/11/08 09:34:55 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -101,7 +101,7 @@
void Dir_Expand(const char *, SearchPath *, StringList *);
char *Dir_FindFile(const char *, SearchPath *);
char *Dir_FindHereOrAbove(const char *, const char *);
-time_t Dir_MTime(GNode *, Boolean);
+void Dir_UpdateMTime(GNode *, Boolean);
CachedDir *Dir_AddDir(SearchPath *, const char *);
char *Dir_MakeFlags(const char *, SearchPath *);
void Dir_ClearPath(SearchPath *);
diff -r 03d72cc0e320 -r 0845f7e2b8ca usr.bin/make/job.c
--- a/usr.bin/make/job.c Sun Nov 08 09:15:19 2020 +0000
+++ b/usr.bin/make/job.c Sun Nov 08 09:34:55 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: job.c,v 1.314 2020/11/08 01:16:04 rillig Exp $ */
+/* $NetBSD: job.c,v 1.315 2020/11/08 09:34:55 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -143,7 +143,7 @@
#include "trace.h"
/* "@(#)job.c 8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: job.c,v 1.314 2020/11/08 01:16:04 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.315 2020/11/08 09:34:55 rillig Exp $");
/* A shell defines how the commands are run. All commands for a target are
* written into a single file, which is then given to the shell to execute
@@ -1225,7 +1225,8 @@
return TRUE;
}
- if (Dir_MTime(gn, 0) != 0 || (gn->type & OP_SPECIAL))
+ Dir_UpdateMTime(gn, FALSE);
+ if (gn->mtime != 0 || (gn->type & OP_SPECIAL))
return TRUE;
/*
diff -r 03d72cc0e320 -r 0845f7e2b8ca usr.bin/make/make.c
--- a/usr.bin/make/make.c Sun Nov 08 09:15:19 2020 +0000
+++ b/usr.bin/make/make.c Sun Nov 08 09:34:55 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: make.c,v 1.193 2020/11/08 09:06:23 rillig Exp $ */
+/* $NetBSD: make.c,v 1.194 2020/11/08 09:34:55 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -108,7 +108,7 @@
#include "job.h"
/* "@(#)make.c 8.1 (Berkeley) 6/6/93" */
-MAKE_RCSID("$NetBSD: make.c,v 1.193 2020/11/08 09:06:23 rillig Exp $");
+MAKE_RCSID("$NetBSD: make.c,v 1.194 2020/11/08 09:34:55 rillig Exp $");
/* Sequence # to detect recursion. */
static unsigned int checked = 1;
@@ -213,7 +213,7 @@
* doesn't depend on their modification time...
*/
if (!(gn->type & (OP_JOIN|OP_USE|OP_USEBEFORE|OP_EXEC))) {
- (void)Dir_MTime(gn, 1);
+ Dir_UpdateMTime(gn, TRUE);
if (DEBUG(MAKE)) {
if (gn->mtime != 0)
debug_printf("modified %s...", Targ_FmtTime(gn->mtime));
@@ -366,7 +366,7 @@
GNode *gn = gnp;
GNode *pgn = pgnp;
- (void)Dir_MTime(gn, 0);
+ Dir_UpdateMTime(gn, FALSE);
GNode_UpdateYoungestChild(pgn, gn);
pgn->unmade--;
@@ -491,7 +491,10 @@
time_t
Make_Recheck(GNode *gn)
{
- time_t mtime = Dir_MTime(gn, 1);
+ time_t mtime;
+
+ Dir_UpdateMTime(gn, TRUE);
+ mtime = gn->mtime;
#ifndef RECHECK
/*
@@ -531,7 +534,7 @@
* using the same file from a common server), there are times
* when the modification time of a file created on a remote
* machine will not be modified before the local stat() implied by
- * the Dir_MTime occurs, thus leading us to believe that the file
+ * the Dir_UpdateMTime occurs, thus leading us to believe that the file
* is unchanged, wreaking havoc with files that depend on this one.
*
* I have decided it is better to make too much than to make too
@@ -1162,7 +1165,7 @@
*eon = ')';
}
- (void)Dir_MTime(gn, 0);
+ Dir_UpdateMTime(gn, FALSE);
Var_Set(TARGET, GNode_Path(gn), gn);
UnmarkChildren(gn);
HandleUseNodes(gn);
Home |
Main Index |
Thread Index |
Old Index