[PATCH:xf86-video-modesetting] Include <alloca.h> on platforms that need it for alloca

Alan Coopersmith alan.coopersmith at oracle.com
Fri Apr 13 14:57:26 PDT 2012


I'd be happier with that as well, but that's up to Dave I guess.

	-alan-

On 04/13/12 11:22 AM, Jeremy Huddleston wrote:
> Can we please instead fix this by removing the alloca() calls?
> 
> --Jeremy
> 
> """
> BUGS
>      alloca() is machine and compiler dependent; its use is discouraged.
> 
>      alloca() is slightly unsafe because it cannot ensure that the pointer returned points to a valid and usable
>      block of memory.  The allocation made may exceed the bounds of the stack, or even go further into other
>      objects in memory, and alloca() cannot determine such an error.  Avoid alloca() with large unbounded allo-
>      cations.
> 
>      The use of C99 variable-length arrays and alloca() in the same function will cause the lifetime of alloca's
>      storage to be limited to the block containing the alloca()
> """
> 
> On Apr 6, 2012, at 9:33 PM, Alan Coopersmith <alan.coopersmith at oracle.com> wrote:
> 
>> Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
>> ---
>> configure.ac |    1 +
>> src/driver.c |    3 +++
>> 2 files changed, 4 insertions(+)
>>
>> diff --git a/configure.ac b/configure.ac
>> index aa4ae9f..ddec78e 100644
>> --- a/configure.ac
>> +++ b/configure.ac
>> @@ -78,6 +78,7 @@ AM_CONDITIONAL(HAVE_XEXTPROTO_71, [ test "$HAVE_XEXTPROTO_71" = "yes" ])
>>
>> # Checks for header files.
>> AC_HEADER_STDC
>> +AC_ALLOCA
>>
>> PKG_CHECK_MODULES(DRM, [libdrm >= 2.2])
>> PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.10])
>> diff --git a/src/driver.c b/src/driver.c
>> index 87431ff..514c423 100644
>> --- a/src/driver.c
>> +++ b/src/driver.c
>> @@ -33,6 +33,9 @@
>> #include "config.h"
>> #endif
>>
>> +#ifdef HAVE_ALLOCA_H
>> +# include <alloca.h>
>> +#endif
>> #include <unistd.h>
>> #include <fcntl.h>
>> #include "xf86.h"
>> -- 
>> 1.7.9.2
>>
>> _______________________________________________
>> xorg-devel at lists.x.org: X.Org development
>> Archives: http://lists.x.org/archives/xorg-devel
>> Info: http://lists.x.org/mailman/listinfo/xorg-devel
>>
> 


-- 
	-Alan Coopersmith-              alan.coopersmith at oracle.com
	 Oracle Solaris Engineering - http://blogs.oracle.com/alanc


More information about the xorg-devel mailing list