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

Clément Bœsch ubitux at gmail.com
Sat Sep 11 13:57:19 CEST 2010


> > Well in fact I didn't realized what exactly the problem was. As I
> > understand it now, this is happening:
> > 
> >    const int a[10];     void *p = a     // MPlayer case, warning
> >    int a[10];           void *p = a     // no warning
> >    const int a[10];     void *p = &a    // no warning
> 
> If that's the case that AFAICT is a compiler bug.
> 
> > Since the void *p has to accept const and non-const values (in MPlayer
> > design), their is no way to change it.
> 
> There is no reason you would _have_ to use the same void *.
> You could have another (const) pointer in the struct just for the
> suboptions.
> I don't know how many other changes that might need though.

In fact I think I have something better: just setting the void *p to const
works (gcc, clang), no warning are emitted, and binaries don't change.

There is a second entry with the same issue (void *priv), so the patch I
attached also change this.

What do you think of this workaround?

-- 
Clément B.
-------------- next part --------------
Index: m_option.h
===================================================================
--- m_option.h	(revision 32144)
+++ 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;
 };
 
 


More information about the MPlayer-dev-eng mailing list