[FFmpeg-cvslog] avcodec/v4l2_context: remove reinit variable

Ming Qian git at videolan.org
Wed Jan 12 06:34:57 EET 2022


ffmpeg | branch: master | Ming Qian <ming.qian at nxp.com> | Tue Jan  4 17:08:34 2022 +0800| [35a9307beb6c179a5e517c0d90d5991ed45c07ac] | committer: Andriy Gelman

avcodec/v4l2_context: remove reinit variable

Cleanup after commit 3fc72c9fc16df3b7edc329ed9eeaaa1e65976c33.
Fixes coverity ticket #1497095.

Reviewed-by: Andriy Gelman <andriy.gelman at gmail.com>
Signed-off-by: Ming Qian <ming.qian at nxp.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=35a9307beb6c179a5e517c0d90d5991ed45c07ac
---

 libavcodec/v4l2_context.c | 31 +++++++++++--------------------
 1 file changed, 11 insertions(+), 20 deletions(-)

diff --git a/libavcodec/v4l2_context.c b/libavcodec/v4l2_context.c
index a181f884d2..e891649f92 100644
--- a/libavcodec/v4l2_context.c
+++ b/libavcodec/v4l2_context.c
@@ -178,7 +178,7 @@ static int v4l2_handle_event(V4L2Context *ctx)
     V4L2m2mContext *s = ctx_to_m2mctx(ctx);
     struct v4l2_format cap_fmt = s->capture.format;
     struct v4l2_event evt = { 0 };
-    int reinit, ret;
+    int ret;
 
     ret = ioctl(s->fd, VIDIOC_DQEVENT, &evt);
     if (ret < 0) {
@@ -200,8 +200,7 @@ static int v4l2_handle_event(V4L2Context *ctx)
         return 0;
     }
 
-    reinit = v4l2_resolution_changed(&s->capture, &cap_fmt);
-    if (reinit) {
+    if (v4l2_resolution_changed(&s->capture, &cap_fmt)) {
         s->capture.height = v4l2_get_height(&cap_fmt);
         s->capture.width = v4l2_get_width(&cap_fmt);
         s->capture.sample_aspect_ratio = v4l2_get_sar(&s->capture);
@@ -210,28 +209,20 @@ static int v4l2_handle_event(V4L2Context *ctx)
         return 0;
     }
 
-    if (reinit)
-        s->reinit = 1;
+    s->reinit = 1;
 
-    if (reinit) {
-        if (s->avctx)
-            ret = ff_set_dimensions(s->avctx, s->capture.width, s->capture.height);
-        if (ret < 0)
-            av_log(logger(ctx), AV_LOG_WARNING, "update avcodec height and width\n");
+    if (s->avctx)
+        ret = ff_set_dimensions(s->avctx, s->capture.width, s->capture.height);
+    if (ret < 0)
+        av_log(logger(ctx), AV_LOG_WARNING, "update avcodec height and width\n");
 
-        ret = ff_v4l2_m2m_codec_reinit(s);
-        if (ret) {
-            av_log(logger(ctx), AV_LOG_ERROR, "v4l2_m2m_codec_reinit\n");
-            return AVERROR(EINVAL);
-        }
-        goto reinit_run;
+    ret = ff_v4l2_m2m_codec_reinit(s);
+    if (ret) {
+        av_log(logger(ctx), AV_LOG_ERROR, "v4l2_m2m_codec_reinit\n");
+        return AVERROR(EINVAL);
     }
 
-    /* dummy event received */
-    return 0;
-
     /* reinit executed */
-reinit_run:
     return 1;
 }
 



More information about the ffmpeg-cvslog mailing list