[PATCH] xfree86: Fix prototype for ConfigFilter

Jeremy Huddleston jeremyhu at apple.com
Sun Oct 16 05:18:21 PDT 2011


Ugg... ok, well nevermind then.  I guess I'll just turn off Werror for that warning for now when I build the Xorg DDX ... but thanks for pointing that out.  I hadn't noticed that discrepancy between SUSv4 and our scandir.

On Oct 16, 2011, at 4:40 AM, Mark Kettenis wrote:

>> From: Jeremy Huddleston <jeremyhu at apple.com>
>> Date: Sun, 16 Oct 2011 02:27:08 -0700
>> 
>> This allows scan.c to build with -Wincompatible-pointer-types
>> 
>> Build regression introduced by: efa5269f23c2237eb5368bf5245ffbbf35714153
>> 
>> Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
> 
> Guess it would help if you provided a little bit more information
> here.  I'm guessing the problem is with scandir(3), which
> traditionally had (and still has on various BSDs, including perhaps
> Darwin) the following prototype:
> 
>     int
>     scandir(const char *dirname, struct dirent ***namelist, int
>     (*select)(struct dirent *), int (*compar)(const void *, const void *));
> 
> But over in System V land, at least on Solaris, the prototype is:
> 
>     int
>     scandir(const char  *dirname, struct  dirent  *(*namelist[]), int
>     (*select)(const struct dirent *), int (*dcomp)(const struct dirent **,
>     const struct dirent **));
> 
> Which unfortunately is what ended up in POSIX :(.
> 
> Linux, for a long time, had a hybrid:
> 
>     int
>     scandir(const char *dir, struct dirent ***namelist, int
>     (*selector)(const struct dirent *), int (*cmp)(const void *,
>      const void *));
> 
> But they've fixed that somewhere in 2009.
> 
> So I guess that with your changes, things will break on Linux and Solaris.
> 
> One could argue that this is a problem with -Wincompatible-pointer-types,
> since in this context the const-restricted version of the "select"
> function is perfectly safe even if the scandir(3) prototype doesn't
> request it.
> 
>> ---
>> hw/xfree86/parser/scan.c | 2 +- 1 files changed, 1 insertions(+), 1
>> deletions(-)
>> 
>> diff --git a/hw/xfree86/parser/scan.c b/hw/xfree86/parser/scan.c
>> index 1cff3bc..7ce8c6d 100644
>> --- a/hw/xfree86/parser/scan.c
>> +++ b/hw/xfree86/parser/scan.c
>> @@ -767,7 +767,7 @@ OpenConfigFile(const char *path, const char *cmdline, const char *projroot,
>>  * suffix. This filter is passed to scandir(3).
>>  */
>> static int
>> -ConfigFilter(const struct dirent *de)
>> +ConfigFilter(struct dirent *de)
>> {
>> 	const char *name = de->d_name;
>> 	size_t len;
>> -- 
>> 1.7.6.1
>> 
>> 
>> _______________________________________________
>> 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
>> 
> _______________________________________________
> 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
> 



More information about the xorg-devel mailing list