diff --git a/usr.bin/config/main.c b/usr.bin/config/main.c index 278f1e3a8cf3..a68b08fbd829 100644 --- a/usr.bin/config/main.c +++ b/usr.bin/config/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.76 2015/08/08 15:52:41 shm Exp $ */ +/* $NetBSD: main.c,v 1.77 2015/08/28 03:55:15 uebayasi Exp $ */ /* * Copyright (c) 1992, 1993 @@ -45,7 +45,7 @@ #endif #include -__RCSID("$NetBSD: main.c,v 1.76 2015/08/08 15:52:41 shm Exp $"); +__RCSID("$NetBSD: main.c,v 1.77 2015/08/28 03:55:15 uebayasi Exp $"); #ifndef MAKE_BOOTSTRAP #include @@ -616,30 +616,26 @@ mksymlinks(void) const char *q; struct nvlist *nv; - snprintf(buf, sizeof(buf), "arch/%s/include", machine); - p = sourcepath(buf); + p = buf; + + snprintf(buf, sizeof(buf), "%s/arch/%s/include", srcdir, machine); ret = recreate(p, "machine"); ret = recreate(p, machine); - free(p); if (machinearch != NULL) { - snprintf(buf, sizeof(buf), "arch/%s/include", machinearch); - p = sourcepath(buf); + snprintf(buf, sizeof(buf), "%s/arch/%s/include", srcdir, machinearch); q = machinearch; } else { - p = estrdup("machine"); + snprintf(buf, sizeof(buf), "machine"); q = machine; } ret = recreate(p, q); - free(p); for (nv = machinesubarches; nv != NULL; nv = nv->nv_next) { q = nv->nv_name; - snprintf(buf, sizeof(buf), "arch/%s/include", q); - p = sourcepath(buf); + snprintf(buf, sizeof(buf), "%s/arch/%s/include", srcdir, q); ret = recreate(p, q); - free(p); } return (ret); diff --git a/usr.bin/config/mkioconf.c b/usr.bin/config/mkioconf.c index 8e4507e57238..90dbf54aa3d1 100644 --- a/usr.bin/config/mkioconf.c +++ b/usr.bin/config/mkioconf.c @@ -1,4 +1,4 @@ -/* $NetBSD: mkioconf.c,v 1.29 2015/08/20 09:44:24 christos Exp $ */ +/* $NetBSD: mkioconf.c,v 1.30 2015/08/28 03:55:15 uebayasi Exp $ */ /* * Copyright (c) 1992, 1993 @@ -45,7 +45,7 @@ #endif #include -__RCSID("$NetBSD: mkioconf.c,v 1.29 2015/08/20 09:44:24 christos Exp $"); +__RCSID("$NetBSD: mkioconf.c,v 1.30 2015/08/28 03:55:15 uebayasi Exp $"); #include #include @@ -147,9 +147,10 @@ emithdr(FILE *ofp) autogen_comment(ofp, "ioconf.c"); - (void)snprintf(ifnbuf, sizeof(ifnbuf), "arch/%s/conf/ioconf.incl.%s", + (void)snprintf(ifnbuf, sizeof(ifnbuf), "%s/arch/%s/conf/ioconf.incl.%s", + srcdir, machine ? machine : "(null)", machine ? machine : "(null)"); - ifn = sourcepath(ifnbuf); + ifn = ifnbuf; if ((ifp = fopen(ifn, "r")) != NULL) { while ((n = fread(buf, 1, sizeof(buf), ifp)) > 0) (void)fwrite(buf, 1, n, ofp); @@ -162,7 +163,6 @@ emithdr(FILE *ofp) "#include \n" "#include \n", ofp); } - free(ifn); } /* diff --git a/usr.bin/config/mkmakefile.c b/usr.bin/config/mkmakefile.c index 8202f73ebea1..1265251c0833 100644 --- a/usr.bin/config/mkmakefile.c +++ b/usr.bin/config/mkmakefile.c @@ -1,4 +1,4 @@ -/* $NetBSD: mkmakefile.c,v 1.37 2014/12/15 15:49:25 uebayasi Exp $ */ +/* $NetBSD: mkmakefile.c,v 1.38 2015/08/28 03:55:15 uebayasi Exp $ */ /* * Copyright (c) 1992, 1993 @@ -45,7 +45,7 @@ #endif #include -__RCSID("$NetBSD: mkmakefile.c,v 1.37 2014/12/15 15:49:25 uebayasi Exp $"); +__RCSID("$NetBSD: mkmakefile.c,v 1.38 2015/08/28 03:55:15 uebayasi Exp $"); #include #include @@ -94,8 +94,7 @@ mkmakefile(void) FILE *ifp, *ofp; int lineno; void (*fn)(FILE *); - char *ifname; - char line[BUFSIZ], buf[200]; + char line[BUFSIZ], ifname[200]; /* * Check if conf/Makefile.kern.inc defines "build_kernel". @@ -104,8 +103,8 @@ mkmakefile(void) * unfortunately the "build_kernel" change done around 2014 Aug didn't * bump that version. Thus this hack.) */ - (void)snprintf(buf, sizeof(buf), "conf/Makefile.kern.inc"); - ifname = sourcepath(buf); + (void)snprintf(ifname, sizeof(ifname), "%s/conf/Makefile.kern.inc", + srcdir); if ((ifp = fopen(ifname, "r")) == NULL) { warn("cannot read %s", ifname); goto bad2; @@ -121,17 +120,15 @@ mkmakefile(void) /* * Try a makefile for the port first. */ - (void)snprintf(buf, sizeof(buf), "arch/%s/conf/Makefile.%s", - machine, machine); - ifname = sourcepath(buf); + (void)snprintf(ifname, sizeof(ifname), "%s/arch/%s/conf/Makefile.%s", + srcdir, machine, machine); if ((ifp = fopen(ifname, "r")) == NULL) { /* * Try a makefile for the architecture second. */ - (void)snprintf(buf, sizeof(buf), "arch/%s/conf/Makefile.%s", - machinearch, machinearch); - free(ifname); - ifname = sourcepath(buf); + (void)snprintf(ifname, sizeof(ifname), + "%s/arch/%s/conf/Makefile.%s", + srcdir, machinearch, machinearch); ifp = fopen(ifname, "r"); } if (ifp == NULL) { @@ -205,7 +202,6 @@ mkmakefile(void) warn("error renaming Makefile"); goto bad2; } - free(ifname); return (0); wrerror: @@ -217,7 +213,6 @@ mkmakefile(void) (void)fclose(ifp); /* (void)unlink("Makefile.tmp"); */ bad2: - free(ifname); return (1); }