]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
src: guard for double declaration of `curl_ca_embed` in unity builds
authorViktor Szakats <commit@vsz.me>
Wed, 16 Oct 2024 10:14:52 +0000 (12:14 +0200)
committerViktor Szakats <commit@vsz.me>
Wed, 16 Oct 2024 15:27:56 +0000 (17:27 +0200)
Seen with curl-for-win linux-musl-from-mac build with gcc 9.2.0.

```
n file included from /Users/runner/work/curl-for-win/curl-for-win/curl/_x64-linux-musl-bld/src/CMakeFiles/curl.dir/Unity/unity_0_c.c:136:
/Users/runner/work/curl-for-win/curl-for-win/curl/_x64-linux-musl-bld/src/tool_ca_embed.c:4:28: warning: redundant redeclaration of 'curl_ca_embed' [-Wredundant-decls]
    4 | extern const unsigned char curl_ca_embed[];
      |                            ^~~~~~~~~~~~~
In file included from /Users/runner/work/curl-for-win/curl-for-win/curl/_x64-linux-musl-bld/src/CMakeFiles/curl.dir/Unity/unity_0_c.c:88:
/Users/runner/work/curl-for-win/curl-for-win/curl/src/tool_operate.c:107:28: note: previous declaration of 'curl_ca_embed' was here
  107 | extern const unsigned char curl_ca_embed[];
      |                            ^~~~~~~~~~~~~
```
https://github.com/curl/curl-for-win/actions/runs/11192203640/job/31116070669#step:3:4894

Follow-up to 8a3740bc8e558b9a9d4a652b74cf27a0961d7010 #14059
Closes #15307

src/mk-file-embed.pl
src/tool_operate.c

index 3447aa9472b717321d27b948d2780de2e877f2e9..e4dbe35de1acdcf1283b4e3fbae1ca6f606a013a 100755 (executable)
@@ -29,11 +29,16 @@ if($ARGV[0] eq "--var") {
     $varname = shift @ARGV;
 }
 
+my $varname_upper = uc($varname);
+
 print <<HEAD
 /*
  * NEVER EVER edit this manually, fix the mk-file-embed.pl script instead!
  */
+#ifndef CURL_DECLARED_${varname_upper}
+#define CURL_DECLARED_${varname_upper}
 extern const unsigned char ${varname}[];
+#endif
 const unsigned char ${varname}[] = {
 HEAD
     ;
index ed5ab4d6c86c57c2ac3f9a96761d8c7519449325..5aadf26d23f6e91d45e79a209c2494b538116913 100644 (file)
@@ -105,8 +105,11 @@ CURL_EXTERN CURLcode curl_easy_perform_ev(CURL *easy);
 #include "memdebug.h" /* keep this as LAST include */
 
 #ifdef CURL_CA_EMBED
+#ifndef CURL_DECLARED_CURL_CA_EMBED
+#define CURL_DECLARED_CURL_CA_EMBED
 extern const unsigned char curl_ca_embed[];
 #endif
+#endif
 
 #ifndef O_BINARY
 /* since O_BINARY as used in bitmasks, setting it to zero makes it usable in