[MPlayer-dev-eng] [patch] make some functions static

Stefan Huehner stefan at huehner.org
Fri Jul 14 16:45:20 CEST 2006


On Thu, Jul 13, 2006 at 05:57:08PM +0200, Guillaume POIRIER wrote:
> Hi,
> 
> On 7/11/06, Stefan Huehner <stefan at huehner.org> wrote:
> >Hi,
> >
> >attached patch marks several function without a prototype which arent
> >used outside its sourcefile as static.
> >
> >Regards,
> >Stefan
> 
> BTW, What tool are you using to spot all of these?
> 
> Also, did you run some tests to see if GCC was taking advantage of
> being told if so and so variable is constant or static?

Hi,

the tool is used is plain gcc :) 
Using the following extra compiler flags one can enable several extra
warnings which i then use to spot i.e. static function candidates.

CFLAGS='-Wall -Wextra -Wwrite-strings -Wcast-qual -Wsign-compare
-Wmissing-declarations -Wstrict-prototypes -Wpointer-sign
-Wold-style-definition'

-Wmissing-declarations spots functions which are not marked as static
and have no corresponding prototype in a header file. These is the basis
for this patch. I try to make these ones static if possible, or create a
matching prototype.

-Wstrict-declarations finds 'foo()' type declarations. In plain C the
correct syntax to specify a function whithout parameters in 'foo(void)'.

-Wold-style-definition catches K&R style function declarations (but
unfortunately only for non-static functions).

-WWrite-strings and -Wcast-qual assist in finding const problem. Example
is 'char *s = 'Hello' emits the 'initialization discards qualifiers from
pointer target type'. As 'Hello' is non-writable and the 'char*' is a
pointer to a writable location. The correct thing here would be 'const
char*'.

Hope that explains a bit. Feel free to ask if anything is unclear...

Regards,
Stefan




More information about the MPlayer-dev-eng mailing list