diff --git a/libavformat/smjpegdec.c b/libavformat/smjpegdec.c
index 7764c0f34dd82ffe7cdff09f5c01d75b9f49bdcc..4cbfa2a5801ea611be31945334bcb4171840d092 100644
--- a/libavformat/smjpegdec.c
+++ b/libavformat/smjpegdec.c
@@ -135,8 +135,9 @@ static int smjpeg_read_header(AVFormatContext *s)
 static int smjpeg_read_packet(AVFormatContext *s, AVPacket *pkt)
 {
     SMJPEGContext *sc = s->priv_data;
-    uint32_t dtype, ret, size, timestamp;
+    uint32_t dtype, size, timestamp;
     int64_t pos;
+    int ret;
 
     if (s->pb->eof_reached)
         return AVERROR_EOF;