[FFmpeg-devel] [PATCH] avcodec/bitstream: Rewrite code to avoid triggering compiler warning
Andreas Rheinhardt
andreas.rheinhardt at gmail.com
Wed Dec 9 01:11:47 EET 2020
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.
This solves this by checking the assert condition outside of the switch
and removing the default case.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
---
libavcodec/bitstream.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/libavcodec/bitstream.c b/libavcodec/bitstream.c
index 7570fb2204..9966323a9b 100644
--- a/libavcodec/bitstream.c
+++ b/libavcodec/bitstream.c
@@ -96,6 +96,7 @@ void ff_copy_bits(PutBitContext *pb, const uint8_t *src, int length)
#define GET_DATA(v, table, i, wrap, size) \
{ \
const uint8_t *ptr = (const uint8_t *)table + i * wrap; \
+ av_assert1(size == 1 || size == 2 || size == 4); \
switch(size) { \
case 1: \
v = *(const uint8_t *)ptr; \
@@ -106,8 +107,6 @@ void ff_copy_bits(PutBitContext *pb, const uint8_t *src, int length)
case 4: \
v = *(const uint32_t *)ptr; \
break; \
- default: \
- av_assert1(0); \
} \
}
--
2.25.1
More information about the ffmpeg-devel
mailing list