Skip to content

Commit 61bdc7c

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8157ed4 commit 61bdc7c

15 files changed

+41
-30
lines changed

add-interactive.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ static int run_update(struct add_i_state *s, const struct pathspec *ps,
724724
}
725725

726726
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)
728728
{
729729
int i, add_flags = ADD_CACHE_OK_TO_ADD | ADD_CACHE_OK_TO_REPLACE;
730730

builtin/add.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ static int fix_unmerged_status(struct diff_filepair *p,
8888
}
8989

9090
static void update_callback(struct diff_queue_struct *q,
91-
struct diff_options *opt, void *cbdata)
91+
struct diff_options *opt UNUSED, void *cbdata)
9292
{
9393
int i;
9494
struct update_callback_data *data = cbdata;

builtin/fast-export.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ static const char *anonymize_oid(const char *oid_hex)
409409
}
410410

411411
static void show_filemodify(struct diff_queue_struct *q,
412-
struct diff_options *options, void *data)
412+
struct diff_options *options UNUSED, void *data)
413413
{
414414
int i;
415415
struct string_list *changed = data;

builtin/merge-tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ static void *origin(struct merge_list *entry, unsigned long *size)
9898
return NULL;
9999
}
100100

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)
102102
{
103103
int i;
104104
for (i = 0; i < nbuf; i++)

builtin/merge.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
776776
}
777777

778778
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)
780780
{
781781
int *count = data;
782782

builtin/rerere.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ static const char * const rerere_usage[] = {
1414
NULL,
1515
};
1616

17-
static int outf(void *dummy, mmbuffer_t *ptr, int nbuf)
17+
static int outf(void *dummy UNUSED, mmbuffer_t *ptr, int nbuf)
1818
{
1919
int i;
2020
for (i = 0; i < nbuf; i++)

builtin/reset.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ static void print_new_head_line(struct commit *commit)
133133
}
134134

135135
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)
137138
{
138139
int i;
139140
int intent_to_add = *(int *)data;

builtin/submodule--helper.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,7 @@ static void prepare_submodule_summary(struct summary_cb *info,
10431043
}
10441044

10451045
static void submodule_summary_callback(struct diff_queue_struct *q,
1046-
struct diff_options *options,
1046+
struct diff_options *options UNUSED,
10471047
void *data)
10481048
{
10491049
int i;

combine-diff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ struct combine_diff_state {
372372
static void consume_hunk(void *state_,
373373
long ob, long on,
374374
long nb, long nn,
375-
const char *funcline, long funclen)
375+
const char *func UNUSED, long funclen UNUSED)
376376
{
377377
struct combine_diff_state *state = state_;
378378

diff-lib.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ int index_differs_from(struct repository *r,
673673
return (has_changes != 0);
674674
}
675675

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)
677677
{
678678
return data;
679679
}

diff.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1954,7 +1954,7 @@ static int color_words_output_graph_prefix(struct diff_words_data *diff_words)
19541954
static void fn_out_diff_words_aux(void *priv,
19551955
long minus_first, long minus_len,
19561956
long plus_first, long plus_len,
1957-
const char *func, long funclen)
1957+
const char *func UNUSED, long funclen UNUSED)
19581958
{
19591959
struct diff_words_data *diff_words = priv;
19601960
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
31843184
}
31853185

31863186
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)
31893190

31903191
{
31913192
struct checkdiff_t *data = priv;

range-diff.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,14 +269,18 @@ static void find_exact_matches(struct string_list *a, struct string_list *b)
269269
hashmap_clear(&map);
270270
}
271271

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)
273275
{
274276
(*(int *)data)++;
275277
return 0;
276278
}
277279

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)
280284
{
281285
diffsize_consume(data, NULL, 0);
282286
}
@@ -461,7 +465,7 @@ static void patch_diff(const char *a, const char *b,
461465
diff_flush(diffopt);
462466
}
463467

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)
465469
{
466470
return data;
467471
}

revision.c

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -600,10 +600,12 @@ static struct commit *one_relevant_parent(const struct rev_info *revs,
600600
static int tree_difference = REV_TREE_SAME;
601601

602602
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)
607609
{
608610
int diff = addremove == '+' ? REV_TREE_NEW : REV_TREE_OLD;
609611
struct rev_info *revs = options->change_fn_data;
@@ -614,12 +616,15 @@ static void file_add_remove(struct diff_options *options,
614616
}
615617

616618
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)
623628
{
624629
tree_difference = REV_TREE_DIFFERENT;
625630
options->flags.has_changes = 1;

submodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ static void changed_submodule_data_clear(struct changed_submodule_data *cs_data)
832832
}
833833

834834
static void collect_changed_submodules_cb(struct diff_queue_struct *q,
835-
struct diff_options *options,
835+
struct diff_options *options UNUSED,
836836
void *data)
837837
{
838838
struct collect_changed_submodules_cb_data *me = data;

wt-status.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ static char short_submodule_status(struct wt_status_change_data *d)
438438
}
439439

440440
static void wt_status_collect_changed_cb(struct diff_queue_struct *q,
441-
struct diff_options *options,
441+
struct diff_options *options UNUSED,
442442
void *data)
443443
{
444444
struct wt_status *s = data;
@@ -525,7 +525,7 @@ static int unmerged_mask(struct index_state *istate, const char *path)
525525
}
526526

527527
static void wt_status_collect_updated_cb(struct diff_queue_struct *q,
528-
struct diff_options *options,
528+
struct diff_options *options UNUSED,
529529
void *data)
530530
{
531531
struct wt_status *s = data;

0 commit comments

Comments
 (0)