GNOME Bugzilla – Bug 611644
Work around usage of XPointer
Last modified: 2011-02-28 22:21:39 UTC
XLib has historically used "char*" for "generic pointer" but compliers rightly complain when casting this to a structure. Work around this by taking a void * in our handler, but casting the function type.
Created attachment 155072 [details] [review] Work around usage of XPointer
Created attachment 155074 [details] [review] Work around usage of XPointer XLib has historically used "char*" for "generic pointer" but compliers rightly complain when casting this to a structure. Work around this by casting to void * and letting the implicit conversion to a structure type take effect.
Created attachment 155233 [details] build log from a sparc machine
irc: <owen_> walters: where did this come up? what "compilers" are these? casting from a char * to a structure is certainly 100% valid --> ach1m (~ach1m@p57A7EA36.dip.t-dialin.net) has joined #gnome-shell mizmo (~duffy@66.187.234.199) has joined #gnome-shell <walters> owen_: gcc owen_: on sparc owen_: the void * cast is used elsewhere for XPointer conversion in metacity <ajax> owen_: not if your architecture has alignment requirements. (iirc. i always forget this crap.) <-- danielb has quit (Remote closed the connection) <owen_> ajax: how would that differ from void * casts? <walters> it's just a warning, not an immediate error <owen_> ajax: the compiler has no idea about the alignment of a void * or a char *? <walters> i think void * in C is special in that it's a total escape hatch <owen_> walters: why are you compiling metacity on sparc? <ajax> oh, i bet this is gcc's aliasing analysis more than something C mandates. <walters> owen_: haha i'm not, dgilmore was <owen_> ajax: char * is definitely excepted from the aliasing rules <-- mizmo has quit (Sláinte Mhath) <walters> owen_: he wanted to patch out the -Werror from the spec, i wasn't a fan of that, so... <ajax> well then i'm stumped. --> mizmo (~duffy@66.187.234.199) has joined #gnome-shell <owen_> walters I'd have to see the warning to even start to have an idea <walters> ok...i'll ask --> sanjien (~sanjie@117.204.5.90) has joined #gnome-shell drago01 (~linux@chello062178124135.3.13.univie.teleweb.at) has joined #gnome-shell bognarandras (~irssi@catv-86-101-0-88.catv.broadband.hu) has joined #gnome-shell <owen_> walters: <owen_> case " $CFLAGS " in *[\ \ ]-Wcast-align[\ \ ]*) ;; *) CFLAGS="$CFLAGS -Wcast-align" ;; esac <walters> ah, yes <owen_> to me that's the bogus thing, especially since -Wcast-align is machine specific, but whehter your code is bad or not is machine independent <owen_> walters: if the (void *) cast is all over the same file anyways, then it's probably OK in this case too, but not really, I think, fundamentally, right.
Attachment 155074 [details] pushed as 687376b - Work around usage of XPointer
I had this sitting around in my metacity checkout still, and decided to push it, not like it's going to hurt anything.