]> git.ipfire.org Git - thirdparty/git.git/commitdiff
clar(win32): avoid compile error due to unused `fs_copy()`
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Wed, 4 Sep 2024 14:16:56 +0000 (16:16 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 4 Sep 2024 15:41:36 +0000 (08:41 -0700)
When CLAR_FIXTURE_PATH is unset, the `fs_copy()` function seems not to
be used. But it is declared as `static`, and GCC does not like that,
complaining that it should not be declared/defined to begin with.

We could mark this function as (potentially) unused by following the
`MAYBE_UNUSED` pattern from Git's `git-compat-util.h`. However, this is
a GCC-only construct that is not understood by Visual C. Besides, `clar`
does not use that pattern at all.

Instead, let's use the `((void)SYMBOL);` pattern that `clar` already
uses elsewhere; This avoids the compile error by sorta kinda make the
function used after a fashion.

Note: GCC 14.x (which Git for Windows' SDK already uses) is able to
figure out that this function is unused even though there are recursive
calls between `fs_copy()` and `fs_copydir_helper()`; Earlier GCC
versions do not detect that, and therefore the issue has been hidden
from the regular Linux CI builds (where GCC 14.x is not yet used). That
is the reason why this change is only made in the Windows-specific
portion of `t/unit-tests/clar/clar/fs.h`.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/unit-tests/clar/clar/fs.h

index 3e39890bd3ebd322d91f734c3847e37951d44498..8b206179fc4ea17abc57345c1f863e04aab98d4e 100644 (file)
@@ -297,6 +297,8 @@ cl_fs_cleanup(void)
 {
 #ifdef CLAR_FIXTURE_PATH
        fs_rm(fixture_path(_clar_path, "*"));
+#else
+       ((void)fs_copy); /* unused */
 #endif
 }