[FFmpeg-devel] [PATCH] incorrect return type for opt_bitrate/type safety

Måns Rullgård mans
Wed Jan 2 01:49:09 CET 2008


Michael Niedermayer <michaelni at gmx.at> writes:

> On Wed, Jan 02, 2008 at 12:25:22AM +0100, Morten Hustveit wrote:
>> Hello,
>> 
>> during use I discovered that my -b and -vb options were rejected by
>> ffmpeg.  In the `options' array, the `opt_bitrate' function is
>> declared to be a OPT_FUNC2 handler, yet it void.  OPT_FUNC2
>> handlers are supposed to return int, and negative values for
>> failures.
>> 
>> This is symptomatic of lack of type safety; the compiler could have
>> warned about passing an incorrect function pointer type if given
>> the chance, but in every case the pointers were casted to (void*).
>> I have attached a patch which establishes type safety in the
>> `options' array, in addition to removing all the warnings this
>> caused.
>> 
>> +    { "L", 0, {func_arg: opt_show_license}, "show license" },
>> +    { "h", 0, {func_arg: opt_show_help}, "show help" },
>> +    { "version", 0, {func_arg: opt_show_version}, "show version" },
>> +    { "formats", 0, {func_arg: opt_show_formats}, "show available formats, codecs, protocols, ..." },
>> +    { "f", HAS_ARG, {func_arg: opt_format}, "force format", "fmt" },
>> +    { "i", HAS_ARG, {func_arg: opt_input_file}, "input file name", "filename" },
>> +    { "y", OPT_BOOL, {int_arg: &file_overwrite}, "overwrite output files" },
>
> changing (void*) to the nicer stuff is a cosmetic change and MUST be a 
> seperate patch

That syntax is non-standard.  The proper syntax is { .foo = bar }.

-- 
M?ns Rullg?rd
mans at mansr.com




More information about the ffmpeg-devel mailing list