]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tool_operate: avoid a few #ifdefs for disabled-libcurl builds
authorDaniel Stenberg <daniel@haxx.se>
Mon, 12 Sep 2022 14:30:54 +0000 (16:30 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 13 Sep 2022 08:28:50 +0000 (10:28 +0200)
By providing empty macros in the header file instead, the code gets
easier to read and yet is disabled on demand.

Closes #9486

src/tool_easysrc.h
src/tool_operate.c

index d7a629aca76b890942162312243512c05997b1ca..ec2fdd23f05701bf156d1149a13691c94b72b4c0 100644 (file)
@@ -46,6 +46,13 @@ extern CURLcode easysrc_cleanup(void);
 
 void dumpeasysrc(struct GlobalConfig *config);
 
+#else /* CURL_DISABLE_LIBCURL_OPTION is defined */
+
+#define easysrc_init() CURLE_OK
+#define easysrc_cleanup()
+#define dumpeasysrc(x)
+#define easysrc_perform(x) CURLE_OK
+
 #endif /* CURL_DISABLE_LIBCURL_OPTION */
 
 #endif /* HEADER_CURL_TOOL_EASYSRC_H */
index 75ef68478af3fde28bbbfd7efbf536fb3079fa9e..7d64c1c4d2b821fae4d1dc217ca5b4f25d9e1fb1 100644 (file)
@@ -2417,13 +2417,12 @@ static CURLcode serial_transfers(struct GlobalConfig *global,
     if(result)
       break;
 
-#ifndef CURL_DISABLE_LIBCURL_OPTION
     if(global->libcurl) {
       result = easysrc_perform();
       if(result)
         break;
     }
-#endif
+
     start = tvnow();
 #ifdef CURLDEBUG
     if(global->test_event_based)
@@ -2695,12 +2694,10 @@ CURLcode operate(struct GlobalConfig *global, int argc, argv_item_t argv[])
         result = CURLE_FAILED_INIT;
     }
     else {
-#ifndef CURL_DISABLE_LIBCURL_OPTION
       if(global->libcurl) {
         /* Initialise the libcurl source output */
         result = easysrc_init();
       }
-#endif
 
       /* Perform the main operations */
       if(!result) {
@@ -2708,12 +2705,10 @@ CURLcode operate(struct GlobalConfig *global, int argc, argv_item_t argv[])
         struct OperationConfig *operation = global->first;
         CURLSH *share = curl_share_init();
         if(!share) {
-#ifndef CURL_DISABLE_LIBCURL_OPTION
           if(global->libcurl) {
             /* Cleanup the libcurl source output */
             easysrc_cleanup();
           }
-#endif
           return CURLE_OUT_OF_MEMORY;
         }
 
@@ -2737,7 +2732,6 @@ CURLcode operate(struct GlobalConfig *global, int argc, argv_item_t argv[])
         result = run_all_transfers(global, share, result);
 
         curl_share_cleanup(share);
-#ifndef CURL_DISABLE_LIBCURL_OPTION
         if(global->libcurl) {
           /* Cleanup the libcurl source output */
           easysrc_cleanup();
@@ -2745,7 +2739,6 @@ CURLcode operate(struct GlobalConfig *global, int argc, argv_item_t argv[])
           /* Dump the libcurl code if previously enabled */
           dumpeasysrc(global);
         }
-#endif
       }
       else
         errorf(global, "out of memory\n");