mark unused parameters in trivial compat functions
When a platform feature isn't available or in use, we sometimes conditionally compile empty or trivial functions to turn these into noops. We need to annotate their parameters so that -Wunused-parameters won't complain about them. Note that there are many more of these in compat/mingw.h, but we'll leave them for now, as there's some trickery required to get the UNUSED macro available there. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Oct 17, 2022 at 21:05 UTC
808e91956d1db707643c7f68c2b8fcc6f38a2d80
3 files changed
+12
-8
compat/nonblock.c
+1
-1
@@ -41,7 +41,7 @@ int enable_pipe_nonblock(int fd)
41
42
#else
43
44
-int enable_pipe_nonblock(int fd)
44
+int enable_pipe_nonblock(int fd UNUSED)
45
{
46
errno = ENOSYS;
47
return -1;
exec-cmd.c
+1
-1
@@ -252,7 +252,7 @@ static const char *system_prefix(void)
252
* This is called during initialization, but No work needs to be done here when
253
* runtime prefix is not being used.
254
*/
255
-void git_resolve_executable_dir(const char *argv0)
255
+void git_resolve_executable_dir(const char *argv0 UNUSED)
256
{
257
}
258
git-compat-util.h
+10
-6
@@ -310,7 +310,9 @@ typedef unsigned long uintptr_t;
310
#ifdef PRECOMPOSE_UNICODE
311
#include "compat/precompose_utf8.h"
312
#else
313
-static inline const char *precompose_argv_prefix(int argc, const char **argv, const char *prefix)
313
+static inline const char *precompose_argv_prefix(int argc UNUSED,
314
+ const char **argv UNUSED,
315
+ const char *prefix)
316
{
317
return prefix;
318
}
@@ -335,7 +337,9 @@ struct itimerval {
337
#endif
338
339
#ifdef NO_SETITIMER
338
-static inline int setitimer(int which, const struct itimerval *value, struct itimerval *newvalue) {
340
+static inline int setitimer(int which UNUSED,
341
+ const struct itimerval *value UNUSED,
342
+ struct itimerval *newvalue UNUSED) {
343
return 0; /* pretend success */
344
}
345
#endif
@@ -420,7 +424,7 @@ int lstat_cache_aware_rmdir(const char *path);
424
#endif
425
426
#ifndef has_dos_drive_prefix
423
-static inline int git_has_dos_drive_prefix(const char *path)
427
+static inline int git_has_dos_drive_prefix(const char *path UNUSED)
428
{
429
return 0;
430
}
@@ -428,7 +432,7 @@ static inline int git_has_dos_drive_prefix(const char *path)
432
#endif
433
434
#ifndef skip_dos_drive_prefix
431
-static inline int git_skip_dos_drive_prefix(char **path)
435
+static inline int git_skip_dos_drive_prefix(char **path UNUSED)
436
{
437
return 0;
438
}
@@ -1463,11 +1467,11 @@ int open_nofollow(const char *path, int flags);
1467
#endif
1468
1469
#ifndef _POSIX_THREAD_SAFE_FUNCTIONS
1466
-static inline void flockfile(FILE *fh)
1470
+static inline void flockfile(FILE *fh UNUSED)
1471
{
1472
; /* nothing */
1473
}
1470
-static inline void funlockfile(FILE *fh)
1474
+static inline void funlockfile(FILE *fh UNUSED)
1475
{
1476
; /* nothing */
1477
}