Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 26 Jun 1998 22:49:19 -0600
From:      Warner Losh <imp@village.org>
To:        John Birrell <jb@cimlogic.com.au>
Cc:        committers@FreeBSD.ORG
Subject:   Re: Changes to make (not) 
Message-ID:  <199806270449.WAA02497@harmony.village.org>
In-Reply-To: Your message of "Sat, 27 Jun 1998 14:36:09 %2B1000." <199806270436.OAA15514@cimlogic.com.au> 
References:  <199806270436.OAA15514@cimlogic.com.au>  

next in thread | previous in thread | raw e-mail | index | archive | help
In message <199806270436.OAA15514@cimlogic.com.au> John Birrell writes:
: Please avoid making changes to make(1) sources that rely on functions
: that aren't commonly available in other versions of UNIX. The recent
: changes that involve asprintf() mean that I can't do a bootstrap build
: of the FreeBSD sources using NetBSD/Alpha. This is not so much a problem
: to me now that I don't rely on doing that, but there are some who _are_.

Any objections to committing the following patch?  I think that we
should make life easier for the FreeBSD/alpha effort, and this patch
would do that.  There really is no reason to use asprintf here since
the length of the args is easy to calculate and it gets in the way of
the alpha porting effort.

I added the comment about sprintf being safe to prevent it from being
GC'd into snprintf or asprintf by a future autitor....

Warner

Index: main.c
===================================================================
RCS file: /home/imp/FreeBSD/CVS/src/usr.bin/make/main.c,v
retrieving revision 1.24
diff -u -r1.24 main.c
--- main.c	1998/06/13 11:55:57	1.24
+++ main.c	1998/06/27 04:45:54
@@ -186,9 +186,11 @@
 			break;
 		case 'V':
 			printVars = TRUE;
-			(void)asprintf(&p, "${%s}", optarg);
+			p = malloc(strlen(optarg) + 1 + 3);
 			if (!p)
 				Punt("make: cannot allocate memory.");
+                        /* This sprintf is safe, because of the malloc above */
+			(void)sprintf(&p, "${%s}", optarg);
 			(void)Lst_AtEnd(variables, (ClientData)p);
 			Var_Append(MAKEFLAGS, "-V", VAR_GLOBAL);
 			Var_Append(MAKEFLAGS, optarg, VAR_GLOBAL);

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199806270449.WAA02497>