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

Clément Bœsch ubitux at gmail.com
Sat Sep 11 15:49:51 CEST 2010


> 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.

-- 
Clément B.
-------------- next part --------------
Index: m_option.h
===================================================================
--- 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;
 };
 
 
Index: m_option.c
===================================================================
--- m_option.c	(revision 32153)
+++ m_option.c	(working copy)
@@ -1530,7 +1530,7 @@
 			    const char *param, void* dst, int src) {
   char** opts;
   int r;
-  m_obj_params_t* p = opt->priv;
+  const m_obj_params_t* p = opt->priv;
   const m_struct_t* desc;
   char* cpy;
 
@@ -1770,7 +1770,7 @@
   }
 
   if(!strcmp(param,"help")) {
-    m_obj_list_t* ol = opt->priv;
+    const m_obj_list_t* ol = opt->priv;
     mp_msg(MSGT_VFILTER,MSGL_INFO,"Available video filters:\n");
     mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_FILTERS\n");
     for(n = 0 ; ol->list[n] ; n++)
@@ -1972,7 +1972,7 @@
 			    const char *url, void* dst, int src) {
   int pos1, pos2, r, v6addr = 0;
   char *ptr1=NULL, *ptr2=NULL, *ptr3=NULL, *ptr4=NULL;
-  m_struct_t* desc = opt->priv;
+  const m_struct_t* desc = opt->priv;
 
   if(!desc) {
     mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option %s: Custom URL needs a pointer to a m_struct_t in the priv field.\n",name);
Index: command.c
===================================================================
--- command.c	(revision 32153)
+++ command.c	(working copy)
@@ -1216,7 +1216,7 @@
 static int mp_property_gamma(m_option_t *prop, int action, void *arg,
                              MPContext *mpctx)
 {
-    int *gamma = prop->priv, r, val;
+    int *gamma = (int *)prop->priv, r, val;
 
     if (!mpctx->sh_video)
         return M_PROPERTY_UNAVAILABLE;
Index: m_config.c
===================================================================
--- m_config.c	(revision 32153)
+++ m_config.c	(working copy)
@@ -191,7 +191,7 @@
       pop++;
     }
     if(pop) // We removed some ctx -> set the previous value
-      m_option_set(co->opt,co->opt->p,co->slots->data);
+      m_option_set(co->opt,(void *)co->opt->p,co->slots->data);
   }
 
   config->lvl--;
@@ -248,7 +248,7 @@
     // We always use a dynamic version
     if((arg->type->flags & M_OPT_TYPE_DYNAMIC) && arg->p && (*(void**)arg->p)) {
       *(void**)arg->p = NULL;
-      m_option_set(arg,arg->p,sl->data);
+      m_option_set(arg,(void *)arg->p,sl->data);
     }
     sl->lvl = 0;
     sl->prev = NULL;
@@ -279,7 +279,7 @@
 }
 
 static m_config_option_t*
