]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tool_operate: reorder code to avoid compiler warning
authorDaniel Stenberg <daniel@haxx.se>
Mon, 8 Nov 2021 11:46:44 +0000 (12:46 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 8 Nov 2021 15:51:01 +0000 (16:51 +0100)
tool_operate.c(889) : warning C4701: potentially uninitialized local
variable 'per' use

Follow-up to cc71d352651a0d95
Reported-by: Marc Hörsken
Bug: https://github.com/curl/curl/pull/7922#issuecomment-963042676
Closes #7971

src/tool_operate.c

index f92b1bd37ed68883c1533b28191e101117e64b6c..ed3b2f56ad5c075f7e7aad140ebfcee5c58215eb 100644 (file)
@@ -794,7 +794,7 @@ static CURLcode single_transfer(struct GlobalConfig *global,
                     !strcmp(state->outfiles, "-")) && urlnum > 1);
 
       if(state->up < state->infilenum) {
-        struct per_transfer *per;
+        struct per_transfer *per = NULL;
         struct OutStruct *outs;
         struct InStruct *input;
         struct OutStruct *heads;
@@ -879,11 +879,12 @@ static CURLcode single_transfer(struct GlobalConfig *global,
         curl = curl_easy_init();
         if(curl)
           result = add_per_transfer(&per);
-        if(result || !curl) {
+        else
+          result = CURLE_OUT_OF_MEMORY;
+        if(result) {
           curl_easy_cleanup(curl);
           if(etag_save->fopened)
             fclose(etag_save->stream);
-          result = CURLE_OUT_OF_MEMORY;
           break;
         }
         per->etag_save = etag_first; /* copy the whole struct */