[FFmpeg-devel] Clang static analyser

Benjamin Larsson banan
Sun Apr 19 00:05:14 CEST 2009


Ramiro Polla wrote:
> On Sat, Apr 18, 2009 at 1:55 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
>> On Sat, Apr 18, 2009 at 04:02:33PM +0200, Benjamin Larsson wrote:
>>> Benjamin Larsson wrote:
>>>> Hi, I gave the clang static analyzer a test run. Here is the output from
>>>> todays svn:
>>>>
>>>> http://tranquillity.ath.cx/clang/scan-build-2009-04-17-1/
>>>>
>>>> Most of the logic errors should be real issues that can affect
>>>> stability. All the dead store things seem to be mostly noise.
>>> I reran the analysis as Michael took a real stab at cleaning up the
>>> defects found. Almost 50 less defects today.
>>>
>>> http://tranquillity.ath.cx/clang/scan-build-2009-04-18-1/
>> I found a few problems with CSA, and id love to hear some tips on how to
>> deal with them
> [...]
>> 2. logic errors that assume execution continues after av_exit()
> 
> Will CSA understand __attribute__((noreturn)) ?

It seems it does.

http://tranquillity.ath.cx/clang/scan-build-2009-04-18-4/

I used this patch:

Index: ffmpeg.c
===================================================================
--- ffmpeg.c    (revision 18611)
+++ ffmpeg.c    (working copy)
@@ -385,7 +385,7 @@
     return q_pressed || (q_pressed = read_key() == 'q');
 }

-static int av_exit(int ret)
+static int __attribute__ ((noreturn)) av_exit(int ret)
 {
     int i;


gcc complained then instead about non-void and noreturn at the same
time. There is a comment why the prototype isn't void:

exit(ret); /* not all OS-es handle main() return value */

I wonder how well they handle segfaults instead. I suggest we change the
prototype to void and then add a goto to end of main.

MvH
Benjamin Larsson



More information about the ffmpeg-devel mailing list