In article <20170131065424.246a2f...@cvs.netbsd.org>,
Simon J. Gerraty <source-changes-d@NetBSD.org> wrote:
>-=-=-=-=-=-
>
>Module Name:   src
>Committed By:  sjg
>Date:          Tue Jan 31 06:54:24 UTC 2017
>
>Modified Files:
>       src/usr.bin/make: dir.c main.c
>
>Log Message:
>Partially initialize Dir before MainParseArgs can be called.
>
>The rest can be done once curdir is finalized.
>
>
>To generate a diff of this commit:
>cvs rdiff -u -r1.68 -r1.69 src/usr.bin/make/dir.c
>cvs rdiff -u -r1.254 -r1.255 src/usr.bin/make/main.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.68 src/usr.bin/make/dir.c:1.69
>--- src/usr.bin/make/dir.c:1.68        Tue Jun  7 00:40:00 2016
>+++ src/usr.bin/make/dir.c     Tue Jan 31 06:54:23 2017
>@@ -1,4 +1,4 @@
>-/*    $NetBSD: dir.c,v 1.68 2016/06/07 00:40:00 sjg Exp $     */
>+/*    $NetBSD: dir.c,v 1.69 2017/01/31 06:54:23 sjg 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.68 2016/06/07 00:40:00 sjg Exp $";
>+static char rcsid[] = "$NetBSD: dir.c,v 1.69 2017/01/31 06:54:23 sjg 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.68 2016/06/07 00:40:00 sjg Exp $");
>+__RCSID("$NetBSD: dir.c,v 1.69 2017/01/31 06:54:23 sjg Exp $");
> #endif
> #endif /* not lint */
> #endif
>@@ -346,11 +346,13 @@ cached_lstat(const char *pathname, void 
> void
> Dir_Init(const char *cdname)
> {
>-    dirSearchPath = Lst_Init(FALSE);
>-    openDirectories = Lst_Init(FALSE);
>-    Hash_InitTable(&mtimes, 0);
>-    Hash_InitTable(&lmtimes, 0);
>-
>+    if (!cdname) {
>+      dirSearchPath = Lst_Init(FALSE);
>+      openDirectories = Lst_Init(FALSE);
>+      Hash_InitTable(&mtimes, 0);
>+      Hash_InitTable(&lmtimes, 0);
>+      return;
>+    }

Perhaps it is better to protect against calling this again like:

    if (!dirSearchPath) {
        dirSearchPath = Lst_Init(FALSE);
        openDirectories = Lst_Init(FALSE);
        Hash_InitTable(&mtimes, 0);
        Hash_InitTable(&lmtimes, 0);
    }
    if (!cdname)
        return;

christos

Reply via email to