Merge branch 'jk/unused-anno-more'

More UNUSED annotation to help using -Wunused option with the
compiler.

* jk/unused-anno-more:
  ll-merge: mark unused parameters in callbacks
  diffcore-pickaxe: mark unused parameters in pickaxe functions
  convert: mark unused parameter in null stream filter
  apply: mark unused parameters in noop error/warning routine
  apply: mark unused parameters in handlers
  date: mark unused parameters in handler functions
  string-list: mark unused callback parameters
  object-file: mark unused parameters in hash_unknown functions
  mark unused parameters in trivial compat functions
  update-index: drop unused argc from do_reupdate()
  submodule--helper: drop unused argc from module_list_compute()
  diffstat_consume(): assert non-zero length
This commit is contained in:
Junio C Hamano 2022-10-27 14:51:52 -07:00
commit 220604042c
19 changed files with 70 additions and 57 deletions

18
apply.c
View File

@ -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;
}

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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++)

View File

@ -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;

View File

@ -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;

View File

@ -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 */
}

6
date.c
View File

@ -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);

3
diff.c
View File

@ -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] == '-')

View File

@ -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;

View File

@ -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)
{
}

View File

@ -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 */
}

View File

@ -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)
{

View File

@ -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;

View File

@ -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");
}

View File

@ -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);

View File

@ -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';
}

View File

@ -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;