From: Viktor Szakats Date: Wed, 21 Aug 2024 11:36:29 +0000 (+0200) Subject: src: fix potential macro confusion in cmake unity builds X-Git-Tag: curl-8_10_0~162 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c04504885d947c8e5756d450b93c2faaf9daa372;p=thirdparty%2Fcurl.git src: fix potential macro confusion in cmake unity builds Sources used `lib/curlx.h` with both `ENABLE_CURLX_PRINTF` set and unset before including it. In a cmake "unity" batch where the first included source had it unset, the next sources did not get the macros requested with `ENABLE_CURLX_PRINTF` because `lib/curl.x` had already been included without them. Fix it by by making the macros enabled permanently and globally for internal sources, and dropping `ENABLE_CURLX_PRINTF`. This came up while testing unity builds with smaller batches. The full, default unity build where all `src` is bundled up in a single unit, was not affected. Fixes: ``` $ cmake -B build -DCMAKE_UNITY_BUILD=ON -DCMAKE_UNITY_BUILD_BATCH_SIZE=15 $ make -C build ... curl/src/tool_getparam.c: In function ‘getparameter’: curl/src/tool_getparam.c:2409:11: error: implicit declaration of function ‘msnprintf’; did you mean ‘vsnprintf’? [-Wimplicit-function-declaration] 2409 | msnprintf(buffer, sizeof(buffer), "%" CURL_FORMAT_CURL_OFF_T "-", | ^~~~~~~~~ | vsnprintf curl/src/tool_getparam.c:2409:11: warning: nested extern declaration of ‘msnprintf’ [-Wnested-externs] [...] ``` Reported-by: Daniel Stenberg Bug: https://github.com/curl/curl/pull/14626#issuecomment-2301663491 Closes #14632 --- diff --git a/lib/curlx.h b/lib/curlx.h index fa6d9eb7a6..7e2e8dea0f 100644 --- a/lib/curlx.h +++ b/lib/curlx.h @@ -88,10 +88,9 @@ #define curlx_mvprintf curl_mvprintf #define curlx_mvfprintf curl_mvfprintf -#ifdef ENABLE_CURLX_PRINTF -/* If this define is set, we define all "standard" printf() functions to use - the curlx_* version instead. It makes the source code transparent and - easier to understand/patch. Undefine them first. */ +/* We define all "standard" printf() functions to use the curlx_* version + instead. It makes the source code transparent and easier to + understand/patch. Undefine them first. */ # undef printf # undef fprintf # undef sprintf @@ -111,6 +110,5 @@ # define mvsnprintf curlx_mvsnprintf # define aprintf curlx_maprintf # define vaprintf curlx_mvaprintf -#endif /* ENABLE_CURLX_PRINTF */ #endif /* HEADER_CURL_CURLX_H */ diff --git a/src/tool_cb_dbg.c b/src/tool_cb_dbg.c index dd2a124ad7..6d2a617835 100644 --- a/src/tool_cb_dbg.c +++ b/src/tool_cb_dbg.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "tool_setup.h" -#define ENABLE_CURLX_PRINTF -/* use our own printf() functions */ #include "curlx.h" #include "tool_cfgable.h" diff --git a/src/tool_cb_hdr.c b/src/tool_cb_hdr.c index 96b6fabb7c..969acac1e4 100644 --- a/src/tool_cb_hdr.c +++ b/src/tool_cb_hdr.c @@ -28,8 +28,6 @@ #include #endif -#define ENABLE_CURLX_PRINTF -/* use our own printf() functions */ #include "curlx.h" #include "tool_cfgable.h" diff --git a/src/tool_cb_prg.c b/src/tool_cb_prg.c index df2e19aaa6..5acd3fcc78 100644 --- a/src/tool_cb_prg.c +++ b/src/tool_cb_prg.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "tool_setup.h" -#define ENABLE_CURLX_PRINTF -/* use our own printf() functions */ #include "curlx.h" #include "tool_cfgable.h" diff --git a/src/tool_cb_rea.c b/src/tool_cb_rea.c index 1e23895ca5..0fe4014300 100644 --- a/src/tool_cb_rea.c +++ b/src/tool_cb_rea.c @@ -27,8 +27,6 @@ #include #endif -#define ENABLE_CURLX_PRINTF -/* use our own printf() functions */ #include "curlx.h" #include "tool_cfgable.h" diff --git a/src/tool_cb_see.c b/src/tool_cb_see.c index fdd1f1f72c..a425ebe9de 100644 --- a/src/tool_cb_see.c +++ b/src/tool_cb_see.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "tool_setup.h" -#define ENABLE_CURLX_PRINTF -/* use our own printf() functions */ #include "curlx.h" #include "tool_cfgable.h" diff --git a/src/tool_cb_wrt.c b/src/tool_cb_wrt.c index 370847753a..05f4b0e4a9 100644 --- a/src/tool_cb_wrt.c +++ b/src/tool_cb_wrt.c @@ -30,8 +30,6 @@ #include -#define ENABLE_CURLX_PRINTF -/* use our own printf() functions */ #include "curlx.h" #include "tool_cfgable.h" diff --git a/src/tool_dirhie.c b/src/tool_dirhie.c index 0efdc398c7..772664c5fb 100644 --- a/src/tool_dirhie.c +++ b/src/tool_dirhie.c @@ -29,8 +29,6 @@ # include #endif -#define ENABLE_CURLX_PRINTF -/* use our own printf() functions */ #include "curlx.h" #include "tool_dirhie.h" diff --git a/src/tool_easysrc.c b/src/tool_easysrc.c index 6ef2be721c..761f7ebcad 100644 --- a/src/tool_easysrc.c +++ b/src/tool_easysrc.c @@ -27,8 +27,6 @@ #ifndef CURL_DISABLE_LIBCURL_OPTION -#define ENABLE_CURLX_PRINTF -/* use our own printf() functions */ #include "curlx.h" #include "tool_cfgable.h" diff --git a/src/tool_formparse.c b/src/tool_formparse.c index 61f88396cc..15918d3ee5 100644 --- a/src/tool_formparse.c +++ b/src/tool_formparse.c @@ -25,8 +25,6 @@ #include "strcase.h" -#define ENABLE_CURLX_PRINTF -/* use our own printf() functions */ #include "curlx.h" #include "tool_cfgable.h" diff --git a/src/tool_getparam.c b/src/tool_getparam.c index 411a349304..d044e8386b 100644 --- a/src/tool_getparam.c +++ b/src/tool_getparam.c @@ -25,8 +25,6 @@ #include "strcase.h" -#define ENABLE_CURLX_PRINTF -/* use our own printf() functions */ #include "curlx.h" #include "tool_binmode.h" diff --git a/src/tool_help.c b/src/tool_help.c index 3e21efd7a7..8c655c4b2b 100644 --- a/src/tool_help.c +++ b/src/tool_help.c @@ -22,8 +22,7 @@ * ***************************************************************************/ #include "tool_setup.h" -#define ENABLE_CURLX_PRINTF -/* use our own printf() functions */ + #include "curlx.h" #include "tool_help.h" diff --git a/src/tool_helpers.c b/src/tool_helpers.c index 0f9ac45a8d..ac38a15c20 100644 --- a/src/tool_helpers.c +++ b/src/tool_helpers.c @@ -25,8 +25,6 @@ #include "strcase.h" -#define ENABLE_CURLX_PRINTF -/* use our own printf() functions */ #include "curlx.h" #include "tool_cfgable.h" diff --git a/src/tool_ipfs.c b/src/tool_ipfs.c index 62ef9f604a..09bff49067 100644 --- a/src/tool_ipfs.c +++ b/src/tool_ipfs.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "tool_setup.h" -#define ENABLE_CURLX_PRINTF -/* use our own printf() functions */ #include "curlx.h" #include "dynbuf.h" diff --git a/src/tool_libinfo.c b/src/tool_libinfo.c index 8b006894fd..4bc22217f9 100644 --- a/src/tool_libinfo.c +++ b/src/tool_libinfo.c @@ -25,8 +25,6 @@ #include "strcase.h" -#define ENABLE_CURLX_PRINTF -/* use our own printf() functions */ #include "curlx.h" #include "tool_libinfo.h" diff --git a/src/tool_main.c b/src/tool_main.c index 9d7d1991ac..01993123e2 100644 --- a/src/tool_main.c +++ b/src/tool_main.c @@ -35,8 +35,6 @@ #include #endif -#define ENABLE_CURLX_PRINTF -/* use our own printf() functions */ #include "curlx.h" #include "tool_cfgable.h" diff --git a/src/tool_msgs.c b/src/tool_msgs.c index 47e625c1e3..e74fa10758 100644 --- a/src/tool_msgs.c +++ b/src/tool_msgs.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "tool_setup.h" -#define ENABLE_CURLX_PRINTF -/* use our own printf() functions */ #include "curlx.h" #include "tool_cfgable.h" diff --git a/src/tool_operate.c b/src/tool_operate.c index 681c83e714..05d0420f23 100644 --- a/src/tool_operate.c +++ b/src/tool_operate.c @@ -60,8 +60,6 @@ #include #endif -#define ENABLE_CURLX_PRINTF -/* use our own printf() functions */ #include "curlx.h" #include "tool_binmode.h" diff --git a/src/tool_operhlp.c b/src/tool_operhlp.c index be5bc0a260..7dce5ff0cc 100644 --- a/src/tool_operhlp.c +++ b/src/tool_operhlp.c @@ -26,8 +26,6 @@ #include "strcase.h" -#define ENABLE_CURLX_PRINTF -/* use our own printf() functions */ #include "curlx.h" #include "tool_cfgable.h" diff --git a/src/tool_paramhlp.c b/src/tool_paramhlp.c index 84b150cc42..3990c7d155 100644 --- a/src/tool_paramhlp.c +++ b/src/tool_paramhlp.c @@ -25,8 +25,6 @@ #include "strcase.h" -#define ENABLE_CURLX_PRINTF -/* use our own printf() functions */ #include "curlx.h" #include "tool_cfgable.h" diff --git a/src/tool_parsecfg.c b/src/tool_parsecfg.c index ad67f540fc..6da5a92500 100644 --- a/src/tool_parsecfg.c +++ b/src/tool_parsecfg.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "tool_setup.h" -#define ENABLE_CURLX_PRINTF -/* use our own printf() functions */ #include "curlx.h" #include "tool_cfgable.h" diff --git a/src/tool_progress.c b/src/tool_progress.c index cf3e4c2f67..3fac70a70e 100644 --- a/src/tool_progress.c +++ b/src/tool_progress.c @@ -26,8 +26,6 @@ #include "tool_progress.h" #include "tool_util.h" -#define ENABLE_CURLX_PRINTF -/* use our own printf() functions */ #include "curlx.h" /* The point of this function would be to return a string of the input data, diff --git a/src/tool_setopt.c b/src/tool_setopt.c index 4ec1016570..52ae0f9607 100644 --- a/src/tool_setopt.c +++ b/src/tool_setopt.c @@ -25,8 +25,6 @@ #ifndef CURL_DISABLE_LIBCURL_OPTION -#define ENABLE_CURLX_PRINTF -/* use our own printf() functions */ #include "curlx.h" #include "tool_cfgable.h" diff --git a/src/tool_urlglob.c b/src/tool_urlglob.c index 7c43b26c31..35f472d4f2 100644 --- a/src/tool_urlglob.c +++ b/src/tool_urlglob.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "tool_setup.h" -#define ENABLE_CURLX_PRINTF -/* use our own printf() functions */ #include "curlx.h" #include "tool_cfgable.h" #include "tool_doswin.h" diff --git a/src/tool_vms.c b/src/tool_vms.c index 9860e16e5b..8ac9fc409e 100644 --- a/src/tool_vms.c +++ b/src/tool_vms.c @@ -30,7 +30,6 @@ #include #endif -#define ENABLE_CURLX_PRINTF #include "curlx.h" #include "curlmsg_vms.h" diff --git a/src/tool_writeout.c b/src/tool_writeout.c index fed81acb0b..141178c332 100644 --- a/src/tool_writeout.c +++ b/src/tool_writeout.c @@ -22,8 +22,7 @@ * ***************************************************************************/ #include "tool_setup.h" -#define ENABLE_CURLX_PRINTF -/* use our own printf() functions */ + #include "curlx.h" #include "tool_cfgable.h" #include "tool_writeout.h" diff --git a/src/tool_writeout_json.c b/src/tool_writeout_json.c index feb791da9a..205b702ae1 100644 --- a/src/tool_writeout_json.c +++ b/src/tool_writeout_json.c @@ -23,9 +23,6 @@ ***************************************************************************/ #include "tool_setup.h" -#define ENABLE_CURLX_PRINTF - -/* use our own printf() functions */ #include "curlx.h" #include "tool_cfgable.h" #include "tool_writeout_json.h" diff --git a/src/var.c b/src/var.c index fb028667d4..dbcef3c116 100644 --- a/src/var.c +++ b/src/var.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "tool_setup.h" -#define ENABLE_CURLX_PRINTF -/* use our own printf() functions */ #include "curlx.h" #include "tool_cfgable.h" diff --git a/tests/server/fake_ntlm.c b/tests/server/fake_ntlm.c index 6693450357..4c02e69fe5 100644 --- a/tests/server/fake_ntlm.c +++ b/tests/server/fake_ntlm.c @@ -31,7 +31,6 @@ * responses with a pre-written string saved in test case test2005. */ -#define ENABLE_CURLX_PRINTF #include "curlx.h" /* from the private lib dir */ #include "getpart.h" #include "util.h" diff --git a/tests/server/getpart.c b/tests/server/getpart.c index 971e5b9783..378c04acf0 100644 --- a/tests/server/getpart.c +++ b/tests/server/getpart.c @@ -25,9 +25,6 @@ #include "getpart.h" -#define ENABLE_CURLX_PRINTF -/* make the curlx header define all printf() functions to use the curlx_* - versions instead */ #include "curlx.h" /* from the private lib dir */ /* just to please curl_base64.h we create a fake struct */ diff --git a/tests/server/mqttd.c b/tests/server/mqttd.c index 6e24f5cc24..12dd91c38f 100644 --- a/tests/server/mqttd.c +++ b/tests/server/mqttd.c @@ -54,9 +54,6 @@ #include #endif -#define ENABLE_CURLX_PRINTF -/* make the curlx header define all printf() functions to use the curlx_* - versions instead */ #include "curlx.h" /* from the private lib dir */ #include "getpart.h" #include "inet_pton.h" diff --git a/tests/server/resolve.c b/tests/server/resolve.c index 9e0345272f..cf59d48ea5 100644 --- a/tests/server/resolve.c +++ b/tests/server/resolve.c @@ -45,9 +45,6 @@ #include #endif -#define ENABLE_CURLX_PRINTF -/* make the curlx header define all printf() functions to use the curlx_* - versions instead */ #include "curlx.h" /* from the private lib dir */ #include "util.h" diff --git a/tests/server/rtspd.c b/tests/server/rtspd.c index a39c8c890e..5868c34383 100644 --- a/tests/server/rtspd.c +++ b/tests/server/rtspd.c @@ -46,9 +46,6 @@ #include /* for TCP_NODELAY */ #endif -#define ENABLE_CURLX_PRINTF -/* make the curlx header define all printf() functions to use the curlx_* - versions instead */ #include "curlx.h" /* from the private lib dir */ #include "getpart.h" #include "util.h" diff --git a/tests/server/sockfilt.c b/tests/server/sockfilt.c index aefa741682..8735b45c84 100644 --- a/tests/server/sockfilt.c +++ b/tests/server/sockfilt.c @@ -99,9 +99,6 @@ #include #endif -#define ENABLE_CURLX_PRINTF -/* make the curlx header define all printf() functions to use the curlx_* - versions instead */ #include "curlx.h" /* from the private lib dir */ #include "getpart.h" #include "inet_pton.h" diff --git a/tests/server/socksd.c b/tests/server/socksd.c index d2de40082f..09dd9c3c3c 100644 --- a/tests/server/socksd.c +++ b/tests/server/socksd.c @@ -71,9 +71,6 @@ #include #endif -#define ENABLE_CURLX_PRINTF -/* make the curlx header define all printf() functions to use the curlx_* - versions instead */ #include "curlx.h" /* from the private lib dir */ #include "getpart.h" #include "inet_pton.h" diff --git a/tests/server/sws.c b/tests/server/sws.c index 94fb48cc1c..9468acce4c 100644 --- a/tests/server/sws.c +++ b/tests/server/sws.c @@ -47,9 +47,6 @@ #include /* for TCP_NODELAY */ #endif -#define ENABLE_CURLX_PRINTF -/* make the curlx header define all printf() functions to use the curlx_* - versions instead */ #include "curlx.h" /* from the private lib dir */ #include "getpart.h" #include "inet_pton.h" diff --git a/tests/server/tftpd.c b/tests/server/tftpd.c index bda44a9d36..3961ce22cd 100644 --- a/tests/server/tftpd.c +++ b/tests/server/tftpd.c @@ -81,9 +81,6 @@ #include -#define ENABLE_CURLX_PRINTF -/* make the curlx header define all printf() functions to use the curlx_* - versions instead */ #include "curlx.h" /* from the private lib dir */ #include "getpart.h" #include "util.h" diff --git a/tests/server/util.c b/tests/server/util.c index 56a68b7f61..b38d9f058f 100644 --- a/tests/server/util.c +++ b/tests/server/util.c @@ -40,9 +40,6 @@ #include #endif -#define ENABLE_CURLX_PRINTF -/* make the curlx header define all printf() functions to use the curlx_* - versions instead */ #include "curlx.h" /* from the private lib dir */ #include "getpart.h" #include "util.h" diff --git a/tests/unit/unit1305.c b/tests/unit/unit1305.c index c446d8fe6a..ad8c85c442 100644 --- a/tests/unit/unit1305.c +++ b/tests/unit/unit1305.c @@ -33,7 +33,6 @@ # include #endif -#define ENABLE_CURLX_PRINTF #include "curlx.h" #include "hash.h" diff --git a/tests/unit/unit1602.c b/tests/unit/unit1602.c index f7dc4a212d..4c7b794ab8 100644 --- a/tests/unit/unit1602.c +++ b/tests/unit/unit1602.c @@ -23,7 +23,6 @@ ***************************************************************************/ #include "curlcheck.h" -#define ENABLE_CURLX_PRINTF #include "curlx.h" #include "hash.h" diff --git a/tests/unit/unit1603.c b/tests/unit/unit1603.c index 44f9b880ad..46492424c5 100644 --- a/tests/unit/unit1603.c +++ b/tests/unit/unit1603.c @@ -23,7 +23,6 @@ ***************************************************************************/ #include "curlcheck.h" -#define ENABLE_CURLX_PRINTF #include "curlx.h" #include "hash.h" diff --git a/tests/unit/unit1616.c b/tests/unit/unit1616.c index 8f988657aa..6bccdb9cae 100644 --- a/tests/unit/unit1616.c +++ b/tests/unit/unit1616.c @@ -23,7 +23,6 @@ ***************************************************************************/ #include "curlcheck.h" -#define ENABLE_CURLX_PRINTF #include "curlx.h" #include "hash.h"