[FFmpeg-trac] #5345(undetermined:new): resample.c has "&& 0" in one of its "if" checks, which disables code

FFmpeg trac at avcodec.org
Wed Mar 16 18:52:58 CET 2016


#5345: resample.c has "&& 0" in one of its "if" checks, which disables code
-------------------------------------+-------------------------------------
             Reporter:  dholbert     |                     Type:  defect
               Status:  new          |                 Priority:  normal
            Component:               |                  Version:
  undetermined                       |  unspecified
             Keywords:               |               Blocked By:
             Blocking:               |  Reproduced by developer:  0
Analyzed by developer:  0            |
-------------------------------------+-------------------------------------
 Summary of the bug:
 ===================
 One of FFmpeg's source files, resample.c, has the following condition:
   if (s->input_channels == s->output_channels && s->ratio == 1.0 && 0) {

 The "&& 0" at the end there is almost certainly a typo -- it means the
 condition will always fail, and the code inside of the condition is dead
 code which will never be visited.

 How to reproduce:
 =================
 (1) Look at this line of source:
 https://github.com/FFmpeg/FFmpeg/blob/095347ffe4c73143dbeb7b05cde8891fd1289389/libavcodec/resample.c#L294

 (2) Notice the "&& 0" at the end of its "if" condition, which disables it.

 RESULT FOR COMPILER OUTPUT:
 This bug causes clang 3.8 (maybe older versions as well) to spam this
 build warning, if you compile with this build warning enabled:
   resample.c:296:9 [-Wunreachable-code] code will never be executed

 HISTORICAL NOTE:
 According to github blame, this change was introduced by michaelni here in
 2004:
 https://github.com/FFmpeg/FFmpeg/commit/b9d2085ba14aa733503ff02d966204992f46ff00

 The first piece of that patch was adding "&& 0" to this condition.

 Not sure if that was an accident, or intentionally disabling this
 condition. If it was intentional, it'd probably be better to explicitly
 delete this code, or wrap it in "#if 0 ... #endif" so that it's more
 explicitly-disabled & so the compiler doesn't have to see it.

--
Ticket URL: <https://trac.ffmpeg.org/ticket/5345>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list