[PATCH:xorg-macros] Use AC_LANG_PROGRAM in XORG_CHECK_MALLOC_ZERO to clear autoconf-2.68 warnings

Gaetan Nadon memsize at videotron.ca
Sun Dec 5 11:27:06 PST 2010


On Sun, 2010-12-05 at 01:36 -0800, Alan Coopersmith wrote:

> configure.ac:126: warning: AC_LANG_CONFTEST: no AC_LANG_SOURCE call detected in body
> ../../lib/autoconf/lang.m4:194: AC_LANG_CONFTEST is expanded from...
> ../../lib/autoconf/general.m4:2730: _AC_RUN_IFELSE is expanded from...
> ../../lib/m4sugar/m4sh.m4:606: AS_IF is expanded from...
> ../../lib/autoconf/general.m4:2749: AC_RUN_IFELSE is expanded from...
> aclocal.m4:1952: XORG_CHECK_MALLOC_ZERO is expanded from...
> configure.ac:126: the top level
> 
> Also, calloc() takes two arguments, as the compiler points out when
> you #include <stdlib.h> instead of faking it badly.
> 
> Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
> ---
>  xorg-macros.m4.in |   14 ++++++--------
>  1 files changed, 6 insertions(+), 8 deletions(-)
> 
> diff --git a/xorg-macros.m4.in b/xorg-macros.m4.in
> index fe29881..c7df523 100644
> --- a/xorg-macros.m4.in
> +++ b/xorg-macros.m4.in
> @@ -904,18 +904,16 @@ AC_ARG_ENABLE(malloc0returnsnull,
>  
>  AC_MSG_CHECKING([whether malloc(0) returns NULL])
>  if test "x$MALLOC_ZERO_RETURNS_NULL" = xauto; then
> -	AC_RUN_IFELSE([
> -char *malloc();
> -char *realloc();
> -char *calloc();
> -main() {
> +	AC_RUN_IFELSE([AC_LANG_PROGRAM([
> +#include <stdlib.h>
> +],[
>      char *m0, *r0, *c0, *p;
>      m0 = malloc(0);
>      p = malloc(10);
>      r0 = realloc(p,0);
> -    c0 = calloc(0);
> -    exit(m0 == 0 || r0 == 0 || c0 == 0 ? 0 : 1);
> -}],
> +    c0 = calloc(0,10);
> +    exit((m0 == 0 || r0 == 0 || c0 == 0) ? 0 : 1);
> +])],
>  		[MALLOC_ZERO_RETURNS_NULL=yes],
>  		[MALLOC_ZERO_RETURNS_NULL=no],
>  		[MALLOC_ZERO_RETURNS_NULL=yes])


Reviewed-by: Gaetan Nadon <memsize at videotron.ca>

Tested with 2.63. There was no warning.


I keep seeing this all the time in config.log (not because of this
patch):

        conftest.c:2: warning: conflicting types for built-in function 'malloc'
        conftest.c:3: warning: conflicting types for built-in function 'realloc'
        conftest.c:4: warning: conflicting types for built-in function 'calloc'
        conftest.c: In function 'main':
        conftest.c:11: warning: incompatible implicit declaration of built-in function 'exit'

Seems to come from this macro.




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.x.org/archives/xorg-devel/attachments/20101205/8d97d712/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
URL: <http://lists.x.org/archives/xorg-devel/attachments/20101205/8d97d712/attachment.pgp>


More information about the xorg-devel mailing list