[PATCH 02/16] xf86AutoConfig: Simplify builtin-config splitting.

Dirk Wallenstein halsmit at t-online.de
Thu May 27 01:32:24 PDT 2010


On Wed, May 26, 2010 at 12:19:52PM -0700, Dan Nicholson wrote:
> On Wed, May 26, 2010 at 12:12 PM, Mark Kettenis <mark.kettenis at xs4all.nl> wrote:
> >> From: Jamey Sharp <jamey at minilop.net>
> >> Date: Wed, 26 May 2010 10:40:51 -0700
> >>
> >> On Wed, May 26, 2010 at 1:29 AM, Mark Kettenis <mark.kettenis at xs4all.nl> wrote:
> >> >> From: Jamey Sharp <jamey at minilop.net>
> >> >> Date: Tue, 25 May 2010 16:53:13 -0700
> >> >>
> >> >> @@ -179,7 +169,7 @@ xf86AutoConfig(void)
> >> >>      xf86MsgVerb(X_DEFAULT, 3, "--- End of built-in configuration ---\n");
> >> >>
> >> >>      xf86initConfigFiles();
> >> >> -    xf86setBuiltinConfig(builtinConfig);
> >> >> +    xf86setBuiltinConfig((const char **) builtinConfig);
> >> >
> >> > That cast isn't really necessary isn't it?
> >>
> >> I wasn't happy about it either, but at least according to GCC, while
> >> "const char *" is assignment-compatible from "char *", "const char **"
> >> is not compatible with "char **". So I was going to have to cast
> >> either at the call to free or this call to xf86setBuiltinConfig, and
> >> this seemed more sane to me.
> >
> > Ugh, pointers to pointers continue to confuse me, so I wouldn't be
> > able to tell if GCC is on crack here or not.  Thanks for the
> > explanation.
> 
> We had the same discussion a week or so ago about the char **tags in
> InputAttributes. Finally I had to see exactly what gcc was up to. The
> results don't make me happy, but I'm no C guru to say whether it's
> right or wrong.
> 
> int main(void)
> {
>     const char * const *a;
>     const char **b;
>     char * const *c;
>     char *d[] = {"foo", "bar"};
> 
>     a = d; /* warning: assignment from incompatible pointer type */
>     b = d; /* warning: assignment from incompatible pointer type */
>     c = d; /* OK? */
> 
>     return 0;
> }

I'm still looking for a good catchphrase to instantly remember this.
"Have access to the same pointer with and without const qualified
pointee by means of a pointer-to-pointer" feels a bit bulky. I think
top-level-constness is a keyword here.

void nofun(void)
{
    const char * literal = "fang";
    char * changer = 0;
    const char ** subverter = &changer; // Warning although "more const"
    *subverter = literal; // exact type match!
    changer[0] = 'b'; // 'bang'
}

-- 
Greetings,
Dirk


More information about the xorg-devel mailing list