aboutsummaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authorSimon J. Gerraty <sjg@FreeBSD.org>2017-04-20 23:12:37 +0000
committerSimon J. Gerraty <sjg@FreeBSD.org>2017-04-20 23:12:37 +0000
commitf62a02334b3d7ac500f6ed20aac449ecc477a673 (patch)
tree0aa711e5819aea1735576f7cd835075300d8510f /dir.c
parent85813b0c12abc28e502c1b1ae68d71ccfbd89b86 (diff)
downloadsrc-f62a02334b3d7ac500f6ed20aac449ecc477a673.tar.gz
src-f62a02334b3d7ac500f6ed20aac449ecc477a673.zip
Import bmake-20170420vendor/NetBSD/bmake/20170420
Only use -C arg "as is" if it contains no relative component. Fix Main_SetObjdir() for relative paths (eg obj). Fix a number of coverity complaints.
Notes
Notes: svn path=/vendor/NetBSD/bmake/dist/; revision=317232 svn path=/vendor/NetBSD/bmake/20170420/; revision=317233; tag=vendor/NetBSD/bmake/20170420
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c40
1 files changed, 28 insertions, 12 deletions
diff --git a/dir.c b/dir.c
index 2494da513ee2..8331999802d2 100644
--- a/dir.c
+++ b/dir.c
@@ -1,4 +1,4 @@
-/* $NetBSD: dir.c,v 1.69 2017/01/31 06:54:23 sjg Exp $ */
+/* $NetBSD: dir.c,v 1.71 2017/04/16 21:14:47 riastradh 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.69 2017/01/31 06:54:23 sjg Exp $";
+static char rcsid[] = "$NetBSD: dir.c,v 1.71 2017/04/16 21:14:47 riastradh 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.69 2017/01/31 06:54:23 sjg Exp $");
+__RCSID("$NetBSD: dir.c,v 1.71 2017/04/16 21:14:47 riastradh Exp $");
#endif
#endif /* not lint */
#endif
@@ -803,11 +803,11 @@ DirExpandInt(const char *word, Lst path, Lst expansions)
*-----------------------------------------------------------------------
*/
static int
-DirPrintWord(void *word, void *dummy)
+DirPrintWord(void *word, void *dummy MAKE_ATTR_UNUSED)
{
fprintf(debug_file, "%s ", (char *)word);
- return(dummy ? 0 : 0);
+ return 0;
}
/*-
@@ -1315,8 +1315,14 @@ Dir_FindFile(const char *name, Lst path)
fprintf(debug_file, " Trying exact path matches...\n");
}
- if (!hasLastDot && cur && (file = DirLookupAbs(cur, name, cp)) != NULL)
- return *file?file:NULL;
+ if (!hasLastDot && cur && ((file = DirLookupAbs(cur, name, cp))
+ != NULL)) {
+ if (file[0] == '\0') {
+ free(file);
+ return NULL;
+ }
+ return file;
+ }
(void)Lst_Open(path);
while ((ln = Lst_Next(path)) != NULL) {
@@ -1325,13 +1331,23 @@ Dir_FindFile(const char *name, Lst path)
continue;
if ((file = DirLookupAbs(p, name, cp)) != NULL) {
Lst_Close(path);
- return *file?file:NULL;
+ if (file[0] == '\0') {
+ free(file);
+ return NULL;
+ }
+ return file;
}
}
Lst_Close(path);
- if (hasLastDot && cur && (file = DirLookupAbs(cur, name, cp)) != NULL)
- return *file?file:NULL;
+ if (hasLastDot && cur && ((file = DirLookupAbs(cur, name, cp))
+ != NULL)) {
+ if (file[0] == '\0') {
+ free(file);
+ return NULL;
+ }
+ return file;
+ }
}
/*
@@ -1851,10 +1867,10 @@ Dir_PrintDirectories(void)
}
static int
-DirPrintDir(void *p, void *dummy)
+DirPrintDir(void *p, void *dummy MAKE_ATTR_UNUSED)
{
fprintf(debug_file, "%s ", ((Path *)p)->name);
- return (dummy ? 0 : 0);
+ return 0;
}
void