compat: mark unused parameters in win32/mingw functions
The compat/ directory contains many stub functions, wrappers, and so on that have to conform to a specific interface, but don't necessarily need to use all of their parameters. Let's mark them to avoid complaints from -Wunused-parameter. This was done mostly via guess-and-check with the Windows build in GitHub CI. I also confirmed that the win+VS build is similarly happy. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Aug 28, 2024 at 00:00 UTC
b652382d761607c76258e2e91fa753dffe5c21dc
8 files changed
+24
-23
compat/mingw.c
+8
-7
@@ -243,7 +243,8 @@ static enum hide_dotfiles_type hide_dotfiles = HIDE_DOTFILES_DOTGITONLY;
243
static char *unset_environment_variables;
244
245
int mingw_core_config(const char *var, const char *value,
246
- const struct config_context *ctx, void *cb)
246
+ const struct config_context *ctx UNUSED,
247
+ void *cb UNUSED)
248
{
249
if (!strcmp(var, "core.hidedotfiles")) {
250
if (value && !strcasecmp(value, "dotgitonly"))
@@ -453,7 +454,7 @@ static int set_hidden_flag(const wchar_t *path, int set)
454
return -1;
455
}
456
456
-int mingw_mkdir(const char *path, int mode)
457
+int mingw_mkdir(const char *path, int mode UNUSED)
458
{
459
int ret;
460
wchar_t wpath[MAX_PATH];
@@ -597,7 +598,7 @@ int mingw_open (const char *filename, int oflags, ...)
598
return fd;
599
}
600
600
-static BOOL WINAPI ctrl_ignore(DWORD type)
601
+static BOOL WINAPI ctrl_ignore(DWORD type UNUSED)
602
{
603
return TRUE;
604
}
@@ -1085,7 +1086,7 @@ int mkstemp(char *template)
1086
return git_mkstemp_mode(template, 0600);
1087
}
1088
1088
-int gettimeofday(struct timeval *tv, void *tz)
1089
+int gettimeofday(struct timeval *tv, void *tz UNUSED)
1090
{
1091
FILETIME ft;
1092
long long hnsec;
@@ -2252,7 +2253,7 @@ char *mingw_query_user_email(void)
2253
return get_extended_user_info(NameUserPrincipal);
2254
}
2255
2255
-struct passwd *getpwuid(int uid)
2256
+struct passwd *getpwuid(int uid UNUSED)
2257
{
2258
static unsigned initialized;
2259
static char user_name[100];
@@ -2304,7 +2305,7 @@ static sig_handler_t timer_fn = SIG_DFL, sigint_fn = SIG_DFL;
2305
* length to call the signal handler.
2306
*/
2307
2307
-static unsigned __stdcall ticktack(void *dummy)
2308
+static unsigned __stdcall ticktack(void *dummy UNUSED)
2309
{
2310
while (WaitForSingleObject(timer_event, timer_interval) == WAIT_TIMEOUT) {
2311
mingw_raise(SIGALRM);
@@ -2352,7 +2353,7 @@ static inline int is_timeval_eq(const struct timeval *i1, const struct timeval *
2353
return i1->tv_sec == i2->tv_sec && i1->tv_usec == i2->tv_usec;
2354
}
2355
2355
-int setitimer(int type, struct itimerval *in, struct itimerval *out)
2356
+int setitimer(int type UNUSED, struct itimerval *in, struct itimerval *out)
2357
{
2358
static const struct timeval zero;
2359
static int atexit_done;
compat/mingw.h
+9
-9
@@ -122,17 +122,17 @@ struct utsname {
122
* trivial stubs
123
*/
124
125
-static inline int readlink(const char *path, char *buf, size_t bufsiz)
125
+static inline int readlink(const char *path UNUSED, char *buf UNUSED, size_t bufsiz UNUSED)
126
{ errno = ENOSYS; return -1; }
127
-static inline int symlink(const char *oldpath, const char *newpath)
127
+static inline int symlink(const char *oldpath UNUSED, const char *newpath UNUSED)
128
{ errno = ENOSYS; return -1; }
129
-static inline int fchmod(int fildes, mode_t mode)
129
+static inline int fchmod(int fildes UNUSED, mode_t mode UNUSED)
130
{ errno = ENOSYS; return -1; }
131
#ifndef __MINGW64_VERSION_MAJOR
132
static inline pid_t fork(void)
133
{ errno = ENOSYS; return -1; }
134
#endif
135
-static inline unsigned int alarm(unsigned int seconds)
135
+static inline unsigned int alarm(unsigned int seconds UNUSED)
136
{ return 0; }
137
static inline int fsync(int fd)
138
{ return _commit(fd); }
@@ -140,9 +140,9 @@ static inline void sync(void)
140
{}
141
static inline uid_t getuid(void)
142
{ return 1; }
143
-static inline struct passwd *getpwnam(const char *name)
143
+static inline struct passwd *getpwnam(const char *name UNUSED)
144
{ return NULL; }
145
-static inline int fcntl(int fd, int cmd, ...)
145
+static inline int fcntl(int fd UNUSED, int cmd, ...)
146
{
147
if (cmd == F_GETFD || cmd == F_SETFD)
148
return 0;
@@ -151,17 +151,17 @@ static inline int fcntl(int fd, int cmd, ...)
151
}
152
153
#define sigemptyset(x) (void)0
154
-static inline int sigaddset(sigset_t *set, int signum)
154
+static inline int sigaddset(sigset_t *set UNUSED, int signum UNUSED)
155
{ return 0; }
156
#define SIG_BLOCK 0
157
#define SIG_UNBLOCK 0
158
-static inline int sigprocmask(int how, const sigset_t *set, sigset_t *oldset)
158
+static inline int sigprocmask(int how UNUSED, const sigset_t *set UNUSED, sigset_t *oldset UNUSED)
159
{ return 0; }
160
static inline pid_t getppid(void)
161
{ return 1; }
162
static inline pid_t getpgid(pid_t pid)
163
{ return pid == 0 ? getpid() : pid; }
164
-static inline pid_t tcgetpgrp(int fd)
164
+static inline pid_t tcgetpgrp(int fd UNUSED)
165
{ return getpid(); }
166
167
/*
compat/stub/procinfo.c
+1
-1
@@ -6,6 +6,6 @@
6
* Stub. See sample implementations in compat/linux/procinfo.c and
7
* compat/win32/trace2_win32_process_info.c.
8
*/
9
-void trace2_collect_process_info(enum trace2_process_info_reason reason)
9
+void trace2_collect_process_info(enum trace2_process_info_reason reason UNUSED)
10
{
11
}
compat/win32/pthread.c
+1
-1
@@ -21,7 +21,7 @@ static unsigned __stdcall win32_start_routine(void *arg)
21
return 0;
22
}
23
24
-int pthread_create(pthread_t *thread, const void *unused,
24
+int pthread_create(pthread_t *thread, const void *attr UNUSED,
25
void *(*start_routine)(void *), void *arg)
26
{
27
thread->arg = arg;
compat/win32/pthread.h
+2
-2
@@ -18,7 +18,7 @@
18
*/
19
#define pthread_mutex_t CRITICAL_SECTION
20
21
-static inline int return_0(int i) {
21
+static inline int return_0(int i UNUSED) {
22
return 0;
23
}
24
#define pthread_mutex_init(a,b) return_0((InitializeCriticalSection((a)), 0))
@@ -70,7 +70,7 @@ static inline void NORETURN pthread_exit(void *ret)
70
}
71
72
typedef DWORD pthread_key_t;
73
-static inline int pthread_key_create(pthread_key_t *keyp, void (*destructor)(void *value))
73
+static inline int pthread_key_create(pthread_key_t *keyp, void (*destructor)(void *value) UNUSED)
74
{
75
return (*keyp = TlsAlloc()) == TLS_OUT_OF_INDEXES ? EAGAIN : 0;
76
}
compat/win32/syslog.c
+1
-1
@@ -2,7 +2,7 @@
2
3
static HANDLE ms_eventlog;
4
5
-void openlog(const char *ident, int logopt, int facility)
5
+void openlog(const char *ident, int logopt UNUSED, int facility UNUSED)
6
{
7
if (ms_eventlog)
8
return;
compat/win32mmap.c
+1
-1
@@ -40,7 +40,7 @@ void *git_mmap(void *start, size_t length, int prot, int flags, int fd, off_t of
40
return MAP_FAILED;
41
}
42
43
-int git_munmap(void *start, size_t length)
43
+int git_munmap(void *start, size_t length UNUSED)
44
{
45
return !UnmapViewOfFile(start);
46
}
compat/winansi.c
+1
-1
@@ -340,7 +340,7 @@ enum {
340
TEXT = 0, ESCAPE = 033, BRACKET = '['
341
};
342
343
-static DWORD WINAPI console_thread(LPVOID unused)
343
+static DWORD WINAPI console_thread(LPVOID data UNUSED)
344
{
345
unsigned char buffer[BUFFER_SIZE];
346
DWORD bytes;