Subject: bin/13123: make: ReadMakefile return value incorrect
To: None <gnats-bugs@gnats.netbsd.org>
From: Simon J. Gerraty <sjg@quick.com.au>
List: netbsd-bugs
Date: 06/05/2001 23:36:51
>Number: 13123
>Category: bin
>Synopsis: make: ReadMakefile return value incorrect
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Jun 05 23:35:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: Simon J. Gerraty
>Release: 2001-06-01
>Organization:
Zen Programming...
>Environment:
System: NetBSD zen.quick.com.au 1.4.2 NetBSD 1.4.2 (ZEN) #2: Wed Mar 22 01:07:26 EST 2000 root@zen.quick.com.au:/u3/NetBSD/1.4.X/src/sys/arch/i386/compile/ZEN i386
>Description:
ReadMakefile is called by Lst_Find() to search sysMkPath for "sys.mk".
ReadMakefile currently returns TRUE on success, which is not what
Lst_Find expects - it want's 0 for success. As a result, multiple
sys.mk's may end up being read, with potentially bad side effects.
>How-To-Repeat:
>Fix:
The following changes ReadMakefile to returning FALSE (0) for success.
Which solves the above.
Index: main.c
===================================================================
RCS file: /cvsroot/basesrc/usr.bin/make/main.c,v
retrieving revision 1.67
diff -u -p -r1.67 main.c
--- main.c 2001/06/01 20:33:37 1.67
+++ main.c 2001/06/06 06:36:13
@@ -805,7 +805,7 @@ main(argc, argv)
Fatal("%s: no system rules (%s).", progname,
_PATH_DEFSYSMK);
ln = Lst_Find(sysMkPath, (ClientData)NULL, ReadMakefile);
- if (ln != NILLNODE)
+ if (ln == NILLNODE)
Fatal("%s: cannot open %s.", progname,
(char *)Lst_Datum(ln));
}
@@ -814,10 +814,10 @@ main(argc, argv)
LstNode ln;
ln = Lst_Find(makefiles, (ClientData)NULL, ReadMakefile);
- if (ln != NILLNODE)
+ if (ln == NILLNODE)
Fatal("%s: cannot open %s.", progname,
(char *)Lst_Datum(ln));
- } else if (!ReadMakefile("makefile", NULL))
+ } else if (ReadMakefile("makefile", NULL))
(void)ReadMakefile("Makefile", NULL);
(void)ReadMakefile(".depend", NULL);
@@ -974,7 +974,7 @@ main(argc, argv)
* Open and parse the given makefile.
*
* Results:
- * TRUE if ok. FALSE if couldn't open file.
+ * FALSE if ok. TRUE if couldn't open file.
*
* Side Effects:
* lots
@@ -1014,7 +1014,7 @@ ReadMakefile(p, q)
name = Dir_FindFile(fname, sysIncPath);
if (!name || !(stream = fopen(name, "r"))) {
free(path);
- return(FALSE);
+ return(TRUE);
}
fname = name;
/*
@@ -1029,7 +1029,7 @@ found:
(void)fclose(stream);
}
free(path);
- return(TRUE);
+ return(FALSE);
}
>Release-Note:
>Audit-Trail:
>Unformatted: