tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[reinoud%NetBSD.org@localhost: make(1) cleanup patch]



----- Forwarded message from Reinoud Zandijk <reinoud%NetBSD.org@localhost> -----

Date: Wed, 11 Jul 2018 21:03:38 +0200
From: Reinoud Zandijk <reinoud%NetBSD.org@localhost>
To: current-users%NetBSD.org@localhost
Subject: make(1) cleanup patch
User-Agent: Mutt/1.9.4 (2018-02-28)

Dear folks,

in my attempt to clean up make(1) I stumbled on the following duplicate code.
It was replaced by the cached_stat() addition but the old code was not
removed.

I tested the unit-test and all output is identical as well as are all ATF
tests are still passing.

If there are no objections I'd like to commit these patches,
Reinoud

--------

Index: dir.c
===================================================================
RCS file: /cvsroot/src/usr.bin/make/dir.c,v
retrieving revision 1.71
diff -u -p -r1.71 dir.c
--- dir.c	16 Apr 2017 21:14:47 -0000	1.71
+++ dir.c	11 Jul 2018 18:47:44 -0000
@@ -268,15 +268,6 @@ struct cache_st {
 };
 
 /* minimize changes below */
-static time_t
-Hash_GetTimeValue(Hash_Entry *entry)
-{
-    struct cache_st *cst;
-
-    cst = entry->clientPtr;
-    return cst->mtime;
-}
-
 #define CST_LSTAT 1
 #define CST_UPDATE 2
 
@@ -1134,7 +1125,6 @@ Dir_FindFile(const char *name, Lst path)
     Boolean	  hasLastDot = FALSE;	/* true we should search dot last */
     Boolean	  hasSlash;		/* true if 'name' contains a / */
     struct stat	  stb;			/* Buffer for stat, if necessary */
-    Hash_Entry	  *entry;		/* Entry for mtimes table */
     const char   *trailing_dot = ".";
 
     /*
@@ -1395,13 +1385,7 @@ Dir_FindFile(const char *name, Lst path)
     }
 
     bigmisses += 1;
-    entry = Hash_FindEntry(&mtimes, name);
-    if (entry != NULL) {
-	if (DEBUG(DIR)) {
-	    fprintf(debug_file, "   got it (in mtime cache)\n");
-	}
-	return(bmake_strdup(name));
-    } else if (cached_stat(name, &stb) == 0) {
+    if (cached_stat(name, &stb) == 0) {
 	if (DEBUG(DIR)) {
 	    fprintf(debug_file, "   Caching %s for %s\n", Targ_FmtTime(stb.st_mtime),
 		    name);
@@ -1518,7 +1502,6 @@ Dir_MTime(GNode *gn, Boolean recheck)
 {
     char          *fullName;  /* the full pathname of name */
     struct stat	  stb;	      /* buffer for finding the mod time */
-    Hash_Entry	  *entry;
 
     if (gn->type & OP_ARCHV) {
 	return Arch_MTime(gn);
@@ -1569,17 +1552,7 @@ Dir_MTime(GNode *gn, Boolean recheck)
 	fullName = bmake_strdup(gn->name);
     }
 
-    if (!recheck)
-	entry = Hash_FindEntry(&mtimes, fullName);
-    else
-	entry = NULL;
-    if (entry != NULL) {
-	stb.st_mtime = Hash_GetTimeValue(entry);
-	if (DEBUG(DIR)) {
-	    fprintf(debug_file, "Using cached time %s for %s\n",
-		    Targ_FmtTime(stb.st_mtime), fullName);
-	}
-    } else if (cached_stats(&mtimes, fullName, &stb, recheck ? CST_UPDATE : 0) < 0) {
+    if (cached_stats(&mtimes, fullName, &stb, recheck ? CST_UPDATE : 0) < 0) {
 	if (gn->type & OP_MEMBER) {
 	    if (fullName != gn->path)
 		free(fullName);



----- End forwarded message -----

Attachment: signature.asc
Description: PGP signature



Home | Main Index | Thread Index | Old Index