Module Name:    src
Committed By:   rillig
Date:           Sat Aug 22 19:57:43 UTC 2020

Modified Files:
        src/usr.bin/make: dir.c

Log Message:
make(1): use Lst_OpenS in Dir_SetPATH

Since dirSearchPath is initialized in Dir_Init, opening the list can
never fail.


To generate a diff of this commit:
cvs rdiff -u -r1.106 -r1.107 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.106 src/usr.bin/make/dir.c:1.107
--- src/usr.bin/make/dir.c:1.106	Sat Aug 22 17:34:25 2020
+++ src/usr.bin/make/dir.c	Sat Aug 22 19:57:43 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.c,v 1.106 2020/08/22 17:34:25 rillig Exp $	*/
+/*	$NetBSD: dir.c,v 1.107 2020/08/22 19:57:43 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.106 2020/08/22 17:34:25 rillig Exp $";
+static char rcsid[] = "$NetBSD: dir.c,v 1.107 2020/08/22 19:57:43 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.106 2020/08/22 17:34:25 rillig Exp $");
+__RCSID("$NetBSD: dir.c,v 1.107 2020/08/22 19:57:43 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -478,43 +478,42 @@ Dir_SetPATH(void)
 {
     LstNode ln;			/* a list element */
     Path *p;
-    Boolean hasLastDot = FALSE;	/* true we should search dot last */
+    Boolean hasLastDot = FALSE;	/* true if we should search dot last */
 
     Var_Delete(".PATH", VAR_GLOBAL);
 
-    if (Lst_Open(dirSearchPath) == SUCCESS) {
-	if ((ln = Lst_First(dirSearchPath)) != NULL) {
-	    p = Lst_DatumS(ln);
-	    if (p == dotLast) {
-		hasLastDot = TRUE;
-		Var_Append(".PATH", dotLast->name, VAR_GLOBAL);
-	    }
+    Lst_OpenS(dirSearchPath);
+    if ((ln = Lst_First(dirSearchPath)) != NULL) {
+	p = Lst_DatumS(ln);
+	if (p == dotLast) {
+	    hasLastDot = TRUE;
+	    Var_Append(".PATH", dotLast->name, VAR_GLOBAL);
 	}
+    }
 
-	if (!hasLastDot) {
-	    if (dot)
-		Var_Append(".PATH", dot->name, VAR_GLOBAL);
-	    if (cur)
-		Var_Append(".PATH", cur->name, VAR_GLOBAL);
-	}
+    if (!hasLastDot) {
+	if (dot)
+	    Var_Append(".PATH", dot->name, VAR_GLOBAL);
+	if (cur)
+	    Var_Append(".PATH", cur->name, VAR_GLOBAL);
+    }
 
-	while ((ln = Lst_NextS(dirSearchPath)) != NULL) {
-	    p = Lst_DatumS(ln);
-	    if (p == dotLast)
-		continue;
-	    if (p == dot && hasLastDot)
-		continue;
-	    Var_Append(".PATH", p->name, VAR_GLOBAL);
-	}
+    while ((ln = Lst_NextS(dirSearchPath)) != NULL) {
+	p = Lst_DatumS(ln);
+	if (p == dotLast)
+	    continue;
+	if (p == dot && hasLastDot)
+	    continue;
+	Var_Append(".PATH", p->name, VAR_GLOBAL);
+    }
 
-	if (hasLastDot) {
-	    if (dot)
-		Var_Append(".PATH", dot->name, VAR_GLOBAL);
-	    if (cur)
-		Var_Append(".PATH", cur->name, VAR_GLOBAL);
-	}
-	Lst_CloseS(dirSearchPath);
+    if (hasLastDot) {
+	if (dot)
+	    Var_Append(".PATH", dot->name, VAR_GLOBAL);
+	if (cur)
+	    Var_Append(".PATH", cur->name, VAR_GLOBAL);
     }
+    Lst_CloseS(dirSearchPath);
 }
 
 /*-

Reply via email to