diff mbox

alloca: fix buf interaction

Message ID 1424755103-20378-1-git-send-email-vapier@gentoo.org
State Accepted
Headers show

Commit Message

Mike Frysinger Feb. 24, 2015, 5:18 a.m. UTC
The stack-grows-down case is missing paren around the buf cast.

The stack-grows-up case is missing a cast with the buf assignment.
This leads to build failures due to -Werror:
vfprintf.c: In function '_IO_vfprintf_internal':
vfprintf.c:1738:16: error: initialization from incompatible pointer type [-Werror]

2015-02-24  Mike Frysinger  <vapier@gentoo.org>

	* include/alloca.h [_STACK_GROWS_DOWN] (extend_alloca): Add
	parenthesis around the buf assignment.
	[_STACK_GROWS_UP] (extend_alloca): Add a char* cast.
---
 include/alloca.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Andreas Schwab Feb. 24, 2015, 3:55 p.m. UTC | #1
Mike Frysinger <vapier@gentoo.org> writes:

> 	* include/alloca.h [_STACK_GROWS_DOWN] (extend_alloca): Add
> 	parenthesis around the buf assignment.
> 	[_STACK_GROWS_UP] (extend_alloca): Add a char* cast.

Ok.

Andreas.
diff mbox

Patch

diff --git a/include/alloca.h b/include/alloca.h
index f741d25..0150025 100644
--- a/include/alloca.h
+++ b/include/alloca.h
@@ -28,7 +28,7 @@  libc_hidden_proto (__libc_alloca_cutoff)
 # define extend_alloca(buf, len, newlen) \
   (__typeof (buf)) ({ size_t __newlen = stackinfo_alloca_round (newlen);      \
 		      char *__newbuf = __alloca (__newlen);		      \
-		      if (__newbuf + __newlen == (char *) buf)		      \
+		      if (__newbuf + __newlen == (char *) (buf))	      \
 			len += __newlen;				      \
 		      else						      \
 			len = __newlen;					      \
@@ -37,7 +37,7 @@  libc_hidden_proto (__libc_alloca_cutoff)
 # define extend_alloca(buf, len, newlen) \
   (__typeof (buf)) ({ size_t __newlen = stackinfo_alloca_round (newlen);      \
 		      char *__newbuf = __alloca (__newlen);		      \
-		      char *__buf = (buf);				      \
+		      char *__buf = (char *) (buf);			      \
 		      if (__buf + len == __newbuf)			      \
 			{						      \
 			  len += __newlen;				      \