Module Name:    src
Committed By:   rillig
Date:           Sun Nov  8 09:15:19 UTC 2020

Modified Files:
        src/usr.bin/make: arch.c dir.c nonints.h

Log Message:
make(1): change return type of Arch_MTime to void

This makes it easier to prove that Dir_MTime always returns gn->mtime,
without looking at the implementation of Arch_UpdateMTime.


To generate a diff of this commit:
cvs rdiff -u -r1.173 -r1.174 src/usr.bin/make/arch.c
cvs rdiff -u -r1.199 -r1.200 src/usr.bin/make/dir.c
cvs rdiff -u -r1.157 -r1.158 src/usr.bin/make/nonints.h

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/arch.c
diff -u src/usr.bin/make/arch.c:1.173 src/usr.bin/make/arch.c:1.174
--- src/usr.bin/make/arch.c:1.173	Sun Nov  8 09:06:22 2020
+++ src/usr.bin/make/arch.c	Sun Nov  8 09:15:19 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: arch.c,v 1.173 2020/11/08 09:06:22 rillig Exp $	*/
+/*	$NetBSD: arch.c,v 1.174 2020/11/08 09:15:19 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -93,10 +93,10 @@
  *			because it also updates the modification time
  *			of the library's table of contents.
  *
- *	Arch_MTime	Find the modification time of a member of
- *			an archive *in the archive*. The time is also
- *			placed in the member's GNode. Returns the
- *			modification time.
+ *	Arch_UpdateMTime
+ *			Find the modification time of a member of
+ *			an archive *in the archive* and place it in the
+ *			member's GNode.
  *
  *	Arch_UpdateMemberMTime
  *			Find the modification time of a member of
@@ -125,7 +125,7 @@
 #include "config.h"
 
 /*	"@(#)arch.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: arch.c,v 1.173 2020/11/08 09:06:22 rillig Exp $");
+MAKE_RCSID("$NetBSD: arch.c,v 1.174 2020/11/08 09:15:19 rillig Exp $");
 
 typedef struct List ArchList;
 typedef struct ListNode ArchListNode;
@@ -889,21 +889,16 @@ Arch_TouchLib(GNode *gn MAKE_ATTR_UNUSED
 
 /* Update the mtime of the GNode with the mtime from the archive member on
  * disk (or in the cache). */
-time_t
-Arch_MTime(GNode *gn)
+void
+Arch_UpdateMTime(GNode *gn)
 {
     struct ar_hdr *arh;
-    time_t modTime;
 
     arh = ArchStatMember(GNode_VarArchive(gn), GNode_VarMember(gn), TRUE);
-    if (arh != NULL) {
-	modTime = (time_t)strtol(arh->ar_date, NULL, 10);
-    } else {
-	modTime = 0;
-    }
-
-    gn->mtime = modTime;
-    return modTime;
+    if (arh != NULL)
+	gn->mtime = (time_t)strtol(arh->ar_date, NULL, 10);
+    else
+	gn->mtime = 0;
 }
 
 /* Given a non-existent archive member's node, update gn->mtime from its
@@ -930,7 +925,8 @@ Arch_UpdateMemberMTime(GNode *gn)
 
 	    if ((pgn->flags & REMAKE) &&
 		strncmp(nameStart, gn->name, nameLen) == 0) {
-		gn->mtime = Arch_MTime(pgn);
+		Arch_UpdateMTime(pgn);
+		gn->mtime = pgn->mtime;
 	    }
 	} else if (pgn->flags & REMAKE) {
 	    /*

Index: src/usr.bin/make/dir.c
diff -u src/usr.bin/make/dir.c:1.199 src/usr.bin/make/dir.c:1.200
--- src/usr.bin/make/dir.c:1.199	Sun Nov  8 09:06:22 2020
+++ src/usr.bin/make/dir.c	Sun Nov  8 09:15:19 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.c,v 1.199 2020/11/08 09:06:22 rillig Exp $	*/
+/*	$NetBSD: dir.c,v 1.200 2020/11/08 09:15:19 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -134,7 +134,7 @@
 #include "job.h"
 
 /*	"@(#)dir.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: dir.c,v 1.199 2020/11/08 09:06:22 rillig Exp $");
+MAKE_RCSID("$NetBSD: dir.c,v 1.200 2020/11/08 09:15:19 rillig Exp $");
 
 #define DIR_DEBUG0(text) DEBUG0(DIR, text)
 #define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1)
@@ -1302,7 +1302,8 @@ Dir_MTime(GNode *gn, Boolean recheck)
     CachedStatsFlags flags;
 
     if (gn->type & OP_ARCHV) {
-	return Arch_MTime(gn);
+	Arch_UpdateMTime(gn);
+	return gn->mtime;
     } else if (gn->type & OP_PHONY) {
 	gn->mtime = 0;
 	return 0;

Index: src/usr.bin/make/nonints.h
diff -u src/usr.bin/make/nonints.h:1.157 src/usr.bin/make/nonints.h:1.158
--- src/usr.bin/make/nonints.h:1.157	Sun Nov  8 09:06:23 2020
+++ src/usr.bin/make/nonints.h	Sun Nov  8 09:15:19 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nonints.h,v 1.157 2020/11/08 09:06:23 rillig Exp $	*/
+/*	$NetBSD: nonints.h,v 1.158 2020/11/08 09:15:19 rillig Exp $	*/
 
 /*-
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -79,7 +79,7 @@ void Arch_End(void);
 Boolean Arch_ParseArchive(char **, GNodeList *, GNode *);
 void Arch_Touch(GNode *);
 void Arch_TouchLib(GNode *);
-time_t Arch_MTime(GNode *);
+void Arch_UpdateMTime(GNode *gn);
 void Arch_UpdateMemberMTime(GNode *gn);
 void Arch_FindLib(GNode *, SearchPath *);
 Boolean Arch_LibOODate(GNode *);

Reply via email to