diff mbox series

[FFmpeg-devel,7/7] avcodec/iff: Use unsigned to avoid compiler warning

Message ID DB6PR0101MB2214E536D34E68889E5CBE578F869@DB6PR0101MB2214.eurprd01.prod.exchangelabs.com
State Accepted
Commit 4cd1d3e3b7e7412818553ae84e04ae3e077b680f
Headers show
Series [FFmpeg-devel,1/7] avcodec/iff: Split extract_header into extradata and packet part | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_armv7_RPi4 success Make finished
andriy/make_fate_armv7_RPi4 success Make fate finished

Commit Message

Andreas Rheinhardt July 12, 2022, 10:27 a.m. UTC
GCC 12 apparently believes that negative palette sizes are
possible (they are not, as this has already been checked during
init) and therefore emits a -Wstringop-overflow= for the memcpy.
Using unsigned avoids this.
(To be honest, there might be a compiler bug involved.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/iff.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/iff.c b/libavcodec/iff.c
index ad96bd9191..0bc2e3ca21 100644
--- a/libavcodec/iff.c
+++ b/libavcodec/iff.c
@@ -152,9 +152,10 @@  static av_always_inline uint32_t gray2rgb(const uint32_t x) {
 static int cmap_read_palette(AVCodecContext *avctx, uint32_t *pal)
 {
     IffContext *s = avctx->priv_data;
-    int count, i;
+    unsigned count, i;
     const uint8_t *const palette = avctx->extradata + AV_RB16(avctx->extradata);
-    int palette_size = avctx->extradata_size - AV_RB16(avctx->extradata);
+    /* extract_header() already checked that the RHS is >= 0. */
+    unsigned palette_size = avctx->extradata_size - AV_RB16(avctx->extradata);
 
     if (avctx->bits_per_coded_sample > 8) {
         av_log(avctx, AV_LOG_ERROR, "bits_per_coded_sample > 8 not supported\n");