[Spice-devel] [PATCH xf86-video-qxl 04/13] qxl_driver: cleanup: fix const cast warnings

Alon Levy alevy at redhat.com
Wed Apr 11 05:04:37 PDT 2012


On Wed, Apr 11, 2012 at 01:37:49PM +0200, Christophe Fergeau wrote:
> On Wed, Apr 11, 2012 at 02:05:17PM +0300, Alon Levy wrote:
> > On Wed, Apr 11, 2012 at 12:46:18PM +0200, Christophe Fergeau wrote:
> > > On Tue, Apr 10, 2012 at 04:02:56PM +0300, Alon Levy wrote:
> > > > My bad for not putting it in. It's warning on a const attribute removal
> > > > cast, since a static string "bla" is (const char*).
> > > 
> > > For the record, the warning is -Wcast-qual. While this patch is okayish,
> > > the 2 other similar patches are a bit ugly imo. Maybe we could use a pragma
> > > to disable this warning around the initialisation of X structures?
> > > 
> > > Christophe
> > 
> > Which pragma does that?
> 
> Dunno, but actually I was wrong about the flag that causes these warnings,
> it's -Wwrite-strings actually.
> gcc documentation says:
> -Wwrite-strings:
>            When compiling C, give string constants the type "const
> char[length]" so that copying the address of one into a non-"const" "char
> *" pointer will get a warning.  These warnings will help you find at
> compile time code that can try to write into a string constant, but only if
> you have been very careful about using "const" in declarations and
> prototypes.  Otherwise, it will just be a nuisance. This is why we did not
> make -Wall request these warnings.
> 
> Given that we are definitely dealing with code not using "const"
> consistently in declarations and prototypes, I'd tend to just drop that
> warning.

My problem with carying on this seamingly simple suggestion is that I
haven't found the source of the warnings yet, I think it's via
xorg-macros, if I could disable this I'd also disable -Winline at the
same time.

> 
> Christophe



> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel



More information about the Spice-devel mailing list