Module Name: src Committed By: rillig Date: Sun Nov 29 15:14:33 UTC 2020
Modified Files: src/usr.bin/make: dir.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.236 -r1.237 src/usr.bin/make/dir.c 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/dir.c diff -u src/usr.bin/make/dir.c:1.236 src/usr.bin/make/dir.c:1.237 --- src/usr.bin/make/dir.c:1.236 Sun Nov 29 14:29:19 2020 +++ src/usr.bin/make/dir.c Sun Nov 29 15:14:32 2020 @@ -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 @@ Dir_InitCur(const char *cdname) 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.