Skip to content

Commit b652382

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1414918 commit b652382

File tree

8 files changed

+24
-23
lines changed

8 files changed

+24
-23
lines changed

compat/mingw.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,8 @@ static enum hide_dotfiles_type hide_dotfiles = HIDE_DOTFILES_DOTGITONLY;
243243
static char *unset_environment_variables;
244244

245245
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)
247248
{
248249
if (!strcmp(var, "core.hidedotfiles")) {
249250
if (value && !strcasecmp(value, "dotgitonly"))
@@ -453,7 +454,7 @@ static int set_hidden_flag(const wchar_t *path, int set)
453454
return -1;
454455
}
455456

456-
int mingw_mkdir(const char *path, int mode)
457+
int mingw_mkdir(const char *path, int mode UNUSED)
457458
{
458459
int ret;
459460
wchar_t wpath[MAX_PATH];
@@ -597,7 +598,7 @@ int mingw_open (const char *filename, int oflags, ...)
597598
return fd;
598599
}
599600

600-
static BOOL WINAPI ctrl_ignore(DWORD type)
601+
static BOOL WINAPI ctrl_ignore(DWORD type UNUSED)
601602
{
602603
return TRUE;
603604
}
@@ -1085,7 +1086,7 @@ int mkstemp(char *template)
10851086
return git_mkstemp_mode(template, 0600);
10861087
}
10871088

1088-
int gettimeofday(struct timeval *tv, void *tz)
1089+
int gettimeofday(struct timeval *tv, void *tz UNUSED)
10891090
{
10901091
FILETIME ft;
10911092
long long hnsec;
@@ -2252,7 +2253,7 @@ char *mingw_query_user_email(void)
22522253
return get_extended_user_info(NameUserPrincipal);
22532254
}
22542255

2255-
struct passwd *getpwuid(int uid)
2256+
struct passwd *getpwuid(int uid UNUSED)
22562257
{
22572258
static unsigned initialized;
22582259
static char user_name[100];
@@ -2304,7 +2305,7 @@ static sig_handler_t timer_fn = SIG_DFL, sigint_fn = SIG_DFL;
23042305
* length to call the signal handler.
23052306
*/
23062307

2307-
static unsigned __stdcall ticktack(void *dummy)
2308+
static unsigned __stdcall ticktack(void *dummy UNUSED)
23082309
{
23092310
while (WaitForSingleObject(timer_event, timer_interval) == WAIT_TIMEOUT) {
23102311
mingw_raise(SIGALRM);
@@ -2352,7 +2353,7 @@ static inline int is_timeval_eq(const struct timeval *i1, const struct timeval *
23522353
return i1->tv_sec == i2->tv_sec && i1->tv_usec == i2->tv_usec;
23532354
}
23542355

2355-
int setitimer(int type, struct itimerval *in, struct itimerval *out)
2356+
int setitimer(int type UNUSED, struct itimerval *in, struct itimerval *out)
23562357
{
23572358
static const struct timeval zero;
23582359
static int atexit_done;

compat/mingw.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,27 +122,27 @@ struct utsname {
122122
* trivial stubs
123123
*/
124124

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)
126126
{ 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)
128128
{ 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)
130130
{ errno = ENOSYS; return -1; }
131131
#ifndef __MINGW64_VERSION_MAJOR
132132
static inline pid_t fork(void)
133133
{ errno = ENOSYS; return -1; }
134134
#endif
135-
static inline unsigned int alarm(unsigned int seconds)
135+
static inline unsigned int alarm(unsigned int seconds UNUSED)
136136
{ return 0; }
137137
static inline int fsync(int fd)
138138
{ return _commit(fd); }
139139
static inline void sync(void)
140140
{}
141141
static inline uid_t getuid(void)
142142
{ return 1; }
143-
static inline struct passwd *getpwnam(const char *name)
143+
static inline struct passwd *getpwnam(const char *name UNUSED)
144144
{ return NULL; }
145-
static inline int fcntl(int fd, int cmd, ...)
145+
static inline int fcntl(int fd UNUSED, int cmd, ...)
146146
{
147147
if (cmd == F_GETFD || cmd == F_SETFD)
148148
return 0;
@@ -151,17 +151,17 @@ static inline int fcntl(int fd, int cmd, ...)
151151
}
152152

153153
#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)
155155
{ return 0; }
156156
#define SIG_BLOCK 0
157157
#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)
159159
{ return 0; }
160160
static inline pid_t getppid(void)
161161
{ return 1; }
162162
static inline pid_t getpgid(pid_t pid)
163163
{ return pid == 0 ? getpid() : pid; }
164-
static inline pid_t tcgetpgrp(int fd)
164+
static inline pid_t tcgetpgrp(int fd UNUSED)
165165
{ return getpid(); }
166166

167167
/*

compat/stub/procinfo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
* Stub. See sample implementations in compat/linux/procinfo.c and
77
* compat/win32/trace2_win32_process_info.c.
88
*/
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)
1010
{
1111
}

compat/win32/pthread.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ static unsigned __stdcall win32_start_routine(void *arg)
2121
return 0;
2222
}
2323

24-
int pthread_create(pthread_t *thread, const void *unused,
24+
int pthread_create(pthread_t *thread, const void *attr UNUSED,
2525
void *(*start_routine)(void *), void *arg)
2626
{
2727
thread->arg = arg;

compat/win32/pthread.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919
#define pthread_mutex_t CRITICAL_SECTION
2020

21-
static inline int return_0(int i) {
21+
static inline int return_0(int i UNUSED) {
2222
return 0;
2323
}
2424
#define pthread_mutex_init(a,b) return_0((InitializeCriticalSection((a)), 0))
@@ -70,7 +70,7 @@ static inline void NORETURN pthread_exit(void *ret)
7070
}
7171

7272
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)
7474
{
7575
return (*keyp = TlsAlloc()) == TLS_OUT_OF_INDEXES ? EAGAIN : 0;
7676
}

compat/win32/syslog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
static HANDLE ms_eventlog;
44

5-
void openlog(const char *ident, int logopt, int facility)
5+
void openlog(const char *ident, int logopt UNUSED, int facility UNUSED)
66
{
77
if (ms_eventlog)
88
return;

compat/win32mmap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ void *git_mmap(void *start, size_t length, int prot, int flags, int fd, off_t of
4040
return MAP_FAILED;
4141
}
4242

43-
int git_munmap(void *start, size_t length)
43+
int git_munmap(void *start, size_t length UNUSED)
4444
{
4545
return !UnmapViewOfFile(start);
4646
}

compat/winansi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ enum {
340340
TEXT = 0, ESCAPE = 033, BRACKET = '['
341341
};
342342

343-
static DWORD WINAPI console_thread(LPVOID unused)
343+
static DWORD WINAPI console_thread(LPVOID data UNUSED)
344344
{
345345
unsigned char buffer[BUFFER_SIZE];
346346
DWORD bytes;

0 commit comments

Comments
 (0)