[PATCH 3/9] config: warning fixes

Guillem Jover guillem at hadrons.org
Tue Oct 19 21:49:48 PDT 2010


Hi!

On Tue, 2010-10-19 at 11:59:18 -0400, Adam Jackson wrote:
> xf86AutoConfig.c: In function ‘FreeList’:
> xf86AutoConfig.c:123: warning: passing argument 1 of ‘free’ discards
> qualifiers from pointer target type
> /usr/include/stdlib.h:488: note: expected ‘void *’ but argument is of
> type ‘const char *’

> diff --git a/hw/xfree86/common/xf86AutoConfig.c b/hw/xfree86/common/xf86AutoConfig.c
> index 200cb8f..d06a561 100644
> --- a/hw/xfree86/common/xf86AutoConfig.c
> +++ b/hw/xfree86/common/xf86AutoConfig.c
> @@ -120,7 +120,7 @@ FreeList(const char ***list, int *lines)
>      int i;
>  
>      for (i = 0; i < *lines; i++) {
> -	free((*list)[i]);
> +	free((char *)((*list)[i]));
>      }
>      free(*list);
>      *list = NULL;

Well, I'd say that if you need to free the pointer then it should not
be const in the first place. In the future it might end up, for example,
with a literal assigned to it, which free() would not like much, and the
compiler would not be able to detect, but -Wwrite-strings would
otherwise.

The same goes for the loader patch.

regards,
guillem


More information about the xorg-devel mailing list