mirror of
https://github.com/git/git.git
synced 2024-10-28 04:49:43 +01:00
Merge branch 'jk/unused-parameters'
Make our codebase compilable with the -Werror=unused-parameter option. * jk/unused-parameters: CodingGuidelines: mention -Wunused-parameter and UNUSED config.mak.dev: enable -Wunused-parameter by default compat: mark unused parameters in win32/mingw functions compat: disable -Wunused-parameter in win32/headless.c compat: disable -Wunused-parameter in 3rd-party code t-reftable-readwrite: mark unused parameter in callback function gc: mark unused config parameter in virtual functions
This commit is contained in:
commit
5ecd5fa58b
15 changed files with 46 additions and 33 deletions
|
@ -258,6 +258,13 @@ For C programs:
|
|||
ensure your patch is clear of all compiler warnings we care about,
|
||||
by e.g. "echo DEVELOPER=1 >>config.mak".
|
||||
|
||||
- When using DEVELOPER=1 mode, you may see warnings from the compiler
|
||||
like "error: unused parameter 'foo' [-Werror=unused-parameter]",
|
||||
which indicates that a function ignores its argument. If the unused
|
||||
parameter can't be removed (e.g., because the function is used as a
|
||||
callback and has to match a certain interface), you can annotate the
|
||||
individual parameters with the UNUSED keyword, like "int foo UNUSED".
|
||||
|
||||
- We try to support a wide range of C compilers to compile Git with,
|
||||
including old ones. As of Git v2.35.0 Git requires C99 (we check
|
||||
"__STDC_VERSION__"). You should not use features from a newer C
|
||||
|
|
16
builtin/gc.c
16
builtin/gc.c
|
@ -967,7 +967,7 @@ static int dfs_on_ref(const char *refname UNUSED,
|
|||
return result;
|
||||
}
|
||||
|
||||
static int should_write_commit_graph(struct gc_config *cfg)
|
||||
static int should_write_commit_graph(struct gc_config *cfg UNUSED)
|
||||
{
|
||||
int result;
|
||||
struct cg_auto_data data;
|
||||
|
@ -1005,7 +1005,7 @@ static int run_write_commit_graph(struct maintenance_run_opts *opts)
|
|||
}
|
||||
|
||||
static int maintenance_task_commit_graph(struct maintenance_run_opts *opts,
|
||||
struct gc_config *cfg)
|
||||
struct gc_config *cfg UNUSED)
|
||||
{
|
||||
prepare_repo_settings(the_repository);
|
||||
if (!the_repository->settings.core_commit_graph)
|
||||
|
@ -1040,7 +1040,7 @@ static int fetch_remote(struct remote *remote, void *cbdata)
|
|||
}
|
||||
|
||||
static int maintenance_task_prefetch(struct maintenance_run_opts *opts,
|
||||
struct gc_config *cfg)
|
||||
struct gc_config *cfg UNUSED)
|
||||
{
|
||||
if (for_each_remote(fetch_remote, opts)) {
|
||||
error(_("failed to prefetch remotes"));
|
||||
|
@ -1051,7 +1051,7 @@ static int maintenance_task_prefetch(struct maintenance_run_opts *opts,
|
|||
}
|
||||
|
||||
static int maintenance_task_gc(struct maintenance_run_opts *opts,
|
||||
struct gc_config *cfg)
|
||||
struct gc_config *cfg UNUSED)
|
||||
{
|
||||
struct child_process child = CHILD_PROCESS_INIT;
|
||||
|
||||
|
@ -1100,7 +1100,7 @@ static int loose_object_count(const struct object_id *oid UNUSED,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int loose_object_auto_condition(struct gc_config *cfg)
|
||||
static int loose_object_auto_condition(struct gc_config *cfg UNUSED)
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
|
@ -1192,12 +1192,12 @@ static int pack_loose(struct maintenance_run_opts *opts)
|
|||
}
|
||||
|
||||
static int maintenance_task_loose_objects(struct maintenance_run_opts *opts,
|
||||
struct gc_config *cfg)
|
||||
struct gc_config *cfg UNUSED)
|
||||
{
|
||||
return prune_packed(opts) || pack_loose(opts);
|
||||
}
|
||||
|
||||
static int incremental_repack_auto_condition(struct gc_config *cfg)
|
||||
static int incremental_repack_auto_condition(struct gc_config *cfg UNUSED)
|
||||
{
|
||||
struct packed_git *p;
|
||||
int incremental_repack_auto_limit = 10;
|
||||
|
@ -1317,7 +1317,7 @@ static int multi_pack_index_repack(struct maintenance_run_opts *opts)
|
|||
}
|
||||
|
||||
static int maintenance_task_incremental_repack(struct maintenance_run_opts *opts,
|
||||
struct gc_config *cfg)
|
||||
struct gc_config *cfg UNUSED)
|
||||
{
|
||||
prepare_repo_settings(the_repository);
|
||||
if (!the_repository->settings.core_multi_pack_index) {
|
||||
|
|
|
@ -243,7 +243,8 @@ static enum hide_dotfiles_type hide_dotfiles = HIDE_DOTFILES_DOTGITONLY;
|
|||
static char *unset_environment_variables;
|
||||
|
||||
int mingw_core_config(const char *var, const char *value,
|
||||
const struct config_context *ctx, void *cb)
|
||||
const struct config_context *ctx UNUSED,
|
||||
void *cb UNUSED)
|
||||
{
|
||||
if (!strcmp(var, "core.hidedotfiles")) {
|
||||
if (value && !strcasecmp(value, "dotgitonly"))
|
||||
|
@ -453,7 +454,7 @@ static int set_hidden_flag(const wchar_t *path, int set)
|
|||
return -1;
|
||||
}
|
||||
|
||||
int mingw_mkdir(const char *path, int mode)
|
||||
int mingw_mkdir(const char *path, int mode UNUSED)
|
||||
{
|
||||
int ret;
|
||||
wchar_t wpath[MAX_PATH];
|
||||
|
@ -597,7 +598,7 @@ int mingw_open (const char *filename, int oflags, ...)
|
|||
return fd;
|
||||
}
|
||||
|
||||
static BOOL WINAPI ctrl_ignore(DWORD type)
|
||||
static BOOL WINAPI ctrl_ignore(DWORD type UNUSED)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -1085,7 +1086,7 @@ int mkstemp(char *template)
|
|||
return git_mkstemp_mode(template, 0600);
|
||||
}
|
||||
|
||||
int gettimeofday(struct timeval *tv, void *tz)
|
||||
int gettimeofday(struct timeval *tv, void *tz UNUSED)
|
||||
{
|
||||
FILETIME ft;
|
||||
long long hnsec;
|
||||
|
@ -2252,7 +2253,7 @@ char *mingw_query_user_email(void)
|
|||
return get_extended_user_info(NameUserPrincipal);
|
||||
}
|
||||
|
||||
struct passwd *getpwuid(int uid)
|
||||
struct passwd *getpwuid(int uid UNUSED)
|
||||
{
|
||||
static unsigned initialized;
|
||||
static char user_name[100];
|
||||
|
@ -2304,7 +2305,7 @@ static sig_handler_t timer_fn = SIG_DFL, sigint_fn = SIG_DFL;
|
|||
* length to call the signal handler.
|
||||
*/
|
||||
|
||||
static unsigned __stdcall ticktack(void *dummy)
|
||||
static unsigned __stdcall ticktack(void *dummy UNUSED)
|
||||
{
|
||||
while (WaitForSingleObject(timer_event, timer_interval) == WAIT_TIMEOUT) {
|
||||
mingw_raise(SIGALRM);
|
||||
|
@ -2352,7 +2353,7 @@ static inline int is_timeval_eq(const struct timeval *i1, const struct timeval *
|
|||
return i1->tv_sec == i2->tv_sec && i1->tv_usec == i2->tv_usec;
|
||||
}
|
||||
|
||||
int setitimer(int type, struct itimerval *in, struct itimerval *out)
|
||||
int setitimer(int type UNUSED, struct itimerval *in, struct itimerval *out)
|
||||
{
|
||||
static const struct timeval zero;
|
||||
static int atexit_done;
|
||||
|
|
|
@ -122,17 +122,17 @@ struct utsname {
|
|||
* trivial stubs
|
||||
*/
|
||||
|
||||
static inline int readlink(const char *path, char *buf, size_t bufsiz)
|
||||
static inline int readlink(const char *path UNUSED, char *buf UNUSED, size_t bufsiz UNUSED)
|
||||
{ errno = ENOSYS; return -1; }
|
||||
static inline int symlink(const char *oldpath, const char *newpath)
|
||||
static inline int symlink(const char *oldpath UNUSED, const char *newpath UNUSED)
|
||||
{ errno = ENOSYS; return -1; }
|
||||
static inline int fchmod(int fildes, mode_t mode)
|
||||
static inline int fchmod(int fildes UNUSED, mode_t mode UNUSED)
|
||||
{ errno = ENOSYS; return -1; }
|
||||
#ifndef __MINGW64_VERSION_MAJOR
|
||||
static inline pid_t fork(void)
|
||||
{ errno = ENOSYS; return -1; }
|
||||
#endif
|
||||
static inline unsigned int alarm(unsigned int seconds)
|
||||
static inline unsigned int alarm(unsigned int seconds UNUSED)
|
||||
{ return 0; }
|
||||
static inline int fsync(int fd)
|
||||
{ return _commit(fd); }
|
||||
|
@ -140,9 +140,9 @@ static inline void sync(void)
|
|||
{}
|
||||
static inline uid_t getuid(void)
|
||||
{ return 1; }
|
||||
static inline struct passwd *getpwnam(const char *name)
|
||||
static inline struct passwd *getpwnam(const char *name UNUSED)
|
||||
{ return NULL; }
|
||||
static inline int fcntl(int fd, int cmd, ...)
|
||||
static inline int fcntl(int fd UNUSED, int cmd, ...)
|
||||
{
|
||||
if (cmd == F_GETFD || cmd == F_SETFD)
|
||||
return 0;
|
||||
|
@ -151,17 +151,17 @@ static inline int fcntl(int fd, int cmd, ...)
|
|||
}
|
||||
|
||||
#define sigemptyset(x) (void)0
|
||||
static inline int sigaddset(sigset_t *set, int signum)
|
||||
static inline int sigaddset(sigset_t *set UNUSED, int signum UNUSED)
|
||||
{ return 0; }
|
||||
#define SIG_BLOCK 0
|
||||
#define SIG_UNBLOCK 0
|
||||
static inline int sigprocmask(int how, const sigset_t *set, sigset_t *oldset)
|
||||
static inline int sigprocmask(int how UNUSED, const sigset_t *set UNUSED, sigset_t *oldset UNUSED)
|
||||
{ return 0; }
|
||||
static inline pid_t getppid(void)
|
||||
{ return 1; }
|
||||
static inline pid_t getpgid(pid_t pid)
|
||||
{ return pid == 0 ? getpid() : pid; }
|
||||
static inline pid_t tcgetpgrp(int fd)
|
||||
static inline pid_t tcgetpgrp(int fd UNUSED)
|
||||
{ return getpid(); }
|
||||
|
||||
/*
|
||||
|
|
|
@ -31,6 +31,8 @@ DEALINGS IN THE SOFTWARE.
|
|||
/*#pragma optimize("a", on)*/
|
||||
#endif
|
||||
|
||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
|
||||
/*#define FULLSANITYCHECKS*/
|
||||
|
||||
#include "nedmalloc.h"
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
|
||||
#if defined __TANDEM
|
||||
/* This is currently duplicated from git-compat-utils.h */
|
||||
# ifdef NO_INTPTR_T
|
||||
|
|
|
@ -6,6 +6,6 @@
|
|||
* Stub. See sample implementations in compat/linux/procinfo.c and
|
||||
* compat/win32/trace2_win32_process_info.c.
|
||||
*/
|
||||
void trace2_collect_process_info(enum trace2_process_info_reason reason)
|
||||
void trace2_collect_process_info(enum trace2_process_info_reason reason UNUSED)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
#include <stdlib.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
|
||||
/*
|
||||
* If `dir` contains the path to a Git exec directory, extend `PATH` to
|
||||
* include the corresponding `bin/` directory (which is where all those
|
||||
|
|
|
@ -21,7 +21,7 @@ static unsigned __stdcall win32_start_routine(void *arg)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int pthread_create(pthread_t *thread, const void *unused,
|
||||
int pthread_create(pthread_t *thread, const void *attr UNUSED,
|
||||
void *(*start_routine)(void *), void *arg)
|
||||
{
|
||||
thread->arg = arg;
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
#define pthread_mutex_t CRITICAL_SECTION
|
||||
|
||||
static inline int return_0(int i) {
|
||||
static inline int return_0(int i UNUSED) {
|
||||
return 0;
|
||||
}
|
||||
#define pthread_mutex_init(a,b) return_0((InitializeCriticalSection((a)), 0))
|
||||
|
@ -70,7 +70,7 @@ static inline void NORETURN pthread_exit(void *ret)
|
|||
}
|
||||
|
||||
typedef DWORD pthread_key_t;
|
||||
static inline int pthread_key_create(pthread_key_t *keyp, void (*destructor)(void *value))
|
||||
static inline int pthread_key_create(pthread_key_t *keyp, void (*destructor)(void *value) UNUSED)
|
||||
{
|
||||
return (*keyp = TlsAlloc()) == TLS_OUT_OF_INDEXES ? EAGAIN : 0;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
static HANDLE ms_eventlog;
|
||||
|
||||
void openlog(const char *ident, int logopt, int facility)
|
||||
void openlog(const char *ident, int logopt UNUSED, int facility UNUSED)
|
||||
{
|
||||
if (ms_eventlog)
|
||||
return;
|
||||
|
|
|
@ -40,7 +40,7 @@ void *git_mmap(void *start, size_t length, int prot, int flags, int fd, off_t of
|
|||
return MAP_FAILED;
|
||||
}
|
||||
|
||||
int git_munmap(void *start, size_t length)
|
||||
int git_munmap(void *start, size_t length UNUSED)
|
||||
{
|
||||
return !UnmapViewOfFile(start);
|
||||
}
|
||||
|
|
|
@ -340,7 +340,7 @@ enum {
|
|||
TEXT = 0, ESCAPE = 033, BRACKET = '['
|
||||
};
|
||||
|
||||
static DWORD WINAPI console_thread(LPVOID unused)
|
||||
static DWORD WINAPI console_thread(LPVOID data UNUSED)
|
||||
{
|
||||
unsigned char buffer[BUFFER_SIZE];
|
||||
DWORD bytes;
|
||||
|
|
|
@ -54,7 +54,6 @@ ifeq ($(filter extra-all,$(DEVOPTS)),)
|
|||
DEVELOPER_CFLAGS += -Wno-empty-body
|
||||
DEVELOPER_CFLAGS += -Wno-missing-field-initializers
|
||||
DEVELOPER_CFLAGS += -Wno-sign-compare
|
||||
DEVELOPER_CFLAGS += -Wno-unused-parameter
|
||||
endif
|
||||
endif
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ static ssize_t strbuf_add_void(void *b, const void *data, size_t sz)
|
|||
return sz;
|
||||
}
|
||||
|
||||
static int noop_flush(void *arg)
|
||||
static int noop_flush(void *arg UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue