Skip to content

Commit 2206040

Browse files
committed
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
2 parents 99bb1a0 + 4b992f0 commit 2206040

19 files changed

+70
-57
lines changed

apply.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ void clear_apply_state(struct apply_state *state)
125125
/* &state->fn_table is cleared at the end of apply_patch() */
126126
}
127127

128-
static void mute_routine(const char *msg, va_list params)
128+
static void mute_routine(const char *msg UNUSED, va_list params UNUSED)
129129
{
130130
/* do nothing */
131131
}
@@ -892,9 +892,9 @@ static int parse_traditional_patch(struct apply_state *state,
892892
return 0;
893893
}
894894

895-
static int gitdiff_hdrend(struct gitdiff_data *state,
896-
const char *line,
897-
struct patch *patch)
895+
static int gitdiff_hdrend(struct gitdiff_data *state UNUSED,
896+
const char *line UNUSED,
897+
struct patch *patch UNUSED)
898898
{
899899
return 1;
900900
}
@@ -1044,7 +1044,7 @@ static int gitdiff_renamedst(struct gitdiff_data *state,
10441044
return 0;
10451045
}
10461046

1047-
static int gitdiff_similarity(struct gitdiff_data *state,
1047+
static int gitdiff_similarity(struct gitdiff_data *state UNUSED,
10481048
const char *line,
10491049
struct patch *patch)
10501050
{
@@ -1054,7 +1054,7 @@ static int gitdiff_similarity(struct gitdiff_data *state,
10541054
return 0;
10551055
}
10561056

1057-
static int gitdiff_dissimilarity(struct gitdiff_data *state,
1057+
static int gitdiff_dissimilarity(struct gitdiff_data *state UNUSED,
10581058
const char *line,
10591059
struct patch *patch)
10601060
{
@@ -1104,9 +1104,9 @@ static int gitdiff_index(struct gitdiff_data *state,
11041104
* This is normal for a diff that doesn't change anything: we'll fall through
11051105
* into the next diff. Tell the parser to break out.
11061106
*/
1107-
static int gitdiff_unrecognized(struct gitdiff_data *state,
1108-
const char *line,
1109-
struct patch *patch)
1107+
static int gitdiff_unrecognized(struct gitdiff_data *state UNUSED,
1108+
const char *line UNUSED,
1109+
struct patch *patch UNUSED)
11101110
{
11111111
return 1;
11121112
}

archive.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ static void parse_treeish_arg(const char **argv,
498498
ar_args->time = archive_time;
499499
}
500500

501-
static void extra_file_info_clear(void *util, const char *str)
501+
static void extra_file_info_clear(void *util, const char *str UNUSED)
502502
{
503503
struct extra_file_info *info = util;
504504
free(info->base);

builtin/gc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ static uint64_t estimate_repack_memory(struct packed_git *pack)
322322
return os_cache + heap;
323323
}
324324

325-
static int keep_one_pack(struct string_list_item *item, void *data)
325+
static int keep_one_pack(struct string_list_item *item, void *data UNUSED)
326326
{
327327
strvec_pushf(&repack, "--keep-pack=%s", basename(item->string));
328328
return 0;

builtin/remote.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -942,7 +942,7 @@ static int rm(int argc, const char **argv, const char *prefix)
942942
return result;
943943
}
944944

945-
static void clear_push_info(void *util, const char *string)
945+
static void clear_push_info(void *util, const char *string UNUSED)
946946
{
947947
struct push_info *info = util;
948948
free(info->dest);

builtin/submodule--helper.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ static void module_list_release(struct module_list *ml)
181181
free(ml->entries);
182182
}
183183

184-
static int module_list_compute(int argc, const char **argv,
184+
static int module_list_compute(const char **argv,
185185
const char *prefix,
186186
struct pathspec *pathspec,
187187
struct module_list *list)
@@ -405,7 +405,7 @@ static int module_foreach(int argc, const char **argv, const char *prefix)
405405
argc = parse_options(argc, argv, prefix, module_foreach_options,
406406
git_submodule_helper_usage, 0);
407407

408-
if (module_list_compute(0, NULL, prefix, &pathspec, &list) < 0)
408+
if (module_list_compute(NULL, prefix, &pathspec, &list) < 0)
409409
goto cleanup;
410410

411411
info.argc = argc;
@@ -545,7 +545,7 @@ static int module_init(int argc, const char **argv, const char *prefix)
545545
argc = parse_options(argc, argv, prefix, module_init_options,
546546
git_submodule_helper_usage, 0);
547547

548-
if (module_list_compute(argc, argv, prefix, &pathspec, &list) < 0)
548+
if (module_list_compute(argv, prefix, &pathspec, &list) < 0)
549549
goto cleanup;
550550

551551
/*
@@ -732,7 +732,7 @@ static int module_status(int argc, const char **argv, const char *prefix)
732732
argc = parse_options(argc, argv, prefix, module_status_options,
733733
git_submodule_helper_usage, 0);
734734

735-
if (module_list_compute(argc, argv, prefix, &pathspec, &list) < 0)
735+
if (module_list_compute(argv, prefix, &pathspec, &list) < 0)
736736
goto cleanup;
737737

738738
info.prefix = prefix;
@@ -1326,7 +1326,7 @@ static int module_sync(int argc, const char **argv, const char *prefix)
13261326
argc = parse_options(argc, argv, prefix, module_sync_options,
13271327
git_submodule_helper_usage, 0);
13281328

1329-
if (module_list_compute(argc, argv, prefix, &pathspec, &list) < 0)
1329+
if (module_list_compute(argv, prefix, &pathspec, &list) < 0)
13301330
goto cleanup;
13311331

13321332
info.prefix = prefix;
@@ -1479,7 +1479,7 @@ static int module_deinit(int argc, const char **argv, const char *prefix)
14791479
if (!argc && !all)
14801480
die(_("Use '--all' if you really want to deinitialize all submodules"));
14811481

1482-
if (module_list_compute(argc, argv, prefix, &pathspec, &list) < 0)
1482+
if (module_list_compute(argv, prefix, &pathspec, &list) < 0)
14831483
goto cleanup;
14841484

14851485
info.prefix = prefix;
@@ -2697,7 +2697,7 @@ static int module_update(int argc, const char **argv, const char *prefix)
26972697
if (opt.update_default)
26982698
opt.update_strategy.type = opt.update_default;
26992699

2700-
if (module_list_compute(argc, argv, prefix, &pathspec, &opt.list) < 0) {
2700+
if (module_list_compute(argv, prefix, &pathspec, &opt.list) < 0) {
27012701
ret = 1;
27022702
goto cleanup;
27032703
}
@@ -2709,7 +2709,7 @@ static int module_update(int argc, const char **argv, const char *prefix)
27092709
struct module_list list = MODULE_LIST_INIT;
27102710
struct init_cb info = INIT_CB_INIT;
27112711

2712-
if (module_list_compute(argc, argv, opt.prefix,
2712+
if (module_list_compute(argv, opt.prefix,
27132713
&pathspec2, &list) < 0) {
27142714
module_list_release(&list);
27152715
ret = 1;
@@ -2840,7 +2840,7 @@ static int absorb_git_dirs(int argc, const char **argv, const char *prefix)
28402840
argc = parse_options(argc, argv, prefix, embed_gitdir_options,
28412841
git_submodule_helper_usage, 0);
28422842

2843-
if (module_list_compute(argc, argv, prefix, &pathspec, &list) < 0)
2843+
if (module_list_compute(argv, prefix, &pathspec, &list) < 0)
28442844
goto cleanup;
28452845

28462846
for (i = 0; i < list.nr; i++)

builtin/update-index.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ static int do_unresolve(int ac, const char **av,
732732
return err;
733733
}
734734

735-
static int do_reupdate(int ac, const char **av,
735+
static int do_reupdate(const char **paths,
736736
const char *prefix)
737737
{
738738
/* Read HEAD and run update-index on paths that are
@@ -744,7 +744,7 @@ static int do_reupdate(int ac, const char **av,
744744

745745
parse_pathspec(&pathspec, 0,
746746
PATHSPEC_PREFER_CWD,
747-
prefix, av + 1);
747+
prefix, paths);
748748

749749
if (read_ref("HEAD", &head_oid))
750750
/* If there is no HEAD, that means it is an initial
@@ -970,7 +970,7 @@ static enum parse_opt_result reupdate_callback(
970970

971971
/* consume remaining arguments. */
972972
setup_work_tree();
973-
*has_errors = do_reupdate(ctx->argc, ctx->argv, prefix);
973+
*has_errors = do_reupdate(ctx->argv + 1, prefix);
974974
if (*has_errors)
975975
active_cache_changed = 0;
976976

compat/nonblock.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ int enable_pipe_nonblock(int fd)
4141

4242
#else
4343

44-
int enable_pipe_nonblock(int fd)
44+
int enable_pipe_nonblock(int fd UNUSED)
4545
{
4646
errno = ENOSYS;
4747
return -1;

convert.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1549,7 +1549,7 @@ struct stream_filter {
15491549
struct stream_filter_vtbl *vtbl;
15501550
};
15511551

1552-
static int null_filter_fn(struct stream_filter *filter,
1552+
static int null_filter_fn(struct stream_filter *filter UNUSED,
15531553
const char *input, size_t *isize_p,
15541554
char *output, size_t *osize_p)
15551555
{
@@ -1568,7 +1568,7 @@ static int null_filter_fn(struct stream_filter *filter,
15681568
return 0;
15691569
}
15701570

1571-
static void null_free_fn(struct stream_filter *filter)
1571+
static void null_free_fn(struct stream_filter *filter UNUSED)
15721572
{
15731573
; /* nothing -- null instances are shared */
15741574
}

date.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,7 @@ static void date_tea(struct tm *tm, struct tm *now, int *num)
11011101
date_time(tm, now, 17);
11021102
}
11031103

1104-
static void date_pm(struct tm *tm, struct tm *now, int *num)
1104+
static void date_pm(struct tm *tm, struct tm *now UNUSED, int *num)
11051105
{
11061106
int hour, n = *num;
11071107
*num = 0;
@@ -1115,7 +1115,7 @@ static void date_pm(struct tm *tm, struct tm *now, int *num)
11151115
tm->tm_hour = (hour % 12) + 12;
11161116
}
11171117

1118-
static void date_am(struct tm *tm, struct tm *now, int *num)
1118+
static void date_am(struct tm *tm, struct tm *now UNUSED, int *num)
11191119
{
11201120
int hour, n = *num;
11211121
*num = 0;
@@ -1129,7 +1129,7 @@ static void date_am(struct tm *tm, struct tm *now, int *num)
11291129
tm->tm_hour = (hour % 12);
11301130
}
11311131

1132-
static void date_never(struct tm *tm, struct tm *now, int *num)
1132+
static void date_never(struct tm *tm, struct tm *now UNUSED, int *num)
11331133
{
11341134
time_t n = 0;
11351135
localtime_r(&n, tm);

diff.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2488,6 +2488,9 @@ static int diffstat_consume(void *priv, char *line, unsigned long len)
24882488
struct diffstat_t *diffstat = priv;
24892489
struct diffstat_file *x = diffstat->files[diffstat->nr - 1];
24902490

2491+
if (!len)
2492+
BUG("xdiff fed us an empty line");
2493+
24912494
if (line[0] == '+')
24922495
x->added++;
24932496
else if (line[0] == '-')

0 commit comments

Comments
 (0)