-m_config_get_co(m_config_t *config, char* arg) {
+m_config_get_co(const m_config_t *config, char* arg) {
   m_config_option_t *co;
 
   for(co = config->opts ; co ; co = co->next ) {
@@ -295,7 +295,7 @@
 }
 
 static int
-m_config_parse_option(m_config_t *config, char* arg, char* param,int set) {
+m_config_parse_option(const m_config_t *config, char* arg, char* param,int set) {
   m_config_option_t *co;
   int r = 0;
 
@@ -372,7 +372,7 @@
     return r;
   // Set the option
   if(set) {
-    m_option_set(co->opt,co->opt->p,co->slots->data);
+    m_option_set(co->opt,(void *)co->opt->p,co->slots->data);
     co->flags |= M_CFG_OPT_SET;
   }
 
@@ -386,7 +386,7 @@
 }
 
 int
-m_config_check_option(m_config_t *config, char* arg, char* param) {
+m_config_check_option(const m_config_t *config, char* arg, char* param) {
   int r;
   mp_msg(MSGT_CFGPARSER, MSGL_DBG2,"Checking %s=%s\n",arg,param);
   r=m_config_parse_option(config,arg,param,0);
@@ -399,7 +399,7 @@
 
 
 const m_option_t*
-m_config_get_option(m_config_t *config, char* arg) {
+m_config_get_option(const m_config_t *config, char* arg) {
   m_config_option_t *co;
 
 #ifdef MP_DEBUG
@@ -417,7 +417,7 @@
 
 
 void
-m_config_print_option_list(m_config_t *config) {
+m_config_print_option_list(const m_config_t *config) {
   char min[50],max[50];
   m_config_option_t* co;
   int count = 0;
@@ -450,7 +450,7 @@
 }
 
 m_profile_t*
-m_config_get_profile(m_config_t* config, char* name) {
+m_config_get_profile(const m_config_t* config, char* name) {
   m_profile_t* p;
   for(p = config->profiles ; p ; p = p->next)
     if(!strcmp(p->name,name)) return p;
@@ -504,7 +504,7 @@
 static int
 parse_profile(const m_option_t *opt, const char *name, const char *param, void *dst, int src)
 {
-  m_config_t* config = opt->priv;
+  const m_config_t* config = opt->priv;
   char** list = NULL;
   int i,r;
   if(param && !strcmp(param,"help")) {
@@ -539,7 +539,7 @@
 
 static void
 set_profile(const m_option_t *opt, void *dst, const void *src) {
-  m_config_t* config = opt->priv;
+  m_config_t* config = (m_config_t*)opt->priv;
   m_profile_t* p;
   char** list = NULL;
   int i;
@@ -555,7 +555,7 @@
 
 static int
 show_profile(m_option_t *opt, char* name, char *param) {
-  m_config_t* config = opt->priv;
+  m_config_t* config = (m_config_t *)opt->priv;
   m_profile_t* p;
   int i,j;
   if(!param) return M_OPT_MISSING_PARAM;
@@ -600,7 +600,7 @@
 
 static int
 list_options(m_option_t *opt, char* name, char *param) {
-  m_config_t* config = opt->priv;
+  const m_config_t* config = opt->priv;
   m_config_print_option_list(config);
   return M_OPT_EXIT;
 }
Index: m_config.h
===================================================================
--- m_config.h	(revision 32153)
+++ m_config.h	(working copy)
@@ -156,20 +156,20 @@
  *  \return See \ref OptionParserReturn.
  */
 int
-m_config_check_option(m_config_t *config, char* arg, char* param);
+m_config_check_option(const m_config_t *config, char* arg, char* param);
 
 /// Get the option matching the given name.
 /** \param config The config object.
  *  \param arg The option's name.
  */
 const struct m_option*
-m_config_get_option(m_config_t *config, char* arg);
+m_config_get_option(const m_config_t *config, char* arg);
 
 /// Print a list of all registered options.
 /** \param config The config object.
  */
 void
-m_config_print_option_list(m_config_t *config);
+m_config_print_option_list(const m_config_t *config);
 
 /// \addtogroup ConfigProfiles
 ///@{
@@ -180,7 +180,7 @@
  *  \return The profile object or NULL.
  */
 m_profile_t*
-m_config_get_profile(m_config_t* config, char* name);
+m_config_get_profile(const m_config_t* config, char* name);
 
 /// Get the profile with the given name, creating it if necessary.
 /** \param config The config object.
-------------- next part --------------
11,34d10
< In file included from cfg-mplayer.h:26:0,
<                  from mplayer.c:350:
< cfg-common.h:299:5: warning: initialization discards qualifiers from pointer target type
< cfg-common.h:312:5: warning: initialization discards qualifiers from pointer target type
< In file included from cfg-mplayer.h:26:0,
<                  from mplayer.c:350:
< cfg-common.h:458:5: warning: initialization discards qualifiers from pointer target type
< cfg-common.h:465:5: warning: initialization discards qualifiers from pointer target type
< cfg-common.h:470:5: warning: initialization discards qualifiers from pointer target type
< cfg-common.h:474:5: warning: initialization discards qualifiers from pointer target type
< cfg-common.h:476:5: warning: initialization discards qualifiers from pointer target type
< cfg-common.h:516:5: warning: initialization discards qualifiers from pointer target type
< cfg-common.h:519:5: warning: initialization discards qualifiers from pointer target type
< cfg-common.h:531:5: warning: initialization discards qualifiers from pointer target type
< cfg-common.h:536:5: warning: initialization discards qualifiers from pointer target type
< cfg-common.h:558:5: warning: initialization discards qualifiers from pointer target type
< cfg-common.h:561:5: warning: initialization discards qualifiers from pointer target type
< cfg-common.h:564:5: warning: initialization discards qualifiers from pointer target type
< In file included from mplayer.c:350:0:
< cfg-mplayer.h:346:5: warning: initialization discards qualifiers from pointer target type
< cfg-mplayer.h:353:5: warning: initialization discards qualifiers from pointer target type
< cfg-mplayer.h:354:5: warning: initialization discards qualifiers from pointer target type
< cfg-mplayer.h:355:5: warning: initialization discards qualifiers from pointer target type
< cfg-mplayer.h:357:5: warning: initialization discards qualifiers from pointer target type
635d610
< libmpcodecs/vf_scale.c:708:3: warning: initialization discards qualifiers from pointer target type
687,688d661
< stream/stream.c: In function 'open_stream_plugin':
< stream/stream.c:163:2: warning: initialization discards qualifiers from pointer target type
691,693d663
< stream/stream_cdda.c:97:14: warning: initialization discards qualifiers from pointer target type
< stream/stream_cdda.c:99:17: warning: initialization discards qualifiers from pointer target type
< stream/stream_cdda.c:123:3: warning: initialization discards qualifiers from pointer target type
1120,1150d1089
< In file included from cfg-mencoder.h:34:0,
<                  from mencoder.c:256:
< cfg-common.h:299:5: warning: initialization discards qualifiers from pointer target type
< cfg-common.h:312:5: warning: initialization discards qualifiers from pointer target type
< In file included from cfg-mencoder.h:34:0,
<                  from mencoder.c:256:
< cfg-common.h:458:5: warning: initialization discards qualifiers from pointer target type
< cfg-common.h:465:5: warning: initialization discards qualifiers from pointer target type
< cfg-common.h:470:5: warning: initialization discards qualifiers from pointer target type
< cfg-common.h:474:5: warning: initialization discards qualifiers from pointer target type
< cfg-common.h:476:5: warning: initialization discards qualifiers from pointer target type
< cfg-common.h:516:5: warning: initialization discards qualifiers from pointer target type
< cfg-common.h:519:5: warning: initialization discards qualifiers from pointer target type
< cfg-common.h:531:5: warning: initialization discards qualifiers from pointer target type
< cfg-common.h:536:5: warning: initialization discards qualifiers from pointer target type
< cfg-common.h:558:5: warning: initialization discards qualifiers from pointer target type
< cfg-common.h:561:5: warning: initialization discards qualifiers from pointer target type
< cfg-common.h:564:5: warning: initialization discards qualifiers from pointer target type
< In file included from mencoder.c:256:0:
< cfg-mencoder.h:190:5: warning: initialization discards qualifiers from pointer target type
< cfg-mencoder.h:191:5: warning: initialization discards qualifiers from pointer target type
< cfg-mencoder.h:194:5: warning: initialization discards qualifiers from pointer target type
< cfg-mencoder.h:221:5: warning: initialization discards qualifiers from pointer target type
< cfg-mencoder.h:224:5: warning: initialization discards qualifiers from pointer target type
< cfg-mencoder.h:227:5: warning: initialization discards qualifiers from pointer target type
< In file included from mencoder.c:256:0:
< cfg-mencoder.h:242:5: warning: initialization discards qualifiers from pointer target type
< cfg-mencoder.h:250:5: warning: initialization discards qualifiers from pointer target type
< cfg-mencoder.h:257:5: warning: initialization discards qualifiers from pointer target type
< cfg-mencoder.h:259:5: warning: initialization discards qualifiers from pointer target type
< cfg-mencoder.h:261:5: warning: initialization discards qualifiers from pointer target type


More information about the MPlayer-dev-eng mailing list