Skip to content

tests/server: give global path variable a more descriptive name #16719

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

vszakats
Copy link
Member

Use a more descriptive global variable name in server code, also
to avoid colliding with this name used elsewhere in libcurl.

This isn't causing an issue at this time, but makes the code prone
to -Wshadow warnings in unity mode, if the global variable is
compiled first. This specific variable could collide with the path
argument of the curlx_win32_stat() function.


lib/curl_multibyte.c:317:34: error: declaration of 'path' shadows a global declaration [-Werror=shadow]
  317 | int curlx_win32_stat(const char *path, struct_stat *buffer)
      |                      ~~~~~~~~~~~~^~~~
In file included from tests/server/resolve.c:47,
                 from bld/tests/server/server_bundle.c:7,
                 from bld/tests/server/CMakeFiles/servers.dir/Unity/unity_0_c.c:4:
tests/server/util.h:64:20: note: shadowed declaration is here
   64 | extern const char *path;  /* where to find the 'data' dir */
      |                    ^~~~

Seen in these CI jobs while doing tests:

AppVeyor / CMake, VS2022, Release, x64, Schannel, Shared, Unicode, DEBUGBUILD, no-CURLDEBUG, Build-tests
Windows / linux-mingw, CM gcc
Windows / mingw, CM i686 schannel R
Windows / mingw, CM ucrt-x86_64 schannel uwp
Windows / msvc, CM x64-windows boringssl

https://github.com/curl/curl/actions/runs/13845123447/job/38741731971?pr=15000
https://ci.appveyor.com/project/curlorg/curl/builds/51693340

Rename a global variable in server code to avoid colliding with its name
used elsewhere in libcurl. This isn't causing an issue at this time, but
makes the code sensitive to compile order, and may cause `-Wshadow`
warnings if the global declaration precedes libcurl code:
```
lib/curl_multibyte.c:317:34: error: declaration of 'path' shadows a global declaration [-Werror=shadow]
  317 | int curlx_win32_stat(const char *path, struct_stat *buffer)
      |                      ~~~~~~~~~~~~^~~~
In file included from tests/server/resolve.c:47,
                 from bld/tests/server/server_bundle.c:7,
                 from bld/tests/server/CMakeFiles/servers.dir/Unity/unity_0_c.c:4:
tests/server/util.h:64:20: note: shadowed declaration is here
   64 | extern const char *path;  /* where to find the 'data' dir */
      |                    ^~~~
```

Affecting these CI jobs:
```
AppVeyor / CMake, VS2022, Release, x64, Schannel, Shared, Unicode, DEBUGBUILD, no-CURLDEBUG, Build-tests
Windows / linux-mingw, CM gcc
Windows / mingw, CM i686 schannel R
Windows / mingw, CM ucrt-x86_64 schannel uwp
Windows / msvc, CM x64-windows boringssl
```

https://github.com/curl/curl/actions/runs/13845123447/job/38741731971?pr=15000
https://ci.appveyor.com/project/curlorg/curl/builds/51693340
@vszakats vszakats closed this in 43b2884 Mar 14, 2025
@vszakats vszakats deleted the server-shadow branch March 14, 2025 11:05
pps83 pushed a commit to pps83/curl that referenced this pull request Apr 26, 2025
Use a more descriptive global variable name in server code, also
to avoid colliding with this name used elsewhere in libcurl.

This isn't causing an issue at this time, but makes the code prone
to `-Wshadow` warnings in unity mode, if the global variable is
compiled first. This specific variable could collide with the `path`
argument of the `curlx_win32_stat()` function.

Closes curl#16719
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

1 participant