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): remove wrong comment in Dir_InitCur
details: https://anonhg.NetBSD.org/src/rev/ad28b8696322
branches: trunk
changeset: 978704:ad28b8696322
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Nov 29 15:14:32 2020 +0000
description:
make(1): remove wrong comment in Dir_InitCur
In a makefile with repeated ".CURDIR=." lines, Dir_AddDir is called with
a NULL path, once per line. Since the path is NULL, the search for
OpenDirs_Find is skipped and the directory is always read from disk.
The freshly read directory has a refCount of 1, and the refCount never
raises above 2.
In Dir_InitCur, the directory of the previous .CURDIR has a refCount of
2, which is decremented twice and then freed. After this, the new
directory is placed in the global 'cur', after incrementing its refCount
to 2.
It still seems wrong that the refCount of 'cur' is 2 instead of 1, but
it works well.
diffstat:
usr.bin/make/dir.c | 15 +++------------
1 files changed, 3 insertions(+), 12 deletions(-)
diffs (40 lines):
diff -r 1668fde7da78 -r ad28b8696322 usr.bin/make/dir.c
--- a/usr.bin/make/dir.c Sun Nov 29 14:29:19 2020 +0000
+++ b/usr.bin/make/dir.c Sun Nov 29 15:14:32 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dir.c,v 1.236 2020/11/29 14:29:19 rillig Exp $ */
+/* $NetBSD: dir.c,v 1.237 2020/11/29 15:14:32 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -136,7 +136,7 @@
#include "job.h"
/* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */
-MAKE_RCSID("$NetBSD: dir.c,v 1.236 2020/11/29 14:29:19 rillig Exp $");
+MAKE_RCSID("$NetBSD: dir.c,v 1.237 2020/11/29 15:14:32 rillig Exp $");
#define DIR_DEBUG0(text) DEBUG0(DIR, text)
#define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1)
@@ -467,20 +467,11 @@
if (dir == NULL)
return;
- /* XXX: Reference counting is wrong here.
- * If this function is called repeatedly with the same directory name,
- * its reference count increases each time even though the number of
- * actual references stays the same. */
-
- CachedDir_Ref(dir); /* XXX: This can be expressed clearer. */
if (cur != NULL && cur != dir) {
- /*
- * We've been here before, clean up.
- */
CachedDir_Unref(cur); /* XXX: why unref twice? */
CachedDir_Destroy(cur);
}
- cur = dir;
+ cur = CachedDir_Ref(dir);
}
/* (Re)initialize "dot" (current/object directory) path hash.
Home |
Main Index |
Thread Index |
Old Index