[MPlayer-dev-eng] [PATCH] Fix "initialization discards qualifiers" warnings in cfg-*.h

Diego Biurrun diego at biurrun.de
Mon Sep 27 11:26:52 CEST 2010


On Sat, Sep 11, 2010 at 03:49:51PM +0200, Clément Bœsch wrote:
> > The previous patch fixes the cfg-*.h warnings, but creates a few other in
> > the config parser. So here is a new patch adding fixing the related
> > constness issues in parser.
> > 
> > I also attached a diff of the warnings between the two versions (with and
> > without the patch).
> > 
> 
> Diff f*cked up in previous mail, sorry. Fixed in this mail.

Note: non-unified diffs are unreadable, even for showing differences
between warning lists.

> --- m_option.h	(revision 32153)
> +++ m_option.h	(working copy)
> @@ -280,7 +280,7 @@
>     *  use the priv field but this was inherited from older versions of the
>     *  config code.
>     */
> -  void *p;
> +  const void *p;
>  
>    /// Option type.
>    const m_option_type_t* type;
> @@ -301,7 +301,7 @@
>     *  Now it can be used to pass any type of extra args needed by the parser.
>     *  Passing a 'default func' is still valid for all func based option types.
>     */
> -  void* priv;
> +  const void* priv;
>  };

Hmmm...

I made this very same change some time ago, but reverted it after Uoti
complained:

------------------------------------------------------------------------
r30996 | diego | 2010-04-04 17:57:17 +0200 (Sun, 04 Apr 2010) | 3 lines
Changed paths:
   M /trunk/m_option.h

Revert marking m_option struct member as const.
It is used for non-const things, so the original change was wrong.
------------------------------------------------------------------------
r30989 | diego | 2010-04-03 13:06:57 +0200 (Sat, 03 Apr 2010) | 5 lines
Changed paths:
   M /trunk/m_option.h

Mark m_option struct member as const.

This fixes many warnings similar to:
cfg-mplayer.h:368: warning: initialization discards qualifiers from pointer target type
------------------------------------------------------------------------

I'm sure that Uoti's complaints were well-founded, but I agree that the
warnings are very annoying and bound to hide more important stuff.
If Reimar is OK with it I don't mind the change.  Nonetheless there
should be a comment that explains that the change is not 100% correct
and done to shut up the warnings.

Diego


More information about the MPlayer-dev-eng mailing list