[PATCH libxkbcommon 08/11] Fix all constness warnings

Ran Benita ran234 at gmail.com
Tue Feb 28 10:27:59 PST 2012


On Sun, Feb 26, 2012 at 03:30:42PM +0100, walter harms wrote:
> Am 25.02.2012 11:13, schrieb Ran Benita:
> > @@ -578,9 +578,13 @@ MakeMultiDefs(XkbRF_MultiDefsPtr mdefs, XkbRF_VarDefsPtr defs)
> >  static void
> >  FreeMultiDefs(XkbRF_MultiDefsPtr defs)
> >  {
> > -  if (defs->options) free(defs->options);
> > -  if (defs->layout[1])  free(defs->layout[1]);
> > -  if (defs->variant[1])  free(defs->variant[1]);
> > +  if (defs->options)
> > +    free(defs->options);
> > +  /* Avoid -Wcast-qual warnings. */
> > +  if (defs->layout[1])
> > +    free((void *)(uintptr_t)defs->layout[1]);
> > +  if (defs->variant[1])
> > +     free((void *)(uintptr_t)defs->variant[1]);
> >  }
> >  
> 
> free() can handle NULL these days,
> 
> re,
>  wh

Running the following semantic patch:

@@
expression E;
@@
- if (E != NULL)
-     free(E);
+ free(E);

Gives this:

 src/galloc.c             |    6 ++----
 src/maprules.c           |   36 ++++++++++++++++--------------------
 src/xkbcomp/compat.c     |    9 +++------
 src/xkbcomp/geometry.c   |   15 +++++----------
 src/xkbcomp/keycodes.c   |    6 ++----
 src/xkbcomp/keytypes.c   |    6 ++----
 src/xkbcomp/parseutils.c |   24 ++++++++----------------
 src/xkbcomp/symbols.c    |   30 ++++++++++--------------------
 src/xkbcomp/xkbparse.y   |    7 +++----
 src/xkbcomp/xkbscan.l    |    3 +--
 10 files changed, 52 insertions(+), 90 deletions(-)

And probably doesn't catch all of them. So maybe I can send this as a
separate patch later?


More information about the xorg-devel mailing list