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 Arch_MTime to void



details:   https://anonhg.NetBSD.org/src/rev/96692833356b
branches:  trunk
changeset: 1016085:96692833356b
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Nov 08 09:15:19 2020 +0000

description:
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.

diffstat:

 usr.bin/make/arch.c    |  32 ++++++++++++++------------------
 usr.bin/make/dir.c     |   7 ++++---
 usr.bin/make/nonints.h |   4 ++--
 3 files changed, 20 insertions(+), 23 deletions(-)

diffs (117 lines):

diff -r 4d7bda75327a -r 96692833356b usr.bin/make/arch.c
--- a/usr.bin/make/arch.c       Sun Nov 08 09:06:22 2020 +0000
+++ b/usr.bin/make/arch.c       Sun Nov 08 09:15:19 2020 +0000
@@ -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 @@
 
 /* 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 @@
 
            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) {
            /*
diff -r 4d7bda75327a -r 96692833356b usr.bin/make/dir.c
--- a/usr.bin/make/dir.c        Sun Nov 08 09:06:22 2020 +0000
+++ b/usr.bin/make/dir.c        Sun Nov 08 09:15:19 2020 +0000
@@ -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 @@
     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;
diff -r 4d7bda75327a -r 96692833356b usr.bin/make/nonints.h
--- a/usr.bin/make/nonints.h    Sun Nov 08 09:06:22 2020 +0000
+++ b/usr.bin/make/nonints.h    Sun Nov 08 09:15:19 2020 +0000
@@ -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 @@
 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 *);



Home | Main Index | Thread Index | Old Index