[FFmpeg-devel] [PATCH] avcodec/bitstream: Rewrite code to avoid triggering compiler warning
Paul B Mahol
onemda at gmail.com
Wed Dec 9 12:25:17 EET 2020
probably fine
On Wed, Dec 9, 2020 at 12:17 AM Andreas Rheinhardt <
andreas.rheinhardt at gmail.com> wrote:
> 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
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
More information about the ffmpeg-devel
mailing list