diff mbox series

[FFmpeg-devel,2/2] avcodec/bitstream: Rewrite code to avoid triggering compiler warning

Message ID 20210221014100.195627-2-andreas.rheinhardt@gmail.com
State Accepted
Commit 3bf07b1a2dfb2a7579f1d4c6ff6d64a444f66be2
Headers show
Series [FFmpeg-devel,1/2] avcodec/movtextenc: Check for too many styles
Related show


Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt Feb. 21, 2021, 1:41 a.m. UTC
Clang infers from the existence of a default case that said case can be
taken. In case of libavcodec/bitstream.c said default case consisted of
an av_assert1 that evaluates to nothing in case of the ordinary assert
level. In this case (that doesn't happen) a variable wouldn't be
initialized, so Clang emitted Wsometimes-uninitialized warnings.
Solve this by making sure that the default path also initializes
the aforementioned variable.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
 libavcodec/bitstream.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)


Paul B Mahol Feb. 21, 2021, 10:39 a.m. UTC | #1
probably ok
diff mbox series


diff --git a/libavcodec/bitstream.c b/libavcodec/bitstream.c
index 7570fb2204..e425ffdc96 100644
--- a/libavcodec/bitstream.c
+++ b/libavcodec/bitstream.c
@@ -104,10 +104,10 @@  void ff_copy_bits(PutBitContext *pb, const uint8_t *src, int length)
         v = *(const uint16_t *)ptr;                         \
         break;                                              \
     case 4:                                                 \
+    default:                                                \
+        av_assert1(size == 4);                              \
         v = *(const uint32_t *)ptr;                         \
         break;                                              \
-    default:                                                \
-        av_assert1(0);                                      \
     }                                                       \