[FFmpeg-cvslog] avformat/libzmq: Replace fail statements with goto

Andriy Gelman git at videolan.org
Tue Jan 21 17:00:18 EET 2020


ffmpeg | branch: master | Andriy Gelman <andriy.gelman at gmail.com> | Fri Jan 10 23:25:26 2020 -0500| [c07565627b5fe5f27f0fb13a2f3eed03cebb85ec] | committer: Michael Niedermayer

avformat/libzmq: Replace fail statements with goto

Signed-off-by: Andriy Gelman <andriy.gelman at gmail.com>
Reviewed-by: Paul B Mahol <onemda at gmail.com>
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

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

 libavformat/libzmq.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/libavformat/libzmq.c b/libavformat/libzmq.c
index 2df55542c7..8c8b294c92 100644
--- a/libavformat/libzmq.c
+++ b/libavformat/libzmq.c
@@ -101,16 +101,13 @@ static int zmq_proto_open(URLContext *h, const char *uri, int flags)
         s->socket = zmq_socket(s->context, ZMQ_PUB);
         if (!s->socket) {
             av_log(h, AV_LOG_ERROR, "Error occured during zmq_socket(): %s\n", ZMQ_STRERROR);
-            zmq_ctx_term(s->context);
-            return AVERROR_EXTERNAL;
+            goto fail_term;
         }
 
         ret = zmq_bind(s->socket, uri);
         if (ret == -1) {
             av_log(h, AV_LOG_ERROR, "Error occured during zmq_bind(): %s\n", ZMQ_STRERROR);
-            zmq_close(s->socket);
-            zmq_ctx_term(s->context);
-            return AVERROR_EXTERNAL;
+            goto fail_close;
         }
     }
 
@@ -119,27 +116,28 @@ static int zmq_proto_open(URLContext *h, const char *uri, int flags)
         s->socket = zmq_socket(s->context, ZMQ_SUB);
         if (!s->socket) {
             av_log(h, AV_LOG_ERROR, "Error occured during zmq_socket(): %s\n", ZMQ_STRERROR);
-            zmq_ctx_term(s->context);
-            return AVERROR_EXTERNAL;
+            goto fail_term;
         }
 
         ret = zmq_setsockopt(s->socket, ZMQ_SUBSCRIBE, "", 0);
         if (ret == -1) {
             av_log(h, AV_LOG_ERROR, "Error occured during zmq_setsockopt(): %s\n", ZMQ_STRERROR);
-            zmq_close(s->socket);
-            zmq_ctx_term(s->context);
-            return AVERROR_EXTERNAL;
+            goto fail_close;
         }
 
         ret = zmq_connect(s->socket, uri);
         if (ret == -1) {
             av_log(h, AV_LOG_ERROR, "Error occured during zmq_connect(): %s\n", ZMQ_STRERROR);
-            zmq_close(s->socket);
-            zmq_ctx_term(s->context);
-            return AVERROR_EXTERNAL;
+            goto fail_close;
         }
     }
     return 0;
+
+fail_close:
+    zmq_close(s->socket);
+fail_term:
+    zmq_ctx_term(s->context);
+    return AVERROR_EXTERNAL;
 }
 
 static int zmq_proto_write(URLContext *h, const unsigned char *buf, int size)



More information about the ffmpeg-cvslog mailing list