]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
cmake: fix `HAVE_GETHOSTBYNAME_R_*` detections with `CURL_WERROR=ON`
authorViktor Szakats <commit@vsz.me>
Mon, 10 Feb 2025 04:57:49 +0000 (05:57 +0100)
committerViktor Szakats <commit@vsz.me>
Mon, 10 Feb 2025 11:54:11 +0000 (12:54 +0100)
Fix `HAVE_GETHOSTBYNAME_R_*` feature detections always failing with
`CURL_WERROR=ON` due to stripping a const.

Also fix the GHA/cmake-vs-configure to enable `CURL_WERROR=ON` to sync
this setting with `./configure` which enables it by default. With that,
CI detects this issue.

```
CMake/CurlTests.c:73:19: error: initialization discards â€˜const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
   73 |   char *address = "example.com";
      |                   ^~~~~~~~~~~~~
```
Ref: https://github.com/curl/curl/actions/runs/13225827821/job/36916564107#step:33:4198

Closes #16282

.github/workflows/configure-vs-cmake.yml
CMake/CurlTests.c

index dfe2ed622f506e05b2b13f6a989cc15e94dc0c91..7130c7e6d47257c49bb9cb8863960b2e3d852508 100644 (file)
@@ -48,7 +48,7 @@ jobs:
 
       - name: 'run cmake'
         run: |
-          cmake -B bld-cm -DCURL_USE_LIBPSL=OFF -DCURL_BROTLI=OFF
+          cmake -B bld-cm -DCURL_WERROR=ON -DCURL_USE_LIBPSL=OFF -DCURL_BROTLI=OFF
 
       - name: 'configure log'
         run: cat bld-am/config.log 2>/dev/null || true
@@ -88,7 +88,7 @@ jobs:
 
       - name: 'run cmake'
         run: |
-          cmake -B bld-cm -DCURL_USE_LIBPSL=OFF -DCURL_DISABLE_LDAP=ON \
+          cmake -B bld-cm -DCURL_WERROR=ON -DCURL_USE_LIBPSL=OFF -DCURL_DISABLE_LDAP=ON \
             -DCMAKE_C_COMPILER_TARGET="$(uname -m | sed 's/arm64/aarch64/')-apple-darwin$(uname -r)" \
             -DCURL_BROTLI=OFF \
             -DCURL_USE_LIBSSH2=OFF
@@ -128,7 +128,7 @@ jobs:
 
       - name: 'run cmake'
         run: |
-          cmake -B bld-cm -DCURL_USE_SCHANNEL=ON -DCURL_USE_LIBPSL=OFF \
+          cmake -B bld-cm -DCURL_WERROR=ON -DCURL_USE_SCHANNEL=ON -DCURL_USE_LIBPSL=OFF \
             -DCMAKE_SYSTEM_NAME=Windows \
             -DCMAKE_C_COMPILER_TARGET="${TRIPLET}" \
             -DCMAKE_C_COMPILER="${TRIPLET}-gcc"
index 1428238cb0d845492d44c05a8cba4c0bc5287adc..8aa28a310aa36923aed2d9885de7fc0ac26dae5a 100644 (file)
@@ -70,7 +70,7 @@ int main(void)
 #include <netdb.h>
 int main(void)
 {
-  char *address = "example.com";
+  const char *address = "example.com";
   int length = 0;
   int type = 0;
   struct hostent h;