diff --git a/libavcodec/sgidec.c b/libavcodec/sgidec.c
index e7f453bc174d31cecf04c46fcbdf4cf0c6957470..c6e7508d50cdbf42cd035654e56bc6e1a1323487 100644
--- a/libavcodec/sgidec.c
+++ b/libavcodec/sgidec.c
@@ -223,13 +223,11 @@ static int decode_frame(AVCodecContext *avctx,
     } else {
         ret = read_uncompressed_sgi(out_buf, s);
     }
-
-    if (ret == 0) {
-        *got_frame = 1;
-        return avpkt->size;
-    } else {
+    if (ret)
         return ret;
-    }
+
+    *got_frame = 1;
+    return avpkt->size;
 }
 
 AVCodec ff_sgi_decoder = {