05bba0
From d34f673f0d08eff0dce82db232574fe4b5e9ed95 Mon Sep 17 00:00:00 2001
05bba0
From: Richard Jones <rjones@redhat.com>
05bba0
Date: Thu, 11 Jun 2015 11:40:10 +0200
05bba0
Subject: [PATCH 10/30] curl: Remove unnecessary use of goto
05bba0
05bba0
Message-id: <1434022828-13037-4-git-send-email-rjones@redhat.com>
05bba0
Patchwork-id: 65838
05bba0
O-Subject: [RHEL-7.2 qemu-kvm v3 PATCH 03/21] curl: Remove unnecessary use of goto
05bba0
Bugzilla: 1226684
05bba0
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
05bba0
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
05bba0
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
05bba0
05bba0
From: Matthew Booth <mbooth@redhat.com>
05bba0
05bba0
This isn't any of the usually acceptable uses of goto.
05bba0
05bba0
Signed-off-by: Matthew Booth <mbooth@redhat.com>
05bba0
Tested-by: Richard W.M. Jones <rjones@redhat.com>
05bba0
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
05bba0
05bba0
Upstream-status: 9e550b326076caf4a1756b77eee95ad60b4adc27
05bba0
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
05bba0
---
05bba0
 block/curl.c | 55 +++++++++++++++++++++++++++----------------------------
05bba0
 1 file changed, 27 insertions(+), 28 deletions(-)
05bba0
05bba0
diff --git a/block/curl.c b/block/curl.c
05bba0
index f69e337..d399e3a 100644
05bba0
--- a/block/curl.c
05bba0
+++ b/block/curl.c
05bba0
@@ -295,39 +295,38 @@ static CURLState *curl_init_state(BDRVCURLState *s)
05bba0
         }
05bba0
     } while(!state);
05bba0
 
05bba0
-    if (state->curl)
05bba0
-        goto has_curl;
05bba0
-
05bba0
-    state->curl = curl_easy_init();
05bba0
-    if (!state->curl)
05bba0
-        return NULL;
05bba0
-    curl_easy_setopt(state->curl, CURLOPT_URL, s->url);
05bba0
-    curl_easy_setopt(state->curl, CURLOPT_TIMEOUT, 5);
05bba0
-    curl_easy_setopt(state->curl, CURLOPT_WRITEFUNCTION, (void *)curl_read_cb);
05bba0
-    curl_easy_setopt(state->curl, CURLOPT_WRITEDATA, (void *)state);
05bba0
-    curl_easy_setopt(state->curl, CURLOPT_PRIVATE, (void *)state);
05bba0
-    curl_easy_setopt(state->curl, CURLOPT_AUTOREFERER, 1);
05bba0
-    curl_easy_setopt(state->curl, CURLOPT_FOLLOWLOCATION, 1);
05bba0
-    curl_easy_setopt(state->curl, CURLOPT_NOSIGNAL, 1);
05bba0
-    curl_easy_setopt(state->curl, CURLOPT_ERRORBUFFER, state->errmsg);
05bba0
-    curl_easy_setopt(state->curl, CURLOPT_FAILONERROR, 1);
05bba0
-
05bba0
-    /* Restrict supported protocols to avoid security issues in the more
05bba0
-     * obscure protocols.  For example, do not allow POP3/SMTP/IMAP see
05bba0
-     * CVE-2013-0249.
05bba0
-     *
05bba0
-     * Restricting protocols is only supported from 7.19.4 upwards.
05bba0
-     */
05bba0
+    if (!state->curl) {
05bba0
+        state->curl = curl_easy_init();
05bba0
+        if (!state->curl) {
05bba0
+            return NULL;
05bba0
+        }
05bba0
+        curl_easy_setopt(state->curl, CURLOPT_URL, s->url);
05bba0
+        curl_easy_setopt(state->curl, CURLOPT_TIMEOUT, 5);
05bba0
+        curl_easy_setopt(state->curl, CURLOPT_WRITEFUNCTION,
05bba0
+                         (void *)curl_read_cb);
05bba0
+        curl_easy_setopt(state->curl, CURLOPT_WRITEDATA, (void *)state);
05bba0
+        curl_easy_setopt(state->curl, CURLOPT_PRIVATE, (void *)state);
05bba0
+        curl_easy_setopt(state->curl, CURLOPT_AUTOREFERER, 1);
05bba0
+        curl_easy_setopt(state->curl, CURLOPT_FOLLOWLOCATION, 1);
05bba0
+        curl_easy_setopt(state->curl, CURLOPT_NOSIGNAL, 1);
05bba0
+        curl_easy_setopt(state->curl, CURLOPT_ERRORBUFFER, state->errmsg);
05bba0
+        curl_easy_setopt(state->curl, CURLOPT_FAILONERROR, 1);
05bba0
+
05bba0
+        /* Restrict supported protocols to avoid security issues in the more
05bba0
+         * obscure protocols.  For example, do not allow POP3/SMTP/IMAP see
05bba0
+         * CVE-2013-0249.
05bba0
+         *
05bba0
+         * Restricting protocols is only supported from 7.19.4 upwards.
05bba0
+         */
05bba0
 #if LIBCURL_VERSION_NUM >= 0x071304
05bba0
-    curl_easy_setopt(state->curl, CURLOPT_PROTOCOLS, PROTOCOLS);
05bba0
-    curl_easy_setopt(state->curl, CURLOPT_REDIR_PROTOCOLS, PROTOCOLS);
05bba0
+        curl_easy_setopt(state->curl, CURLOPT_PROTOCOLS, PROTOCOLS);
05bba0
+        curl_easy_setopt(state->curl, CURLOPT_REDIR_PROTOCOLS, PROTOCOLS);
05bba0
 #endif
05bba0
 
05bba0
 #ifdef DEBUG_VERBOSE
05bba0
-    curl_easy_setopt(state->curl, CURLOPT_VERBOSE, 1);
05bba0
+        curl_easy_setopt(state->curl, CURLOPT_VERBOSE, 1);
05bba0
 #endif
05bba0
-
05bba0
-has_curl:
05bba0
+    }
05bba0
 
05bba0
     state->s = s;
05bba0
 
05bba0
-- 
05bba0
1.8.3.1
05bba0