diff --git a/apply.c b/apply.c index 2b7cd930ef..6b4dbe0c88 100644 --- a/apply.c +++ b/apply.c @@ -125,7 +125,7 @@ void clear_apply_state(struct apply_state *state) /* &state->fn_table is cleared at the end of apply_patch() */ } -static void mute_routine(const char *msg, va_list params) +static void mute_routine(const char *msg UNUSED, va_list params UNUSED) { /* do nothing */ } @@ -892,9 +892,9 @@ static int parse_traditional_patch(struct apply_state *state, return 0; } -static int gitdiff_hdrend(struct gitdiff_data *state, - const char *line, - struct patch *patch) +static int gitdiff_hdrend(struct gitdiff_data *state UNUSED, + const char *line UNUSED, + struct patch *patch UNUSED) { return 1; } @@ -1044,7 +1044,7 @@ static int gitdiff_renamedst(struct gitdiff_data *state, return 0; } -static int gitdiff_similarity(struct gitdiff_data *state, +static int gitdiff_similarity(struct gitdiff_data *state UNUSED, const char *line, struct patch *patch) { @@ -1054,7 +1054,7 @@ static int gitdiff_similarity(struct gitdiff_data *state, return 0; } -static int gitdiff_dissimilarity(struct gitdiff_data *state, +static int gitdiff_dissimilarity(struct gitdiff_data *state UNUSED, const char *line, struct patch *patch) { @@ -1104,9 +1104,9 @@ static int gitdiff_index(struct gitdiff_data *state, * This is normal for a diff that doesn't change anything: we'll fall through * into the next diff. Tell the parser to break out. */ -static int gitdiff_unrecognized(struct gitdiff_data *state, - const char *line, - struct patch *patch) +static int gitdiff_unrecognized(struct gitdiff_data *state UNUSED, + const char *line UNUSED, + struct patch *patch UNUSED) { return 1; } diff --git a/archive.c b/archive.c index cc1087262f..941495f5d7 100644 --- a/archive.c +++ b/archive.c @@ -498,7 +498,7 @@ static void parse_treeish_arg(const char **argv, ar_args->time = archive_time; } -static void extra_file_info_clear(void *util, const char *str) +static void extra_file_info_clear(void *util, const char *str UNUSED) { struct extra_file_info *info = util; free(info->base); diff --git a/builtin/gc.c b/builtin/gc.c index 243ee85d28..24ea85c7af 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -322,7 +322,7 @@ static uint64_t estimate_repack_memory(struct packed_git *pack) return os_cache + heap; } -static int keep_one_pack(struct string_list_item *item, void *data) +static int keep_one_pack(struct string_list_item *item, void *data UNUSED) { strvec_pushf(&repack, "--keep-pack=%s", basename(item->string)); return 0; diff --git a/builtin/remote.c b/builtin/remote.c index 910f7b9316..93285fc06e 100644 --- a/builtin/remote.c +++ b/builtin/remote.c @@ -942,7 +942,7 @@ static int rm(int argc, const char **argv, const char *prefix) return result; } -static void clear_push_info(void *util, const char *string) +static void clear_push_info(void *util, const char *string UNUSED) { struct push_info *info = util; free(info->dest); diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 0b4acb442b..1e29a3d7dc 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -181,7 +181,7 @@ static void module_list_release(struct module_list *ml) free(ml->entries); } -static int module_list_compute(int argc, const char **argv, +static int module_list_compute(const char **argv, const char *prefix, struct pathspec *pathspec, struct module_list *list) @@ -405,7 +405,7 @@ static int module_foreach(int argc, const char **argv, const char *prefix) argc = parse_options(argc, argv, prefix, module_foreach_options, git_submodule_helper_usage, 0); - if (module_list_compute(0, NULL, prefix, &pathspec, &list) < 0) + if (module_list_compute(NULL, prefix, &pathspec, &list) < 0) goto cleanup; info.argc = argc; @@ -545,7 +545,7 @@ static int module_init(int argc, const char **argv, const char *prefix) argc = parse_options(argc, argv, prefix, module_init_options, git_submodule_helper_usage, 0); - if (module_list_compute(argc, argv, prefix, &pathspec, &list) < 0) + if (module_list_compute(argv, prefix, &pathspec, &list) < 0) goto cleanup; /* @@ -732,7 +732,7 @@ static int module_status(int argc, const char **argv, const char *prefix) argc = parse_options(argc, argv, prefix, module_status_options, git_submodule_helper_usage, 0); - if (module_list_compute(argc, argv, prefix, &pathspec, &list) < 0) + if (module_list_compute(argv, prefix, &pathspec, &list) < 0) goto cleanup; info.prefix = prefix; @@ -1326,7 +1326,7 @@ static int module_sync(int argc, const char **argv, const char *prefix) argc = parse_options(argc, argv, prefix, module_sync_options, git_submodule_helper_usage, 0); - if (module_list_compute(argc, argv, prefix, &pathspec, &list) < 0) + if (module_list_compute(argv, prefix, &pathspec, &list) < 0) goto cleanup; info.prefix = prefix; @@ -1479,7 +1479,7 @@ static int module_deinit(int argc, const char **argv, const char *prefix) if (!argc && !all) die(_("Use '--all' if you really want to deinitialize all submodules")); - if (module_list_compute(argc, argv, prefix, &pathspec, &list) < 0) + if (module_list_compute(argv, prefix, &pathspec, &list) < 0) goto cleanup; info.prefix = prefix; @@ -2697,7 +2697,7 @@ static int module_update(int argc, const char **argv, const char *prefix) if (opt.update_default) opt.update_strategy.type = opt.update_default; - if (module_list_compute(argc, argv, prefix, &pathspec, &opt.list) < 0) { + if (module_list_compute(argv, prefix, &pathspec, &opt.list) < 0) { ret = 1; goto cleanup; } @@ -2709,7 +2709,7 @@ static int module_update(int argc, const char **argv, const char *prefix) struct module_list list = MODULE_LIST_INIT; struct init_cb info = INIT_CB_INIT; - if (module_list_compute(argc, argv, opt.prefix, + if (module_list_compute(argv, opt.prefix, &pathspec2, &list) < 0) { module_list_release(&list); ret = 1; @@ -2840,7 +2840,7 @@ static int absorb_git_dirs(int argc, const char **argv, const char *prefix) argc = parse_options(argc, argv, prefix, embed_gitdir_options, git_submodule_helper_usage, 0); - if (module_list_compute(argc, argv, prefix, &pathspec, &list) < 0) + if (module_list_compute(argv, prefix, &pathspec, &list) < 0) goto cleanup; for (i = 0; i < list.nr; i++) diff --git a/builtin/update-index.c b/builtin/update-index.c index b62249905f..7b0c924d7d 100644 --- a/builtin/update-index.c +++ b/builtin/update-index.c @@ -732,7 +732,7 @@ static int do_unresolve(int ac, const char **av, return err; } -static int do_reupdate(int ac, const char **av, +static int do_reupdate(const char **paths, const char *prefix) { /* Read HEAD and run update-index on paths that are @@ -744,7 +744,7 @@ static int do_reupdate(int ac, const char **av, parse_pathspec(&pathspec, 0, PATHSPEC_PREFER_CWD, - prefix, av + 1); + prefix, paths); if (read_ref("HEAD", &head_oid)) /* If there is no HEAD, that means it is an initial @@ -970,7 +970,7 @@ static enum parse_opt_result reupdate_callback( /* consume remaining arguments. */ setup_work_tree(); - *has_errors = do_reupdate(ctx->argc, ctx->argv, prefix); + *has_errors = do_reupdate(ctx->argv + 1, prefix); if (*has_errors) active_cache_changed = 0; diff --git a/compat/nonblock.c b/compat/nonblock.c index 9694ebdb1d..5b51195c32 100644 --- a/compat/nonblock.c +++ b/compat/nonblock.c @@ -41,7 +41,7 @@ int enable_pipe_nonblock(int fd) #else -int enable_pipe_nonblock(int fd) +int enable_pipe_nonblock(int fd UNUSED) { errno = ENOSYS; return -1; diff --git a/convert.c b/convert.c index 95e6a5244f..9b67649032 100644 --- a/convert.c +++ b/convert.c @@ -1549,7 +1549,7 @@ struct stream_filter { struct stream_filter_vtbl *vtbl; }; -static int null_filter_fn(struct stream_filter *filter, +static int null_filter_fn(struct stream_filter *filter UNUSED, const char *input, size_t *isize_p, char *output, size_t *osize_p) { @@ -1568,7 +1568,7 @@ static int null_filter_fn(struct stream_filter *filter, return 0; } -static void null_free_fn(struct stream_filter *filter) +static void null_free_fn(struct stream_filter *filter UNUSED) { ; /* nothing -- null instances are shared */ } diff --git a/date.c b/date.c index 68a260c214..53bd6a7932 100644 --- a/date.c +++ b/date.c @@ -1101,7 +1101,7 @@ static void date_tea(struct tm *tm, struct tm *now, int *num) date_time(tm, now, 17); } -static void date_pm(struct tm *tm, struct tm *now, int *num) +static void date_pm(struct tm *tm, struct tm *now UNUSED, int *num) { int hour, n = *num; *num = 0; @@ -1115,7 +1115,7 @@ static void date_pm(struct tm *tm, struct tm *now, int *num) tm->tm_hour = (hour % 12) + 12; } -static void date_am(struct tm *tm, struct tm *now, int *num) +static void date_am(struct tm *tm, struct tm *now UNUSED, int *num) { int hour, n = *num; *num = 0; @@ -1129,7 +1129,7 @@ static void date_am(struct tm *tm, struct tm *now, int *num) tm->tm_hour = (hour % 12); } -static void date_never(struct tm *tm, struct tm *now, int *num) +static void date_never(struct tm *tm, struct tm *now UNUSED, int *num) { time_t n = 0; localtime_r(&n, tm); diff --git a/diff.c b/diff.c index 648f6717a5..bba888a34a 100644 --- a/diff.c +++ b/diff.c @@ -2488,6 +2488,9 @@ static int diffstat_consume(void *priv, char *line, unsigned long len) struct diffstat_t *diffstat = priv; struct diffstat_file *x = diffstat->files[diffstat->nr - 1]; + if (!len) + BUG("xdiff fed us an empty line"); + if (line[0] == '+') x->added++; else if (line[0] == '-') diff --git a/diffcore-pickaxe.c b/diffcore-pickaxe.c index c88e50c632..03fcbcb40b 100644 --- a/diffcore-pickaxe.c +++ b/diffcore-pickaxe.c @@ -38,7 +38,7 @@ static int diffgrep_consume(void *priv, char *line, unsigned long len) static int diff_grep(mmfile_t *one, mmfile_t *two, struct diff_options *o, - regex_t *regexp, kwset_t kws) + regex_t *regexp, kwset_t kws UNUSED) { struct diffgrep_cb ecbdata; xpparam_t xpp; @@ -114,7 +114,7 @@ static unsigned int contains(mmfile_t *mf, regex_t *regexp, kwset_t kws, } static int has_changes(mmfile_t *one, mmfile_t *two, - struct diff_options *o, + struct diff_options *o UNUSED, regex_t *regexp, kwset_t kws) { unsigned int c1 = one ? contains(one, regexp, kws, 0) : 0; diff --git a/exec-cmd.c b/exec-cmd.c index eeb2ee52b8..0232bbc990 100644 --- a/exec-cmd.c +++ b/exec-cmd.c @@ -252,7 +252,7 @@ static const char *system_prefix(void) * This is called during initialization, but No work needs to be done here when * runtime prefix is not being used. */ -void git_resolve_executable_dir(const char *argv0) +void git_resolve_executable_dir(const char *argv0 UNUSED) { } diff --git a/git-compat-util.h b/git-compat-util.h index ea53ea4a78..a76d0526f7 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -314,7 +314,9 @@ typedef unsigned long uintptr_t; #ifdef PRECOMPOSE_UNICODE #include "compat/precompose_utf8.h" #else -static inline const char *precompose_argv_prefix(int argc, const char **argv, const char *prefix) +static inline const char *precompose_argv_prefix(int argc UNUSED, + const char **argv UNUSED, + const char *prefix) { return prefix; } @@ -339,7 +341,9 @@ struct itimerval { #endif #ifdef NO_SETITIMER -static inline int setitimer(int which, const struct itimerval *value, struct itimerval *newvalue) { +static inline int setitimer(int which UNUSED, + const struct itimerval *value UNUSED, + struct itimerval *newvalue UNUSED) { return 0; /* pretend success */ } #endif @@ -424,7 +428,7 @@ int lstat_cache_aware_rmdir(const char *path); #endif #ifndef has_dos_drive_prefix -static inline int git_has_dos_drive_prefix(const char *path) +static inline int git_has_dos_drive_prefix(const char *path UNUSED) { return 0; } @@ -432,7 +436,7 @@ static inline int git_has_dos_drive_prefix(const char *path) #endif #ifndef skip_dos_drive_prefix -static inline int git_skip_dos_drive_prefix(char **path) +static inline int git_skip_dos_drive_prefix(char **path UNUSED) { return 0; } @@ -1467,11 +1471,11 @@ int open_nofollow(const char *path, int flags); #endif #ifndef _POSIX_THREAD_SAFE_FUNCTIONS -static inline void flockfile(FILE *fh) +static inline void flockfile(FILE *fh UNUSED) { ; /* nothing */ } -static inline void funlockfile(FILE *fh) +static inline void funlockfile(FILE *fh UNUSED) { ; /* nothing */ } diff --git a/ll-merge.c b/ll-merge.c index 8955d7e1f6..a8e2db9336 100644 --- a/ll-merge.c +++ b/ll-merge.c @@ -49,14 +49,14 @@ void reset_merge_attributes(void) /* * Built-in low-levels */ -static enum ll_merge_result ll_binary_merge(const struct ll_merge_driver *drv_unused, +static enum ll_merge_result ll_binary_merge(const struct ll_merge_driver *drv UNUSED, mmbuffer_t *result, - const char *path, - mmfile_t *orig, const char *orig_name, - mmfile_t *src1, const char *name1, - mmfile_t *src2, const char *name2, + const char *path UNUSED, + mmfile_t *orig, const char *orig_name UNUSED, + mmfile_t *src1, const char *name1 UNUSED, + mmfile_t *src2, const char *name2 UNUSED, const struct ll_merge_options *opts, - int marker_size) + int marker_size UNUSED) { enum ll_merge_result ret; mmfile_t *stolen; @@ -183,9 +183,9 @@ static void create_temp(mmfile_t *src, char *path, size_t len) static enum ll_merge_result ll_ext_merge(const struct ll_merge_driver *fn, mmbuffer_t *result, const char *path, - mmfile_t *orig, const char *orig_name, - mmfile_t *src1, const char *name1, - mmfile_t *src2, const char *name2, + mmfile_t *orig, const char *orig_name UNUSED, + mmfile_t *src1, const char *name1 UNUSED, + mmfile_t *src2, const char *name2 UNUSED, const struct ll_merge_options *opts, int marker_size) { diff --git a/merge-ort.c b/merge-ort.c index e5f41cce48..7e83ebfaa9 100644 --- a/merge-ort.c +++ b/merge-ort.c @@ -397,7 +397,7 @@ struct conflicted_submodule_item { int flag; }; -static void conflicted_submodule_item_free(void *util, const char *str) +static void conflicted_submodule_item_free(void *util, const char *str UNUSED) { struct conflicted_submodule_item *item = util; diff --git a/object-file.c b/object-file.c index 5e30960234..957790098f 100644 --- a/object-file.c +++ b/object-file.c @@ -140,27 +140,32 @@ static void git_hash_sha256_final_oid(struct object_id *oid, git_hash_ctx *ctx) oid->algo = GIT_HASH_SHA256; } -static void git_hash_unknown_init(git_hash_ctx *ctx) +static void git_hash_unknown_init(git_hash_ctx *ctx UNUSED) { BUG("trying to init unknown hash"); } -static void git_hash_unknown_clone(git_hash_ctx *dst, const git_hash_ctx *src) +static void git_hash_unknown_clone(git_hash_ctx *dst UNUSED, + const git_hash_ctx *src UNUSED) { BUG("trying to clone unknown hash"); } -static void git_hash_unknown_update(git_hash_ctx *ctx, const void *data, size_t len) +static void git_hash_unknown_update(git_hash_ctx *ctx UNUSED, + const void *data UNUSED, + size_t len UNUSED) { BUG("trying to update unknown hash"); } -static void git_hash_unknown_final(unsigned char *hash, git_hash_ctx *ctx) +static void git_hash_unknown_final(unsigned char *hash UNUSED, + git_hash_ctx *ctx UNUSED) { BUG("trying to finalize unknown hash"); } -static void git_hash_unknown_final_oid(struct object_id *oid, git_hash_ctx *ctx) +static void git_hash_unknown_final_oid(struct object_id *oid UNUSED, + git_hash_ctx *ctx UNUSED) { BUG("trying to finalize unknown hash"); } diff --git a/reflog-walk.c b/reflog-walk.c index 7aa6595a51..8a4d8fa3bd 100644 --- a/reflog-walk.c +++ b/reflog-walk.c @@ -55,7 +55,7 @@ static void free_complete_reflog(struct complete_reflogs *array) free(array); } -static void complete_reflogs_clear(void *util, const char *str) +static void complete_reflogs_clear(void *util, const char *str UNUSED) { struct complete_reflogs *array = util; free_complete_reflog(array); diff --git a/string-list.c b/string-list.c index 549fc416d6..42bacaec55 100644 --- a/string-list.c +++ b/string-list.c @@ -156,7 +156,7 @@ void filter_string_list(struct string_list *list, int free_util, list->nr = dst; } -static int item_is_not_empty(struct string_list_item *item, void *unused) +static int item_is_not_empty(struct string_list_item *item, void *data UNUSED) { return *item->string != '\0'; } diff --git a/t/helper/test-path-utils.c b/t/helper/test-path-utils.c index d20e1b7a18..f69709d674 100644 --- a/t/helper/test-path-utils.c +++ b/t/helper/test-path-utils.c @@ -8,7 +8,8 @@ * GIT_CEILING_DIRECTORIES. If the path is unusable for some reason, * die with an explanation. */ -static int normalize_ceiling_entry(struct string_list_item *item, void *unused) +static int normalize_ceiling_entry(struct string_list_item *item, + void *data UNUSED) { char *ceil = item->string;