]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
src: fix potential macro confusion in cmake unity builds
authorViktor Szakats <commit@vsz.me>
Wed, 21 Aug 2024 11:36:29 +0000 (13:36 +0200)
committerViktor Szakats <commit@vsz.me>
Thu, 22 Aug 2024 08:45:04 +0000 (10:45 +0200)
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

42 files changed:
lib/curlx.h
src/tool_cb_dbg.c
src/tool_cb_hdr.c
src/tool_cb_prg.c
src/tool_cb_rea.c
src/tool_cb_see.c
src/tool_cb_wrt.c
src/tool_dirhie.c
src/tool_easysrc.c
src/tool_formparse.c
src/tool_getparam.c
src/tool_help.c
src/tool_helpers.c
src/tool_ipfs.c
src/tool_libinfo.c
src/tool_main.c
src/tool_msgs.c
src/tool_operate.c
src/tool_operhlp.c
src/tool_paramhlp.c
src/tool_parsecfg.c
src/tool_progress.c
src/tool_setopt.c
src/tool_urlglob.c
src/tool_vms.c
src/tool_writeout.c
src/tool_writeout_json.c
src/var.c
tests/server/fake_ntlm.c
tests/server/getpart.c
tests/server/mqttd.c
tests/server/resolve.c
tests/server/rtspd.c
tests/server/sockfilt.c
tests/server/socksd.c
tests/server/sws.c
tests/server/tftpd.c
tests/server/util.c
tests/unit/unit1305.c
tests/unit/unit1602.c
tests/unit/unit1603.c
tests/unit/unit1616.c

index fa6d9eb7a6a3d3af5cf5bc749b0e38274b269a09..7e2e8dea0f029237c227c945e2562d099be04d9d 100644 (file)
 #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
 # define mvsnprintf curlx_mvsnprintf
 # define aprintf curlx_maprintf
 # define vaprintf curlx_mvaprintf
-#endif /* ENABLE_CURLX_PRINTF */
 
 #endif /* HEADER_CURL_CURLX_H */
index dd2a124ad7082910b119a0568a3d40c2ed0afbf4..6d2a6178358336e2551f58e71b866cb8f9ee743d 100644 (file)
@@ -23,8 +23,6 @@
  ***************************************************************************/
 #include "tool_setup.h"
 
-#define ENABLE_CURLX_PRINTF
-/* use our own printf() functions */
 #include "curlx.h"
 
 #include "tool_cfgable.h"
index 96b6fabb7c3028b59c6cb2aca4a56bbb5b01f2cd..969acac1e4144c6c3cfd9e05f5dbe460483c5d84 100644 (file)
@@ -28,8 +28,6 @@
 #include <unistd.h>
 #endif
 
-#define ENABLE_CURLX_PRINTF
-/* use our own printf() functions */
 #include "curlx.h"
 
 #include "tool_cfgable.h"
index df2e19aaa6372b2c008d74e89b7f6fb0d1d9bd84..5acd3fcc78fc499865b462509c94e7e5b5672329 100644 (file)
@@ -23,8 +23,6 @@
  ***************************************************************************/
 #include "tool_setup.h"
 
-#define ENABLE_CURLX_PRINTF
-/* use our own printf() functions */
 #include "curlx.h"
 
 #include "tool_cfgable.h"
index 1e23895ca5884306cb830bd9c9e8bf071fa54854..0fe40143007fb4d76628776087ef3c23b2477725 100644 (file)
@@ -27,8 +27,6 @@
 #include <sys/select.h>
 #endif
 
-#define ENABLE_CURLX_PRINTF
-/* use our own printf() functions */
 #include "curlx.h"
 
 #include "tool_cfgable.h"
index fdd1f1f72c3c546fa7c788aecb840ec8ab144654..a425ebe9de7daa54a1d58c2d1060fcf9ec94c6e6 100644 (file)
@@ -23,8 +23,6 @@
  ***************************************************************************/
 #include "tool_setup.h"
 
-#define ENABLE_CURLX_PRINTF
-/* use our own printf() functions */
 #include "curlx.h"
 
 #include "tool_cfgable.h"
index 370847753a2db1bb23d7495cd1c19c6d3d90cd4d..05f4b0e4a9fbbf229af2e2517d6652d17f87f79b 100644 (file)
@@ -30,8 +30,6 @@
 
 #include <sys/stat.h>
 
-#define ENABLE_CURLX_PRINTF
-/* use our own printf() functions */
 #include "curlx.h"
 
 #include "tool_cfgable.h"
index 0efdc398c77ada19293d499c84906f49ac673e37..772664c5fb49cd456a8f8516f95c24c2da420d1a 100644 (file)
@@ -29,8 +29,6 @@
 #  include <direct.h>
 #endif
 
-#define ENABLE_CURLX_PRINTF
-/* use our own printf() functions */
 #include "curlx.h"
 
 #include "tool_dirhie.h"
index 6ef2be721cfd4d475494bd9254240aeca0d22a84..761f7ebcad6df0b95be375bc8549f2a46d0a400d 100644 (file)
@@ -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"
index 61f88396ccb15bc27a31ebc65dfebdd4db2c6416..15918d3ee517eec11d66e4a6ccaff76f76fcf414 100644 (file)
@@ -25,8 +25,6 @@
 
 #include "strcase.h"
 
-#define ENABLE_CURLX_PRINTF
-/* use our own printf() functions */
 #include "curlx.h"
 
 #include "tool_cfgable.h"
index 411a349304a3b0cb9beabaae8896c3f268a9f40d..d044e8386b45e4b78a462f4875eb44f9f5a3aec8 100644 (file)
@@ -25,8 +25,6 @@
 
 #include "strcase.h"
 
-#define ENABLE_CURLX_PRINTF
-/* use our own printf() functions */
 #include "curlx.h"
 
 #include "tool_binmode.h"
index 3e21efd7a7d9fbb9956a9fe260319dcaccbabe0b..8c655c4b2b22994a59932edae99de6c1eff862b8 100644 (file)
@@ -22,8 +22,7 @@
  *
  ***************************************************************************/
 #include "tool_setup.h"
-#define ENABLE_CURLX_PRINTF
-/* use our own printf() functions */
+
 #include "curlx.h"
 
 #include "tool_help.h"
index 0f9ac45a8d0dab34f8e5ddd59bdd62fc879b5eaf..ac38a15c209c032e6932c52a140803c7be38ceb6 100644 (file)
@@ -25,8 +25,6 @@
 
 #include "strcase.h"
 
-#define ENABLE_CURLX_PRINTF
-/* use our own printf() functions */
 #include "curlx.h"
 
 #include "tool_cfgable.h"
index 62ef9f604ac684c0e28f36661104af0b1a599ec3..09bff49067a270c7411c72a2798a43b47e66b6a1 100644 (file)
@@ -23,8 +23,6 @@
  ***************************************************************************/
 #include "tool_setup.h"
 
-#define ENABLE_CURLX_PRINTF
-/* use our own printf() functions */
 #include "curlx.h"
 #include "dynbuf.h"
 
index 8b006894fd9f82f21f57a6a2a052a41b9c29850e..4bc22217f9dce5e0a3de0e0746d97c6e3c345a6b 100644 (file)
@@ -25,8 +25,6 @@
 
 #include "strcase.h"
 
-#define ENABLE_CURLX_PRINTF
-/* use our own printf() functions */
 #include "curlx.h"
 
 #include "tool_libinfo.h"
index 9d7d1991acb054a32039e39f68e42a69359f995f..01993123e25b1f254da31d12948566e2eafd0cf2 100644 (file)
@@ -35,8 +35,6 @@
 #include <fcntl.h>
 #endif
 
-#define ENABLE_CURLX_PRINTF
-/* use our own printf() functions */
 #include "curlx.h"
 
 #include "tool_cfgable.h"
index 47e625c1e3f05a4f215476d1424a3c6860c73b17..e74fa107583038449a6c543052a5650dada4bda6 100644 (file)
@@ -23,8 +23,6 @@
  ***************************************************************************/
 #include "tool_setup.h"
 
-#define ENABLE_CURLX_PRINTF
-/* use our own printf() functions */
 #include "curlx.h"
 
 #include "tool_cfgable.h"
index 681c83e714de39258d82339e497d049874a5ae02..05d0420f2389b4c7d4df7781c8d59560a2d41b5f 100644 (file)
@@ -60,8 +60,6 @@
 #include <uv.h>
 #endif
 
-#define ENABLE_CURLX_PRINTF
-/* use our own printf() functions */
 #include "curlx.h"
 
 #include "tool_binmode.h"
index be5bc0a260e2a704fbe9d7d1dd529be974568a8c..7dce5ff0ccdf2d36f7b27799f9c50830230d20b4 100644 (file)
@@ -26,8 +26,6 @@
 
 #include "strcase.h"
 
-#define ENABLE_CURLX_PRINTF
-/* use our own printf() functions */
 #include "curlx.h"
 
 #include "tool_cfgable.h"
index 84b150cc429042bebabe6df3018b8aba9c4f98c0..3990c7d1556f4d9514e5e48d84364d8d2511910e 100644 (file)
@@ -25,8 +25,6 @@
 
 #include "strcase.h"
 
-#define ENABLE_CURLX_PRINTF
-/* use our own printf() functions */
 #include "curlx.h"
 
 #include "tool_cfgable.h"
index ad67f540fcb68378ed62474d5ff20155ffde9094..6da5a92500b69f7f293fbaf7a866314bc8d98d12 100644 (file)
@@ -23,8 +23,6 @@
  ***************************************************************************/
 #include "tool_setup.h"
 
-#define ENABLE_CURLX_PRINTF
-/* use our own printf() functions */
 #include "curlx.h"
 
 #include "tool_cfgable.h"
index cf3e4c2f67ded6bf362a4ec46c374cbb7c1c52b2..3fac70a70e13903d54b6f9c6c22cab93609dfd64 100644 (file)
@@ -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,
index 4ec1016570a78876d9fd3d03c82aa4c877770920..52ae0f9607477dc95a1b780abdc5542f5f966238 100644 (file)
@@ -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"
index 7c43b26c3106f497dddd40a4ff77949334d4b439..35f472d4f2cfcf4b543be7197c473ea174794641 100644 (file)
@@ -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"
index 9860e16e5baa93055cf50dd9151dd7f6e8c4328b..8ac9fc409e80b83c7565d70d4810e239ef153d75 100644 (file)
@@ -30,7 +30,6 @@
 #include <unixlib.h>
 #endif
 
-#define ENABLE_CURLX_PRINTF
 #include "curlx.h"
 
 #include "curlmsg_vms.h"
index fed81acb0b808eb9ccfd80d407a4b5c9a6396866..141178c332abcd1e70dd56b4ffb2f16551fe6afb 100644 (file)
@@ -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"
index feb791da9a3300f3782f05cfc697943708801296..205b702ae1fc996f031eba8673672224564ea403 100644 (file)
@@ -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"
index fb028667d441a377a4f1d77c7cce340cf6f9badf..dbcef3c1162a1d5817e891726ba542343b770062 100644 (file)
--- 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"
index 6693450357bfcec2e17605dc0eac64dfe28e4922..4c02e69fe5f4270d00a74862fe9272d65fe77d6e 100644 (file)
@@ -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"
index 971e5b978307ecc287dfea8b31bf4627de610f31..378c04acf088c22d61fb7fc4232d84aa6c696333 100644 (file)
@@ -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 */
index 6e24f5cc24e6a06229676ab6e796b78d60067d36..12dd91c38f043a3eb9d6242d63faead60366acc6 100644 (file)
@@ -54,9 +54,6 @@
 #include <netdb.h>
 #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"
index 9e0345272f4162f68362ec521307bd59faded9f7..cf59d48ea5e8a32853acf21aef1d804f4c7513a0 100644 (file)
@@ -45,9 +45,6 @@
 #include <netdb.h>
 #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"
 
index a39c8c890ef1f5b543f3a7b6ce942295e097ea73..5868c3438309de81ca8da35cea9fb666208bcfd4 100644 (file)
@@ -46,9 +46,6 @@
 #include <netinet/tcp.h> /* 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"
index aefa74168206f57449a2eafd00053e808512101b..8735b45c848b4cc8bda18e1485e60074cea9af27 100644 (file)
@@ -99,9 +99,6 @@
 #include <netdb.h>
 #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"
index d2de40082f832df7c4a5526768634255935fe2ea..09dd9c3c3cbb822eb46656ebda14c945c16d9e3a 100644 (file)
@@ -71,9 +71,6 @@
 #include <netdb.h>
 #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"
index 94fb48cc1c44c0a49ee2e81e7598a76e68510f42..9468acce4c37a627578d902eaf6b2e61a37bd0c8 100644 (file)
@@ -47,9 +47,6 @@
 #include <netinet/tcp.h> /* 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"
index bda44a9d362b6376b07463f75e94ed5035157403..3961ce22cd4e4fe6daa2fcc8f639761c54d78938 100644 (file)
@@ -81,9 +81,6 @@
 
 #include <ctype.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 */
 #include "getpart.h"
 #include "util.h"
index 56a68b7f61748ff5039d1efbd554f470468b055f..b38d9f058f53d653c93f73ad0c7582d9153decf9 100644 (file)
@@ -40,9 +40,6 @@
 #include <sys/poll.h>
 #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"
index c446d8fe6a90247a4f48768c8454def6cd3a5f41..ad8c85c442ba7c42d4cee0e5c98c85d5095be7a5 100644 (file)
@@ -33,7 +33,6 @@
 #  include <arpa/inet.h>
 #endif
 
-#define ENABLE_CURLX_PRINTF
 #include "curlx.h"
 
 #include "hash.h"
index f7dc4a212d3f7f71bbe2968b37334f02e48566aa..4c7b794ab8389f0ede7975285ff0e0cc9b445c9d 100644 (file)
@@ -23,7 +23,6 @@
  ***************************************************************************/
 #include "curlcheck.h"
 
-#define ENABLE_CURLX_PRINTF
 #include "curlx.h"
 
 #include "hash.h"
index 44f9b880ad12a3a1a0d9635cd7d1667c8605b423..46492424c565a694bf61dfec8786b24a8e8d82f7 100644 (file)
@@ -23,7 +23,6 @@
  ***************************************************************************/
 #include "curlcheck.h"
 
-#define ENABLE_CURLX_PRINTF
 #include "curlx.h"
 
 #include "hash.h"
index 8f988657aa74f15634c622e678a97c015fd7393a..6bccdb9cae86ce1785c009acd76b512f1ae602d0 100644 (file)
@@ -23,7 +23,6 @@
  ***************************************************************************/
 #include "curlcheck.h"
 
-#define ENABLE_CURLX_PRINTF
 #include "curlx.h"
 
 #include "hash.h"