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

Michael Niedermayer michaelni
Mon Apr 26 23:38:46 CEST 2010

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

> 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

> Don't only look at the current situation: think a little bit ahead.
> Dominique

Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The educated differ from the uneducated as much as the living from the
dead. -- Aristotle 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100426/7485e200/attachment.pgp>

More information about the ffmpeg-devel mailing list