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): fix aliasing problem in cached_stat fr...



details:   https://anonhg.NetBSD.org/src/rev/ff6f3a8e26a3
branches:  trunk
changeset: 938098:ff6f3a8e26a3
user:      rillig <rillig%NetBSD.org@localhost>
date:      Wed Sep 02 04:19:52 2020 +0000

description:
make(1): fix aliasing problem in cached_stat from the previous commit

When the struct stat was used for both calling the actual stat and for
returning the result, no copying was needed.  This also had the side
effect that for the first call of cached_stat, the returned struct stat
included all the fields properly filled in, and on later calls, these
fields were all zeroed out.

These two variables are separate now, thus the fields need to be copied
explicitly.  There are no existing unit tests for this, but ./build.sh
failed reliably.

diffstat:

 usr.bin/make/dir.c |  9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diffs (36 lines):

diff -r 6c21ed1fe45b -r ff6f3a8e26a3 usr.bin/make/dir.c
--- a/usr.bin/make/dir.c        Wed Sep 02 04:08:54 2020 +0000
+++ b/usr.bin/make/dir.c        Wed Sep 02 04:19:52 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dir.c,v 1.133 2020/09/02 04:08:54 rillig Exp $ */
+/*     $NetBSD: dir.c,v 1.134 2020/09/02 04:19:52 rillig 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.133 2020/09/02 04:08:54 rillig Exp $";
+static char rcsid[] = "$NetBSD: dir.c,v 1.134 2020/09/02 04:19:52 rillig 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.133 2020/09/02 04:08:54 rillig Exp $");
+__RCSID("$NetBSD: dir.c,v 1.134 2020/09/02 04:19:52 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -315,6 +315,9 @@
     if (rc == -1)
        return -1;
 
+    mst->mst_mode = sys_st.st_mode;
+    mst->mst_mtime = sys_st.st_mtime;
+
     if (sys_st.st_mtime == 0)
        sys_st.st_mtime = 1;    /* avoid confusion with missing file */
 



Home | Main Index | Thread Index | Old Index