[MPlayer-dev-eng] [PATCH] remove a bunch of const qualifiers to get rid of compiler warnings

Oldrich Jedlicka oldium.pro at seznam.cz
Wed May 6 08:59:53 CEST 2009


On Wednesday 06 of May 2009 at 00:11:25, Andrew Savchenko wrote:
> On Wednesday 06 May 2009, Andrew Savchenko wrote:
> [...]
>
> > > Is there a solution that gets rid of the warnings?
> >
> > It's obvious: to fix the code. Perhaps in some places objects in
> > question are indeed non-constant, perhaps gcc bugs shows up
> > somewhere. Each single group should be reviewed separately.
>
> Example fix :) for m_config.c: const char* was assigned to char*
> without cast.

Hi Andrew,

I'm just curious (I'm non-mplayer dev) - look at the few lines above your 
cast. The co->name has dynamic allocation, so assigning it any const value 
looks wrong. I don't know if co->name is freed anywhere, but if yes, mplayer 
will have problem (and if no, the leak is there). I would use strdup() 
instead.

     co->name = malloc(l);
     sprintf(co->name,"%s:%s",prefix,arg->name);
   } else
-    co->name = arg->name;
+    co->name = (char*)arg->name;

Cheers,
Oldrich.



More information about the MPlayer-dev-eng mailing list