]> git.ipfire.org Git - thirdparty/git.git/commitdiff
diff: mark unused parameters in callbacks
authorJeff King <peff@peff.net>
Tue, 13 Dec 2022 11:13:48 +0000 (06:13 -0500)
committerJunio C Hamano <gitster@pobox.com>
Tue, 13 Dec 2022 13:16:23 +0000 (22:16 +0900)
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>
15 files changed:
add-interactive.c
builtin/add.c
builtin/fast-export.c
builtin/merge-tree.c
builtin/merge.c
builtin/rerere.c
builtin/reset.c
builtin/submodule--helper.c
combine-diff.c
diff-lib.c
diff.c
range-diff.c
revision.c
submodule.c
wt-status.c

index ae1839c04a7fa27125e4a2308c971e63da18492a..00a0f6f96f3f5ebc54bbfb841921c5ceff88c1c3 100644 (file)
@@ -724,7 +724,7 @@ static int run_update(struct add_i_state *s, const struct pathspec *ps,
 }
 
 static void revert_from_diff(struct diff_queue_struct *q,
-                            struct diff_options *opt, void *data)
+                            struct diff_options *opt, void *data UNUSED)
 {
        int i, add_flags = ADD_CACHE_OK_TO_ADD | ADD_CACHE_OK_TO_REPLACE;
 
index 76277df326b4f47f594e4580f6f645ffa76455f3..190d1a692ab833c5eb1c4b74588230af8d4590c2 100644 (file)
@@ -88,7 +88,7 @@ static int fix_unmerged_status(struct diff_filepair *p,
 }
 
 static void update_callback(struct diff_queue_struct *q,
-                           struct diff_options *opt, void *cbdata)
+                           struct diff_options *opt UNUSED, void *cbdata)
 {
        int i;
        struct update_callback_data *data = cbdata;
index 3b3314e7b2a3343b78d14ee3bc9d4a92fb578fd6..39a890fc005192a5082a1c170550f4be102efbc1 100644 (file)
@@ -409,7 +409,7 @@ static const char *anonymize_oid(const char *oid_hex)
 }
 
 static void show_filemodify(struct diff_queue_struct *q,
-                           struct diff_options *options, void *data)
+                           struct diff_options *options UNUSED, void *data)
 {
        int i;
        struct string_list *changed = data;
index e3767087bbfdeb065e9a2806df4ba99b922eb2ec..ae2c0116817381ed791c795eace3036b94277c0d 100644 (file)
@@ -98,7 +98,7 @@ static void *origin(struct merge_list *entry, unsigned long *size)
        return NULL;
 }
 
-static int show_outf(void *priv_, mmbuffer_t *mb, int nbuf)
+static int show_outf(void *priv UNUSED, mmbuffer_t *mb, int nbuf)
 {
        int i;
        for (i = 0; i < nbuf; i++)
index dd474371a256a6170e4f3f1073db2dae2a0f8791..17b41fbe382814279796d8ba289c7617bf01cbce 100644 (file)
@@ -776,7 +776,7 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
 }
 
 static void count_diff_files(struct diff_queue_struct *q,
-                            struct diff_options *opt, void *data)
+                            struct diff_options *opt UNUSED, void *data)
 {
        int *count = data;
 
index 8b7392d5b4483ff961e14fc7ae5194d97d188d8b..94ffb8c21ab1e08f1775ad15315dd689723a2db8 100644 (file)
@@ -14,7 +14,7 @@ static const char * const rerere_usage[] = {
        NULL,
 };
 
-static int outf(void *dummy, mmbuffer_t *ptr, int nbuf)
+static int outf(void *dummy UNUSED, mmbuffer_t *ptr, int nbuf)
 {
        int i;
        for (i = 0; i < nbuf; i++)
index 1fa86edb4c92f31a21d838bcbff76e687cd15c23..d2e0185e55dd84bbe6140b0033ed11fc00612fbf 100644 (file)
@@ -133,7 +133,8 @@ static void print_new_head_line(struct commit *commit)
 }
 
 static void update_index_from_diff(struct diff_queue_struct *q,
-               struct diff_options *opt, void *data)
+                                  struct diff_options *opt UNUSED,
+                                  void *data)
 {
        int i;
        int intent_to_add = *(int *)data;
index 05f2c9bc9858d98ae855b566d6128030e002fa18..6743fb27bd55aed6c143666818022076948415dd 100644 (file)
@@ -1043,7 +1043,7 @@ static void prepare_submodule_summary(struct summary_cb *info,
 }
 
 static void submodule_summary_callback(struct diff_queue_struct *q,
-                                      struct diff_options *options,
+                                      struct diff_options *options UNUSED,
                                       void *data)
 {
        int i;
index b0ece9548082c17510b6abd17427434bbf66cae9..1a39b5dde0946df0c1e36c7b1f4c48552885985a 100644 (file)
@@ -372,7 +372,7 @@ struct combine_diff_state {
 static void consume_hunk(void *state_,
                         long ob, long on,
                         long nb, long nn,
-                        const char *funcline, long funclen)
+                        const char *func UNUSED, long funclen UNUSED)
 {
        struct combine_diff_state *state = state_;
 
index 2edea41a2345af623017d43e14a74d71a32bb873..dec040c366c82a71bc57bad9cf9db865182efe20 100644 (file)
@@ -673,7 +673,7 @@ int index_differs_from(struct repository *r,
        return (has_changes != 0);
 }
 
-static struct strbuf *idiff_prefix_cb(struct diff_options *opt, void *data)
+static struct strbuf *idiff_prefix_cb(struct diff_options *opt UNUSED, void *data)
 {
        return data;
 }
diff --git a/diff.c b/diff.c
index 74ebe247b4d6fe2a7212f30753f5d669a52a1dce..830291080b55d27b7852734ec16bb954c5b218e5 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -1954,7 +1954,7 @@ static int color_words_output_graph_prefix(struct diff_words_data *diff_words)
 static void fn_out_diff_words_aux(void *priv,
                                  long minus_first, long minus_len,
                                  long plus_first, long plus_len,
-                                 const char *func, long funclen)
+                                 const char *func UNUSED, long funclen UNUSED)
 {
        struct diff_words_data *diff_words = priv;
        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
 }
 
 static void checkdiff_consume_hunk(void *priv,
-                                  long ob, long on, long nb, long nn,
-                                  const char *func, long funclen)
+                                  long ob UNUSED, long on UNUSED,
+                                  long nb, long nn UNUSED,
+                                  const char *func UNUSED, long funclen UNUSED)
 
 {
        struct checkdiff_t *data = priv;
index 8b7d81adc1be09d91a1551c370c08058766f76f6..8255ab4349c009bec7c2c7200365d2bd9b018c16 100644 (file)
@@ -269,14 +269,18 @@ static void find_exact_matches(struct string_list *a, struct string_list *b)
        hashmap_clear(&map);
 }
 
-static int diffsize_consume(void *data, char *line, unsigned long len)
+static int diffsize_consume(void *data,
+                            char *line UNUSED,
+                            unsigned long len UNUSED)
 {
        (*(int *)data)++;
        return 0;
 }
 
-static void diffsize_hunk(void *data, long ob, long on, long nb, long nn,
-                         const char *funcline, long funclen)
+static void diffsize_hunk(void *data,
+                         long ob UNUSED, long on UNUSED,
+                         long nb UNUSED, long nn UNUSED,
+                         const char *func UNUSED, long funclen UNUSED)
 {
        diffsize_consume(data, NULL, 0);
 }
@@ -461,7 +465,7 @@ static void patch_diff(const char *a, const char *b,
        diff_flush(diffopt);
 }
 
-static struct strbuf *output_prefix_cb(struct diff_options *opt, void *data)
+static struct strbuf *output_prefix_cb(struct diff_options *opt UNUSED, void *data)
 {
        return data;
 }
index 439e34a7c51803335c4f5677f67058b633c46339..ec441b80ef6350083b425b441489aad484e1bf33 100644 (file)
@@ -600,10 +600,12 @@ static struct commit *one_relevant_parent(const struct rev_info *revs,
 static int tree_difference = REV_TREE_SAME;
 
 static void file_add_remove(struct diff_options *options,
-                   int addremove, unsigned mode,
-                   const struct object_id *oid,
-                   int oid_valid,
-                   const char *fullpath, unsigned dirty_submodule)
+                   int addremove,
+                   unsigned mode UNUSED,
+                   const struct object_id *oid UNUSED,
+                   int oid_valid UNUSED,
+                   const char *fullpath UNUSED,
+                   unsigned dirty_submodule UNUSED)
 {
        int diff = addremove == '+' ? REV_TREE_NEW : REV_TREE_OLD;
        struct rev_info *revs = options->change_fn_data;
@@ -614,12 +616,15 @@ static void file_add_remove(struct diff_options *options,
 }
 
 static void file_change(struct diff_options *options,
-                unsigned old_mode, unsigned new_mode,
-                const struct object_id *old_oid,
-                const struct object_id *new_oid,
-                int old_oid_valid, int new_oid_valid,
-                const char *fullpath,
-                unsigned old_dirty_submodule, unsigned new_dirty_submodule)
+                unsigned old_mode UNUSED,
+                unsigned new_mode UNUSED,
+                const struct object_id *old_oid UNUSED,
+                const struct object_id *new_oid UNUSED,
+                int old_oid_valid UNUSED,
+                int new_oid_valid UNUSED,
+                const char *fullpath UNUSED,
+                unsigned old_dirty_submodule UNUSED,
+                unsigned new_dirty_submodule UNUSED)
 {
        tree_difference = REV_TREE_DIFFERENT;
        options->flags.has_changes = 1;
index 8ac2fca855d6c3615be2e5b8a7f16a4746441e1a..fae24ef34a52f721547f9a88fe2fcc6de710a315 100644 (file)
@@ -832,7 +832,7 @@ static void changed_submodule_data_clear(struct changed_submodule_data *cs_data)
 }
 
 static void collect_changed_submodules_cb(struct diff_queue_struct *q,
-                                         struct diff_options *options,
+                                         struct diff_options *options UNUSED,
                                          void *data)
 {
        struct collect_changed_submodules_cb_data *me = data;
index 5813174896cc9ae5fa9287c8bcc432dc8cf2ef47..76e37a80883306cf02428b006e72e966fe954186 100644 (file)
@@ -438,7 +438,7 @@ static char short_submodule_status(struct wt_status_change_data *d)
 }
 
 static void wt_status_collect_changed_cb(struct diff_queue_struct *q,
-                                        struct diff_options *options,
+                                        struct diff_options *options UNUSED,
                                         void *data)
 {
        struct wt_status *s = data;
@@ -525,7 +525,7 @@ static int unmerged_mask(struct index_state *istate, const char *path)
 }
 
 static void wt_status_collect_updated_cb(struct diff_queue_struct *q,
-                                        struct diff_options *options,
+                                        struct diff_options *options UNUSED,
                                         void *data)
 {
        struct wt_status *s = data;