diff: mark unused parameters in callbacks

The diff code provides a format_callback interface, but not every callback needs each parameter (e.g., the "opt" and "data" parameters are frequently left unused). Likewise for the output_prefix callback, the low-level change/add_remove interfaces, the callbacks used by xdi_diff(), etc. Mark unused arguments in the callback implementations to quiet -Wunused-parameter. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Dec 13, 2022 at 06:13 UTC 61bdc7c5d8b1dedc5f9c3af45c5738d14136ae90
15 files changed +41 -30
add-interactive.c
+1 -1
@@ -724,7 +724,7 @@ static int run_update(struct add_i_state *s, const struct pathspec *ps,
724 }
725
726 static void revert_from_diff(struct diff_queue_struct *q,
727 - struct diff_options *opt, void *data)
727 + struct diff_options *opt, void *data UNUSED)
728 {
729 int i, add_flags = ADD_CACHE_OK_TO_ADD | ADD_CACHE_OK_TO_REPLACE;
730
builtin/add.c
+1 -1
@@ -88,7 +88,7 @@ static int fix_unmerged_status(struct diff_filepair *p,
88 }
89
90 static void update_callback(struct diff_queue_struct *q,
91 - struct diff_options *opt, void *cbdata)
91 + struct diff_options *opt UNUSED, void *cbdata)
92 {
93 int i;
94 struct update_callback_data *data = cbdata;
builtin/fast-export.c
+1 -1
@@ -409,7 +409,7 @@ static const char *anonymize_oid(const char *oid_hex)
409 }
410
411 static void show_filemodify(struct diff_queue_struct *q,
412 - struct diff_options *options, void *data)
412 + struct diff_options *options UNUSED, void *data)
413 {
414 int i;
415 struct string_list *changed = data;
builtin/merge-tree.c
+1 -1
@@ -98,7 +98,7 @@ static void *origin(struct merge_list *entry, unsigned long *size)
98 return NULL;
99 }
100
101 -static int show_outf(void *priv_, mmbuffer_t *mb, int nbuf)
101 +static int show_outf(void *priv UNUSED, mmbuffer_t *mb, int nbuf)
102 {
103 int i;
104 for (i = 0; i < nbuf; i++)
builtin/merge.c
+1 -1
@@ -776,7 +776,7 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
776 }
777
778 static void count_diff_files(struct diff_queue_struct *q,
779 - struct diff_options *opt, void *data)
779 + struct diff_options *opt UNUSED, void *data)
780 {
781 int *count = data;
782
builtin/rerere.c
+1 -1
@@ -14,7 +14,7 @@ static const char * const rerere_usage[] = {
14 NULL,
15 };
16
17 -static int outf(void *dummy, mmbuffer_t *ptr, int nbuf)
17 +static int outf(void *dummy UNUSED, mmbuffer_t *ptr, int nbuf)
18 {
19 int i;
20 for (i = 0; i < nbuf; i++)
builtin/reset.c
+2 -1
@@ -133,7 +133,8 @@ static void print_new_head_line(struct commit *commit)
133 }
134
135 static void update_index_from_diff(struct diff_queue_struct *q,
136 - struct diff_options *opt, void *data)
136 + struct diff_options *opt UNUSED,
137 + void *data)
138 {
139 int i;
140 int intent_to_add = *(int *)data;
builtin/submodule--helper.c
+1 -1
@@ -1043,7 +1043,7 @@ static void prepare_submodule_summary(struct summary_cb *info,
1043 }
1044
1045 static void submodule_summary_callback(struct diff_queue_struct *q,
1046 - struct diff_options *options,
1046 + struct diff_options *options UNUSED,
1047 void *data)
1048 {
1049 int i;
combine-diff.c
+1 -1
@@ -372,7 +372,7 @@ struct combine_diff_state {
372 static void consume_hunk(void *state_,
373 long ob, long on,
374 long nb, long nn,
375 - const char *funcline, long funclen)
375 + const char *func UNUSED, long funclen UNUSED)
376 {
377 struct combine_diff_state *state = state_;
378
diff-lib.c
+1 -1
@@ -673,7 +673,7 @@ int index_differs_from(struct repository *r,
673 return (has_changes != 0);
674 }
675
676 -static struct strbuf *idiff_prefix_cb(struct diff_options *opt, void *data)
676 +static struct strbuf *idiff_prefix_cb(struct diff_options *opt UNUSED, void *data)
677 {
678 return data;
679 }
diff.c
+4 -3
@@ -1954,7 +1954,7 @@ static int color_words_output_graph_prefix(struct diff_words_data *diff_words)
1954 static void fn_out_diff_words_aux(void *priv,
1955 long minus_first, long minus_len,
1956 long plus_first, long plus_len,
1957 - const char *func, long funclen)
1957 + const char *func UNUSED, long funclen UNUSED)
1958 {
1959 struct diff_words_data *diff_words = priv;
1960 struct diff_words_style *style = diff_words->style;
@@ -3184,8 +3184,9 @@ static int is_conflict_marker(const char *line, int marker_size, unsigned long l
3184 }
3185
3186 static void checkdiff_consume_hunk(void *priv,
3187 - long ob, long on, long nb, long nn,
3188 - const char *func, long funclen)
3187 + long ob UNUSED, long on UNUSED,
3188 + long nb, long nn UNUSED,
3189 + const char *func UNUSED, long funclen UNUSED)
3190
3191 {
3192 struct checkdiff_t *data = priv;
range-diff.c
+8 -4
@@ -269,14 +269,18 @@ static void find_exact_matches(struct string_list *a, struct string_list *b)
269 hashmap_clear(&map);
270 }
271
272 -static int diffsize_consume(void *data, char *line, unsigned long len)
272 +static int diffsize_consume(void *data,
273 + char *line UNUSED,
274 + unsigned long len UNUSED)
275 {
276 (*(int *)data)++;
277 return 0;
278 }
279
278 -static void diffsize_hunk(void *data, long ob, long on, long nb, long nn,
279 - const char *funcline, long funclen)
280 +static void diffsize_hunk(void *data,
281 + long ob UNUSED, long on UNUSED,
282 + long nb UNUSED, long nn UNUSED,
283 + const char *func UNUSED, long funclen UNUSED)
284 {
285 diffsize_consume(data, NULL, 0);
286 }
@@ -461,7 +465,7 @@ static void patch_diff(const char *a, const char *b,
465 diff_flush(diffopt);
466 }
467
464 -static struct strbuf *output_prefix_cb(struct diff_options *opt, void *data)
468 +static struct strbuf *output_prefix_cb(struct diff_options *opt UNUSED, void *data)
469 {
470 return data;
471 }
revision.c
+15 -10
@@ -600,10 +600,12 @@ static struct commit *one_relevant_parent(const struct rev_info *revs,
600 static int tree_difference = REV_TREE_SAME;
601
602 static void file_add_remove(struct diff_options *options,
603 - int addremove, unsigned mode,
604 - const struct object_id *oid,
605 - int oid_valid,
606 - const char *fullpath, unsigned dirty_submodule)
603 + int addremove,
604 + unsigned mode UNUSED,
605 + const struct object_id *oid UNUSED,
606 + int oid_valid UNUSED,
607 + const char *fullpath UNUSED,
608 + unsigned dirty_submodule UNUSED)
609 {
610 int diff = addremove == '+' ? REV_TREE_NEW : REV_TREE_OLD;
611 struct rev_info *revs = options->change_fn_data;
@@ -614,12 +616,15 @@ static void file_add_remove(struct diff_options *options,
616 }
617
618 static void file_change(struct diff_options *options,
617 - unsigned old_mode, unsigned new_mode,
618 - const struct object_id *old_oid,
619 - const struct object_id *new_oid,
620 - int old_oid_valid, int new_oid_valid,
621 - const char *fullpath,
622 - unsigned old_dirty_submodule, unsigned new_dirty_submodule)
619 + unsigned old_mode UNUSED,
620 + unsigned new_mode UNUSED,
621 + const struct object_id *old_oid UNUSED,
622 + const struct object_id *new_oid UNUSED,
623 + int old_oid_valid UNUSED,
624 + int new_oid_valid UNUSED,
625 + const char *fullpath UNUSED,
626 + unsigned old_dirty_submodule UNUSED,
627 + unsigned new_dirty_submodule UNUSED)
628 {
629 tree_difference = REV_TREE_DIFFERENT;
630 options->flags.has_changes = 1;
submodule.c
+1 -1
@@ -832,7 +832,7 @@ static void changed_submodule_data_clear(struct changed_submodule_data *cs_data)
832 }
833
834 static void collect_changed_submodules_cb(struct diff_queue_struct *q,
835 - struct diff_options *options,
835 + struct diff_options *options UNUSED,
836 void *data)
837 {
838 struct collect_changed_submodules_cb_data *me = data;
wt-status.c
+2 -2
@@ -438,7 +438,7 @@ static char short_submodule_status(struct wt_status_change_data *d)
438 }
439
440 static void wt_status_collect_changed_cb(struct diff_queue_struct *q,
441 - struct diff_options *options,
441 + struct diff_options *options UNUSED,
442 void *data)
443 {
444 struct wt_status *s = data;
@@ -525,7 +525,7 @@ static int unmerged_mask(struct index_state *istate, const char *path)
525 }
526
527 static void wt_status_collect_updated_cb(struct diff_queue_struct *q,
528 - struct diff_options *options,
528 + struct diff_options *options UNUSED,
529 void *data)
530 {
531 struct wt_status *s = data;