Module Name: src
Committed By: christos
Date: Thu Jul 12 18:03:31 UTC 2018
Modified Files:
src/usr.bin/make: dir.c
Log Message:
Fix previous: cached_stats() returning < 0 means that the file is not found,
not that it was found in the cache, and centralize reporting.
To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 src/usr.bin/make/dir.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/make/dir.c
diff -u src/usr.bin/make/dir.c:1.72 src/usr.bin/make/dir.c:1.73
--- src/usr.bin/make/dir.c:1.72 Thu Jul 12 13:46:37 2018
+++ src/usr.bin/make/dir.c Thu Jul 12 14:03:31 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: dir.c,v 1.72 2018/07/12 17:46:37 reinoud Exp $ */
+/* $NetBSD: dir.c,v 1.73 2018/07/12 18:03:31 christos 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.72 2018/07/12 17:46:37 reinoud Exp $";
+static char rcsid[] = "$NetBSD: dir.c,v 1.73 2018/07/12 18:03:31 christos 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.72 2018/07/12 17:46:37 reinoud Exp $");
+__RCSID("$NetBSD: dir.c,v 1.73 2018/07/12 18:03:31 christos Exp $");
#endif
#endif /* not lint */
#endif
@@ -289,6 +289,10 @@ cached_stats(Hash_Table *htp, const char
memset(st, 0, sizeof(*st));
st->st_mtime = cst->mtime;
st->st_mode = cst->mode;
+ if (DEBUG(DIR)) {
+ fprintf(debug_file, "Using cached time %s for %s\n",
+ Targ_FmtTime(st->st_mtime), pathname);
+ }
return 0;
}
@@ -306,6 +310,10 @@ cached_stats(Hash_Table *htp, const char
cst = entry->clientPtr;
cst->mtime = st->st_mtime;
cst->mode = st->st_mode;
+ if (DEBUG(DIR)) {
+ fprintf(debug_file, " Caching %s for %s\n",
+ Targ_FmtTime(st->st_mtime), pathname);
+ }
return 0;
}
@@ -986,14 +994,6 @@ DirLookupSubdir(Path *p, const char *nam
}
if (cached_stat(file, &stb) == 0) {
- /*
- * Save the modification time so if it's needed, we don't have
- * to fetch it again.
- */
- if (DEBUG(DIR)) {
- fprintf(debug_file, " Caching %s for %s\n", Targ_FmtTime(stb.st_mtime),
- file);
- }
nearmisses += 1;
return (file);
}
@@ -1386,17 +1386,13 @@ Dir_FindFile(const char *name, Lst path)
bigmisses += 1;
if (cached_stat(name, &stb) == 0) {
- if (DEBUG(DIR)) {
- fprintf(debug_file, " Caching %s for %s\n", Targ_FmtTime(stb.st_mtime),
- name);
- }
return (bmake_strdup(name));
- } else {
- if (DEBUG(DIR)) {
- fprintf(debug_file, " failed. Returning NULL\n");
- }
- return NULL;
}
+
+ if (DEBUG(DIR)) {
+ fprintf(debug_file, " failed. Returning NULL\n");
+ }
+ return NULL;
#endif /* notdef */
}
@@ -1553,10 +1549,6 @@ Dir_MTime(GNode *gn, Boolean recheck)
}
if (cached_stats(&mtimes, fullName, &stb, recheck ? CST_UPDATE : 0) < 0) {
- if (DEBUG(DIR)) {
- fprintf(debug_file, "Using cached time %s for %s\n",
- Targ_FmtTime(stb.st_mtime), fullName);
- }
if (gn->type & OP_MEMBER) {
if (fullName != gn->path)
free(fullName);