Skip to content

Commit 9ff7eb8

Browse files
avargitster
authored andcommitted
git-compat-util.h: use "deprecated" for UNUSED variables
As noted in the preceding commit our "UNUSED" macro was no longer protecting against actual use of the "unused" variables, which it was previously doing by renaming the variable. Let's instead use the "deprecated" attribute to accomplish that goal. As [1] rightly notes this has the drawback that compiling with "-Wno-deprecated-declarations" will silence any such uses. I think the trade-off is worth it as: * We can consider that a feature, as e.g. backporting certain patches might use a now "unused" parameter, and the person doing that might want to silence it with DEVOPTS=no-error. * This way we play nicely with coccinelle, and any other dumb(er) parser of C (such as syntax highlighters). * Not every single compilation of git needs to catch "used but declared unused" parameters. It's sufficient that the default "make DEVELOPER=1" will do so, and that the "static-analysis" CI job will catch it. 1. https://lore.kernel.org/git/[email protected]/ Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5cf88fd commit 9ff7eb8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

git-compat-util.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ struct strbuf;
190190
#define _SGI_SOURCE 1
191191

192192
#if defined(__GNUC__)
193-
#define UNUSED __attribute__((unused))
193+
#define UNUSED __attribute__((unused)) \
194+
__attribute__((deprecated ("parameter declared as UNUSED")))
194195
#else
195196
#define UNUSED
196197
#endif

0 commit comments

Comments
 (0)