From 91e2ab1587d8ee18e3d2978f2b7bc250faf5df8f Mon Sep 17 00:00:00 2001 From: Jeff King Date: Tue, 13 Dec 2022 06:11:10 -0500 Subject: ls-refs: use repository parameter to iterate refs The ls_refs() function (for the v2 protocol command of the same name) takes a repository parameter (like all v2 commands), but ignores it. It should use it to access the refs. This isn't a bug in practice, since we only call this function when serving upload-pack from the main repository. But it's an awkward gotcha, and it causes -Wunused-parameter to complain. The main reason we don't use the repository parameter is that the ref iteration interface we call doesn't have a "refs_" variant that takes a ref_store. However we can easily add one. In fact, since there is only one other caller (in ref-filter.c), there is no need to maintain the non-repository wrapper; that caller can just use the_repository. It's still a long way from consistently using a repository object, but it's one small step in the right direction. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano diff --git a/ls-refs.c b/ls-refs.c index fb67697..697d4be 100644 --- a/ls-refs.c +++ b/ls-refs.c @@ -194,8 +194,9 @@ int ls_refs(struct repository *r, struct packet_reader *request) send_possibly_unborn_head(&data); if (!data.prefixes.nr) strvec_push(&data.prefixes, ""); - for_each_fullref_in_prefixes(get_git_namespace(), data.prefixes.v, - send_ref, &data); + refs_for_each_fullref_in_prefixes(get_main_ref_store(r), + get_git_namespace(), data.prefixes.v, + send_ref, &data); packet_fflush(stdout); strvec_clear(&data.prefixes); strbuf_release(&data.buf); diff --git a/ref-filter.c b/ref-filter.c index 9dc2cd1..9713036 100644 --- a/ref-filter.c +++ b/ref-filter.c @@ -2128,8 +2128,9 @@ static int for_each_fullref_in_pattern(struct ref_filter *filter, return for_each_fullref_in("", cb, cb_data); } - return for_each_fullref_in_prefixes(NULL, filter->name_patterns, - cb, cb_data); + return refs_for_each_fullref_in_prefixes(get_main_ref_store(the_repository), + NULL, filter->name_patterns, + cb, cb_data); } /* diff --git a/refs.c b/refs.c index 2c7e88b..e31dbcd 100644 --- a/refs.c +++ b/refs.c @@ -1723,9 +1723,10 @@ static void find_longest_prefixes(struct string_list *out, strbuf_release(&prefix); } -int for_each_fullref_in_prefixes(const char *namespace, - const char **patterns, - each_ref_fn fn, void *cb_data) +int refs_for_each_fullref_in_prefixes(struct ref_store *ref_store, + const char *namespace, + const char **patterns, + each_ref_fn fn, void *cb_data) { struct string_list prefixes = STRING_LIST_INIT_DUP; struct string_list_item *prefix; @@ -1740,7 +1741,7 @@ int for_each_fullref_in_prefixes(const char *namespace, for_each_string_list_item(prefix, &prefixes) { strbuf_addstr(&buf, prefix->string); - ret = for_each_fullref_in(buf.buf, fn, cb_data); + ret = refs_for_each_fullref_in(ref_store, buf.buf, fn, cb_data); if (ret) break; strbuf_setlen(&buf, namespace_len); diff --git a/refs.h b/refs.h index 3266fd8..935cdd1 100644 --- a/refs.h +++ b/refs.h @@ -354,8 +354,10 @@ int for_each_fullref_in(const char *prefix, each_ref_fn fn, void *cb_data); * * callers should be prepared to ignore references that they did not ask for. */ -int for_each_fullref_in_prefixes(const char *namespace, const char **patterns, - each_ref_fn fn, void *cb_data); +int refs_for_each_fullref_in_prefixes(struct ref_store *refs, + const char *namespace, const char **patterns, + each_ref_fn fn, void *cb_data); + /** * iterate refs from the respective area. */ -- cgit v0.10.2-6-g49f6 From c1166ca0e23d60629e0e7babd4eb4be64f578286 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Tue, 13 Dec 2022 06:11:57 -0500 Subject: blob: drop unused parts of parse_blob_buffer() Our parse_blob_buffer() takes a ptr/len combo, just like parse_tree_buffer(), etc, and returns success or failure. But it doesn't actually do anything with them; we just set the "parsed" flag in the object and return success, without even looking at the contents. There could be some value to keeping these unused parameters: - it's consistent with the parse functions for other object types. But we already lost that consistency in 837d395a5c (Replace parse_blob() with an explanatory comment, 2010-01-18). - As the comment from 837d395a5c explains, callers are supposed to make sure they have the object content available. So in theory asking for these parameters could serve as a signal. But there are only two callers, and one of them always passes NULL (after doing a streaming check of the object hash). This shows that there aren't likely to be a lot of callers (since everyone either uses the type-generic parse functions, or handles blobs individually), and that they need to take special care anyway (because we usually want to avoid loading whole blobs in memory if we can avoid it). So let's just drop these unused parameters, and likewise the useless return value. While we're touching the header file, let's move the declaration of parse_blob_buffer() right below that explanatory comment, where it's more likely to be seen by people looking for the function. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano diff --git a/blob.c b/blob.c index 182718a..8f83523 100644 --- a/blob.c +++ b/blob.c @@ -13,8 +13,7 @@ struct blob *lookup_blob(struct repository *r, const struct object_id *oid) return object_as_type(obj, OBJ_BLOB, 0); } -int parse_blob_buffer(struct blob *item, void *buffer, unsigned long size) +void parse_blob_buffer(struct blob *item) { item->object.parsed = 1; - return 0; } diff --git a/blob.h b/blob.h index 1664872..74555c9 100644 --- a/blob.h +++ b/blob.h @@ -11,8 +11,6 @@ struct blob { struct blob *lookup_blob(struct repository *r, const struct object_id *oid); -int parse_blob_buffer(struct blob *item, void *buffer, unsigned long size); - /** * Blobs do not contain references to other objects and do not have * structured data that needs parsing. However, code may use the @@ -21,5 +19,6 @@ int parse_blob_buffer(struct blob *item, void *buffer, unsigned long size); * parse_blob_buffer() is used (by object.c) to flag that the object * has been read successfully from the database. **/ +void parse_blob_buffer(struct blob *item); #endif /* BLOB_H */ diff --git a/object.c b/object.c index 682b852..344087d 100644 --- a/object.c +++ b/object.c @@ -212,8 +212,7 @@ struct object *parse_object_buffer(struct repository *r, const struct object_id if (type == OBJ_BLOB) { struct blob *blob = lookup_blob(r, oid); if (blob) { - if (parse_blob_buffer(blob, buffer, size)) - return NULL; + parse_blob_buffer(blob); obj = &blob->object; } } else if (type == OBJ_TREE) { @@ -292,7 +291,7 @@ struct object *parse_object_with_flags(struct repository *r, error(_("hash mismatch %s"), oid_to_hex(oid)); return NULL; } - parse_blob_buffer(lookup_blob(r, oid), NULL, 0); + parse_blob_buffer(lookup_blob(r, oid)); return lookup_object(r, oid); } -- cgit v0.10.2-6-g49f6 From 00271485d4acefda7ff054a1db5d5a39735e28b9 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Tue, 13 Dec 2022 06:12:09 -0500 Subject: list-objects: drop process_gitlink() function Our object graph traversal code has a process_gitlink() function which we call when we see a gitlink entry. The function does nothing; it was added in the early days of gitlinks by 6e2f441bd4 (Teach git list-objects logic to not follow gitlinks, 2007-04-13). The comment above the function talks about some things we _could_ do. But in the intervening 15 years, nobody has touched the function, and the submodule code usually makes its own decisions about when and how to examine the links. At the generic traversal layer, we can't assume that the pointed-to commit is available. Let's drop this placeholder that isn't really helping anything. This silences some -Wunused-parameter warnings, and also gets rid of a crufty use of "const unsigned char *" to pass a raw hash value. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano diff --git a/list-objects.c b/list-objects.c index 250d9de..7528fe1 100644 --- a/list-objects.c +++ b/list-objects.c @@ -81,36 +81,6 @@ static void process_blob(struct traversal_context *ctx, strbuf_setlen(path, pathlen); } -/* - * Processing a gitlink entry currently does nothing, since - * we do not recurse into the subproject. - * - * We *could* eventually add a flag that actually does that, - * which would involve: - * - is the subproject actually checked out? - * - if so, see if the subproject has already been added - * to the alternates list, and add it if not. - * - process the commit (or tag) the gitlink points to - * recursively. - * - * However, it's unclear whether there is really ever any - * reason to see superprojects and subprojects as such a - * "unified" object pool (potentially resulting in a totally - * humongous pack - avoiding which was the whole point of - * having gitlinks in the first place!). - * - * So for now, there is just a note that we *could* follow - * the link, and how to do it. Whether it necessarily makes - * any sense what-so-ever to ever do that is another issue. - */ -static void process_gitlink(struct traversal_context *ctx, - const unsigned char *sha1, - struct strbuf *path, - const char *name) -{ - /* Nothing to do */ -} - static void process_tree(struct traversal_context *ctx, struct tree *tree, struct strbuf *base, @@ -149,8 +119,7 @@ static void process_tree_contents(struct traversal_context *ctx, process_tree(ctx, t, base, entry.path); } else if (S_ISGITLINK(entry.mode)) - process_gitlink(ctx, entry.oid.hash, - base, entry.path); + ; /* ignore gitlink */ else { struct blob *b = lookup_blob(ctx->revs->repo, &entry.oid); if (!b) { -- cgit v0.10.2-6-g49f6 From c5224f0f4cd53e3b205f54b98bc3dc66a9007c71 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Tue, 13 Dec 2022 06:12:58 -0500 Subject: ws: drop unused parameter from ws_blank_line() We take a ws_rule parameter, but have never looked at it since the function was added in 877f23ccb8 (Teach "diff --check" about new blank lines at end, 2008-06-26). A comment in the function does mention how we _could_ use it, but nobody has felt the need to do so for over a decade. We could keep it around as reminder of what could be done, but the comment serves that purpose. And in the meantime, it triggers -Wunused-parameter. So let's drop it, which in turn allows us to drop similar arguments further up the callstack. I've left the comment intact. It does still say "ws_rule", but that name is used consistently in the whitespace code, so the meaning is clear. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano diff --git a/apply.c b/apply.c index bc33814..8582228 100644 --- a/apply.c +++ b/apply.c @@ -2913,7 +2913,7 @@ static int apply_one_fragment(struct apply_state *state, break; case ' ': if (plen && (ws_rule & WS_BLANK_AT_EOF) && - ws_blank_line(patch + 1, plen, ws_rule)) + ws_blank_line(patch + 1, plen)) is_blank_context = 1; /* fallthrough */ case '-': @@ -2942,7 +2942,7 @@ static int apply_one_fragment(struct apply_state *state, (first == '+' ? 0 : LINE_COMMON)); if (first == '+' && (ws_rule & WS_BLANK_AT_EOF) && - ws_blank_line(patch + 1, plen, ws_rule)) + ws_blank_line(patch + 1, plen)) added_blank_line = 1; break; case '@': case '\\': diff --git a/cache.h b/cache.h index 07d40b0..fcf4970 100644 --- a/cache.h +++ b/cache.h @@ -1865,7 +1865,7 @@ unsigned ws_check(const char *line, int len, unsigned ws_rule); void ws_check_emit(const char *line, int len, unsigned ws_rule, FILE *stream, const char *set, const char *reset, const char *ws); char *whitespace_error_string(unsigned ws); void ws_fix_copy(struct strbuf *, const char *, int, unsigned, int *); -int ws_blank_line(const char *line, int len, unsigned ws_rule); +int ws_blank_line(const char *line, int len); #define ws_tab_width(rule) ((rule) & WS_TAB_WIDTH_MASK) /* ls-files */ diff --git a/diff.c b/diff.c index 1054a4b..74ebe24 100644 --- a/diff.c +++ b/diff.c @@ -604,7 +604,7 @@ static unsigned long diff_filespec_size(struct repository *r, return one->size; } -static int count_trailing_blank(mmfile_t *mf, unsigned ws_rule) +static int count_trailing_blank(mmfile_t *mf) { char *ptr = mf->ptr; long size = mf->size; @@ -622,7 +622,7 @@ static int count_trailing_blank(mmfile_t *mf, unsigned ws_rule) for (prev_eol = ptr; mf->ptr <= prev_eol; prev_eol--) if (*prev_eol == '\n') break; - if (!ws_blank_line(prev_eol + 1, ptr - prev_eol, ws_rule)) + if (!ws_blank_line(prev_eol + 1, ptr - prev_eol)) break; cnt++; ptr = prev_eol - 1; @@ -634,9 +634,8 @@ static void check_blank_at_eof(mmfile_t *mf1, mmfile_t *mf2, struct emit_callback *ecbdata) { int l1, l2, at; - unsigned ws_rule = ecbdata->ws_rule; - l1 = count_trailing_blank(mf1, ws_rule); - l2 = count_trailing_blank(mf2, ws_rule); + l1 = count_trailing_blank(mf1); + l2 = count_trailing_blank(mf2); if (l2 <= l1) { ecbdata->blank_at_eof_in_preimage = 0; ecbdata->blank_at_eof_in_postimage = 0; @@ -1583,7 +1582,7 @@ static int new_blank_line_at_eof(struct emit_callback *ecbdata, const char *line ecbdata->blank_at_eof_in_preimage <= ecbdata->lno_in_preimage && ecbdata->blank_at_eof_in_postimage <= ecbdata->lno_in_postimage)) return 0; - return ws_blank_line(line, len, ecbdata->ws_rule); + return ws_blank_line(line, len); } static void emit_add_line(struct emit_callback *ecbdata, diff --git a/ws.c b/ws.c index 6e69877..46a77bc 100644 --- a/ws.c +++ b/ws.c @@ -252,7 +252,7 @@ unsigned ws_check(const char *line, int len, unsigned ws_rule) return ws_check_emit_1(line, len, ws_rule, NULL, NULL, NULL, NULL); } -int ws_blank_line(const char *line, int len, unsigned ws_rule) +int ws_blank_line(const char *line, int len) { /* * We _might_ want to treat CR differently from other -- cgit v0.10.2-6-g49f6 From a361660aeff6dcf85c92eb1f7bd7645ec6fc60bc Mon Sep 17 00:00:00 2001 From: Jeff King Date: Tue, 13 Dec 2022 06:13:08 -0500 Subject: xdiff: drop unused parameter in def_ff() The def_ff() function is the default "find_func" for finding hunk headers. It has never used its "priv" argument since it was introduced in f258475a6e (Per-path attribute based hunk header selection., 2007-07-06). But back then we used a function pointer to switch between a caller-provided function and the default, so the two had to conform to the same interface. In ff2981f724 (xdiff: factor out match_func_rec(), 2016-05-28), that pointer indirection went away in favor of code which directly calls either of the two functions. So there's no need for def_ff() to retain this unused parameter. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano diff --git a/xdiff/xemit.c b/xdiff/xemit.c index c4ccd68..75f0fe4 100644 --- a/xdiff/xemit.c +++ b/xdiff/xemit.c @@ -95,7 +95,7 @@ xdchange_t *xdl_get_hunk(xdchange_t **xscr, xdemitconf_t const *xecfg) } -static long def_ff(const char *rec, long len, char *buf, long sz, void *priv) +static long def_ff(const char *rec, long len, char *buf, long sz) { if (len > 0 && (isalpha((unsigned char)*rec) || /* identifier? */ @@ -117,7 +117,7 @@ static long match_func_rec(xdfile_t *xdf, xdemitconf_t const *xecfg, long ri, const char *rec; long len = xdl_get_rec(xdf, ri, &rec); if (!xecfg->find_func) - return def_ff(rec, len, buf, sz, xecfg->find_func_priv); + return def_ff(rec, len, buf, sz); return xecfg->find_func(rec, len, buf, sz, xecfg->find_func_priv); } -- cgit v0.10.2-6-g49f6 From 8157ed4046dd58c38c8197b0f1d800c37ca54d61 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Tue, 13 Dec 2022 06:13:24 -0500 Subject: xdiff: mark unused parameter in xdl_call_hunk_func() This function is used interchangeably with xdl_emit via a function pointer, so we can't just drop the unused parameter. Mark it to silence -Wunused-parameter. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano diff --git a/xdiff/xdiffi.c b/xdiff/xdiffi.c index 32652de..344c2df 100644 --- a/xdiff/xdiffi.c +++ b/xdiff/xdiffi.c @@ -973,7 +973,7 @@ void xdl_free_script(xdchange_t *xscr) { } } -static int xdl_call_hunk_func(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb, +static int xdl_call_hunk_func(xdfenv_t *xe UNUSED, xdchange_t *xscr, xdemitcb_t *ecb, xdemitconf_t const *xecfg) { xdchange_t *xch, *xche; -- cgit v0.10.2-6-g49f6 From 61bdc7c5d8b1dedc5f9c3af45c5738d14136ae90 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Tue, 13 Dec 2022 06:13:48 -0500 Subject: 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 Signed-off-by: Junio C Hamano diff --git a/add-interactive.c b/add-interactive.c index ae1839c..00a0f6f 100644 --- a/add-interactive.c +++ b/add-interactive.c @@ -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; diff --git a/builtin/add.c b/builtin/add.c index 76277df..190d1a6 100644 --- a/builtin/add.c +++ b/builtin/add.c @@ -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; diff --git a/builtin/fast-export.c b/builtin/fast-export.c index 3b3314e..39a890f 100644 --- a/builtin/fast-export.c +++ b/builtin/fast-export.c @@ -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; diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c index e376708..ae2c011 100644 --- a/builtin/merge-tree.c +++ b/builtin/merge-tree.c @@ -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++) diff --git a/builtin/merge.c b/builtin/merge.c index dd47437..17b41fb 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -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; diff --git a/builtin/rerere.c b/builtin/rerere.c index 8b7392d..94ffb8c 100644 --- a/builtin/rerere.c +++ b/builtin/rerere.c @@ -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++) diff --git a/builtin/reset.c b/builtin/reset.c index 1fa86ed..d2e0185 100644 --- a/builtin/reset.c +++ b/builtin/reset.c @@ -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; diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 05f2c9b..6743fb2 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -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; diff --git a/combine-diff.c b/combine-diff.c index b0ece95..1a39b5d 100644 --- a/combine-diff.c +++ b/combine-diff.c @@ -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_; diff --git a/diff-lib.c b/diff-lib.c index 2edea41..dec040c 100644 --- a/diff-lib.c +++ b/diff-lib.c @@ -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 74ebe24..8302910 100644 --- 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; diff --git a/range-diff.c b/range-diff.c index 8b7d81a..8255ab4 100644 --- a/range-diff.c +++ b/range-diff.c @@ -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; } diff --git a/revision.c b/revision.c index 439e34a..ec441b8 100644 --- a/revision.c +++ b/revision.c @@ -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; diff --git a/submodule.c b/submodule.c index 8ac2fca..fae24ef 100644 --- a/submodule.c +++ b/submodule.c @@ -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; diff --git a/wt-status.c b/wt-status.c index 5813174..76e37a8 100644 --- a/wt-status.c +++ b/wt-status.c @@ -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; -- cgit v0.10.2-6-g49f6 From d3beb61f939ffcdbefc02d9ddf9d7a46102ec663 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Tue, 13 Dec 2022 06:14:23 -0500 Subject: list-objects-filter: mark unused parameters in virtual functions The "struct filter" abstract type defines several virtual function pointers. Not all of the concrete functions need every parameter, but they have to conform to the generic interface. Mark unused ones to silence -Wunused-parameter. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano diff --git a/list-objects-filter.c b/list-objects-filter.c index b954354..2bbac62 100644 --- a/list-objects-filter.c +++ b/list-objects-filter.c @@ -70,13 +70,13 @@ struct filter { }; static enum list_objects_filter_result filter_blobs_none( - struct repository *r, + struct repository *r UNUSED, enum list_objects_filter_situation filter_situation, struct object *obj, - const char *pathname, - const char *filename, + const char *pathname UNUSED, + const char *filename UNUSED, struct oidset *omits, - void *filter_data_) + void *filter_data_ UNUSED) { switch (filter_situation) { default: @@ -112,7 +112,7 @@ static enum list_objects_filter_result filter_blobs_none( } static void filter_blobs_none__init( - struct list_objects_filter_options *filter_options, + struct list_objects_filter_options *filter_options UNUSED, struct filter *filter) { filter->filter_object_fn = filter_blobs_none; @@ -159,11 +159,11 @@ static int filter_trees_update_omits( } static enum list_objects_filter_result filter_trees_depth( - struct repository *r, + struct repository *r UNUSED, enum list_objects_filter_situation filter_situation, struct object *obj, - const char *pathname, - const char *filename, + const char *pathname UNUSED, + const char *filename UNUSED, struct oidset *omits, void *filter_data_) { @@ -274,8 +274,8 @@ static enum list_objects_filter_result filter_blobs_limit( struct repository *r, enum list_objects_filter_situation filter_situation, struct object *obj, - const char *pathname, - const char *filename, + const char *pathname UNUSED, + const char *filename UNUSED, struct oidset *omits, void *filter_data_) { @@ -554,12 +554,12 @@ struct filter_object_type_data { }; static enum list_objects_filter_result filter_object_type( - struct repository *r, + struct repository *r UNUSED, enum list_objects_filter_situation filter_situation, struct object *obj, - const char *pathname, - const char *filename, - struct oidset *omits, + const char *pathname UNUSED, + const char *filename UNUSED, + struct oidset *omits UNUSED, void *filter_data_) { struct filter_object_type_data *filter_data = filter_data_; @@ -675,7 +675,7 @@ static enum list_objects_filter_result filter_combine( struct object *obj, const char *pathname, const char *filename, - struct oidset *omits, + struct oidset *omits UNUSED, void *filter_data) { struct combine_filter_data *d = filter_data; -- cgit v0.10.2-6-g49f6 From c25d9e529d531adf0697e0c09ba292227c835164 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Tue, 13 Dec 2022 06:16:57 -0500 Subject: userdiff: mark unused parameter in internal callback Since f12fa9ee6c (userdiff: add and use for_each_userdiff_driver(), 2021-04-08), lookup of userdiffs is done with a generic for_each_userdiff_driver(). But the name lookup doesn't use the "type" field, of course. We can't get rid of that field from the generic interface because it is used by t/helper/test-userdiff.c. So mark it as unused in this instance to silence -Wunused-parameter. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano diff --git a/userdiff.c b/userdiff.c index 151d9a5..e25356a 100644 --- a/userdiff.c +++ b/userdiff.c @@ -315,7 +315,8 @@ struct find_by_namelen_data { }; static int userdiff_find_by_namelen_cb(struct userdiff_driver *driver, - enum userdiff_driver_type type, void *priv) + enum userdiff_driver_type type UNUSED, + void *priv) { struct find_by_namelen_data *cb_data = priv; -- cgit v0.10.2-6-g49f6