[FFmpeg-devel] [patch] libswscale: fix warning regarding "no return in non void function"

Dominique Leuenberger dominique-ffmpeg-devel
Mon Apr 26 23:58:45 CEST 2010

Quoting Michael Niedermayer <michaelni at gmx.at>:

> On Mon, Apr 26, 2010 at 05:23:56PM +0300, Dominique Leuenberger wrote:
>> Quoting Dominique Leuenberger <dominique-ffmpeg-devel at leuenberger.net>:
>>> In libswscale, in case HAVE_7REGS is not defined to true, there are  two
>>> functions that result in empty code blocks.
>>> And as a consequence, the compiler warns about no return value in a  non
>>> void function.
>>> The attached patch fixes this by:
>>> - Moving the #if HAVE_7REGS out of the function declaraion (meaning  the
>>> function does not exist at all if we do not HAVE_7REGS.
>>> - Change some logic to not call the functions if they would not return
>>> useful result anyway.
>> Just to bring it back to life:
>> is a compiler warning about an empty function block 'cleaner' than avoiding
>> this using an #if directive?
> a #if* is always worse than a warning

Any reference that staes that other than your own opinion?

>> As said: we do have build log checks that fail in various cases known to
>> cause program errors: one of them is no return in non-void function (which
>> happens to be triggered in this specific case).
>> Yes, I agree, the compiler might get it wrong. But why not tell the
>> compiler that we're smarter? Another day somebody might call the function
>> without if (HAVE_7REGS), and then at least the compiler knows this is not
>> supposed to be and strictly tells: function is not defined.
> theres no reason to belive that this would ever be done
> but we know the #if will make the code less readable, thats a certain
> problem vs. a unlikely problem

Sure: we also never had a reason to believe earth was not a plate and  
we would not fall off at the edge.

Or are you trying to me that you have troubles understanding an #if  
when you see it?

I'm not in favor of replacing them all (agreed, that would make code  
unreadable.. that's m y personal opinion and can be quoted) but  
putting them in places where they do make sense. After all, there  
seemed not to be any objection of adding the #if HAVE_7REGS in the  
_template.c file. Why not be consistent and do it in both files (that  
actually belong together) ? doing twice the same in different manner  
also does not increase readability of code.


More information about the ffmpeg-devel mailing list