refs: mark unused each_ref_fn parameters

Functions used with for_each_ref(), etc, need to conform to the
each_ref_fn interface. But most of them don't need every parameter;
let's annotate the unused ones to quiet -Wunused-parameter.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Jeff King 2022-08-19 06:08:32 -04:00 committed by Junio C Hamano
parent 9b24034754
commit 63e14ee2d6
39 changed files with 132 additions and 84 deletions

View File

@ -441,7 +441,7 @@ void find_bisection(struct commit_list **commit_list, int *reaches,
}
static int register_ref(const char *refname, const struct object_id *oid,
int flags, void *cb_data)
int UNUSED(flags), void *UNUSED(cb_data))
{
struct strbuf good_prefix = STRBUF_INIT;
strbuf_addstr(&good_prefix, term_good);
@ -1160,8 +1160,9 @@ int estimate_bisect_steps(int all)
return (e < 3 * x) ? n : n - 1;
}
static int mark_for_removal(const char *refname, const struct object_id *oid,
int flag, void *cb_data)
static int mark_for_removal(const char *refname,
const struct object_id *UNUSED(oid),
int UNUSED(flag), void *cb_data)
{
struct string_list *refs = cb_data;
char *ref = xstrfmt("refs/bisect%s", refname);

View File

@ -329,8 +329,9 @@ static int check_and_set_terms(struct bisect_terms *terms, const char *cmd)
return 0;
}
static int inc_nr(const char *refname, const struct object_id *oid,
int flag, void *cb_data)
static int inc_nr(const char *UNUSED(refname),
const struct object_id *UNUSED(oid),
int UNUSED(flag), void *cb_data)
{
unsigned int *nr = (unsigned int *)cb_data;
(*nr)++;
@ -518,7 +519,7 @@ finish:
}
static int add_bisect_ref(const char *refname, const struct object_id *oid,
int flags, void *cb)
int UNUSED(flags), void *cb)
{
struct add_bisect_ref_data *data = cb;
@ -1134,8 +1135,9 @@ static int bisect_visualize(struct bisect_terms *terms, const char **argv, int a
return res;
}
static int get_first_good(const char *refname, const struct object_id *oid,
int flag, void *cb_data)
static int get_first_good(const char *UNUSED(refname),
const struct object_id *oid,
int UNUSED(flag), void *cb_data)
{
oidcpy(cb_data, oid);
return 1;

View File

@ -990,7 +990,7 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
static int add_pending_uninteresting_ref(const char *refname,
const struct object_id *oid,
int flags, void *cb_data)
int UNUSED(flags), void *cb_data)
{
add_pending_oid(cb_data, refname, oid, UNINTERESTING);
return 0;

View File

@ -140,7 +140,8 @@ static void add_to_known_names(const char *path,
}
}
static int get_name(const char *path, const struct object_id *oid, int flag, void *cb_data)
static int get_name(const char *path, const struct object_id *oid,
int UNUSED(flag), void *UNUSED(cb_data))
{
int is_tag = 0;
struct object_id peeled;

View File

@ -329,7 +329,7 @@ static struct refname_hash_entry *refname_hash_add(struct hashmap *map,
static int add_one_refname(const char *refname,
const struct object_id *oid,
int flag, void *cbdata)
int UNUSED(flag), void *cbdata)
{
struct hashmap *refname_map = cbdata;
@ -1462,8 +1462,9 @@ static void set_option(struct transport *transport, const char *name, const char
}
static int add_oid(const char *refname, const struct object_id *oid, int flags,
void *cb_data)
static int add_oid(const char *UNUSED(refname),
const struct object_id *oid,
int UNUSED(flags), void *cb_data)
{
struct oid_array *oids = cb_data;

View File

@ -502,8 +502,9 @@ static int fsck_handle_reflog_ent(struct object_id *ooid, struct object_id *noid
return 0;
}
static int fsck_handle_reflog(const char *logname, const struct object_id *oid,
int flag, void *cb_data)
static int fsck_handle_reflog(const char *logname,
const struct object_id *UNUSED(oid),
int UNUSED(flag), void *cb_data)
{
struct strbuf refname = STRBUF_INIT;
@ -514,7 +515,7 @@ static int fsck_handle_reflog(const char *logname, const struct object_id *oid,
}
static int fsck_handle_ref(const char *refname, const struct object_id *oid,
int flag, void *cb_data)
int UNUSED(flag), void *UNUSED(cb_data))
{
struct object *obj;

View File

@ -782,8 +782,9 @@ struct cg_auto_data {
int limit;
};
static int dfs_on_ref(const char *refname,
const struct object_id *oid, int flags,
static int dfs_on_ref(const char *UNUSED(refname),
const struct object_id *oid,
int UNUSED(flags),
void *cb_data)
{
struct cg_auto_data *data = (struct cg_auto_data *)cb_data;

View File

@ -344,7 +344,8 @@ static int cmp_by_tag_and_age(const void *a_, const void *b_)
return a->taggerdate != b->taggerdate;
}
static int name_ref(const char *path, const struct object_id *oid, int flags, void *cb_data)
static int name_ref(const char *path, const struct object_id *oid,
int UNUSED(flags), void *cb_data)
{
struct object *o = parse_object(the_repository, oid);
struct name_ref_data *data = cb_data;

View File

@ -759,8 +759,8 @@ static enum write_one_status write_one(struct hashfile *f,
return WRITE_ONE_WRITTEN;
}
static int mark_tagged(const char *path, const struct object_id *oid, int flag,
void *cb_data)
static int mark_tagged(const char *UNUSED(path), const struct object_id *oid,
int UNUSED(flag), void *UNUSED(cb_data))
{
struct object_id peeled;
struct object_entry *entry = packlist_find(&to_pack, oid);
@ -3035,7 +3035,8 @@ static void add_tag_chain(const struct object_id *oid)
}
}
static int add_ref_tag(const char *tag, const struct object_id *oid, int flag, void *cb_data)
static int add_ref_tag(const char *UNUSED(tag), const struct object_id *oid,
int UNUSED(flag), void *UNUSED(cb_data))
{
struct object_id peeled;
@ -3950,8 +3951,9 @@ static void record_recent_commit(struct commit *commit, void *data)
}
static int mark_bitmap_preferred_tip(const char *refname,
const struct object_id *oid, int flags,
void *_data)
const struct object_id *oid,
int UNUSED(flags),
void *UNUSED(data))
{
struct object_id peeled;
struct object *object;

View File

@ -291,7 +291,7 @@ static void show_ref(const char *path, const struct object_id *oid)
}
static int show_ref_cb(const char *path_full, const struct object_id *oid,
int flag, void *data)
int UNUSED(flag), void *data)
{
struct oidset *seen = data;
const char *path = strip_namespace(path_full);

View File

@ -56,7 +56,8 @@ struct worktree_reflogs {
struct string_list reflogs;
};
static int collect_reflog(const char *ref, const struct object_id *oid, int unused, void *cb_data)
static int collect_reflog(const char *ref, const struct object_id *UNUSED(oid),
int UNUSED(flags), void *cb_data)
{
struct worktree_reflogs *cb = cb_data;
struct worktree *worktree = cb->worktree;

View File

@ -264,7 +264,8 @@ static const char *abbrev_ref(const char *name, const char *prefix)
}
#define abbrev_branch(name) abbrev_ref((name), "refs/heads/")
static int config_read_branches(const char *key, const char *value, void *cb)
static int config_read_branches(const char *key, const char *value,
void *UNUSED(data))
{
const char *orig_key = key;
char *name;
@ -538,7 +539,8 @@ struct branches_for_remote {
};
static int add_branch_for_removal(const char *refname,
const struct object_id *oid, int flags, void *cb_data)
const struct object_id *UNUSED(oid),
int UNUSED(flags), void *cb_data)
{
struct branches_for_remote *branches = cb_data;
struct refspec_item refspec;
@ -580,7 +582,8 @@ struct rename_info {
};
static int read_remote_branches(const char *refname,
const struct object_id *oid, int flags, void *cb_data)
const struct object_id *UNUSED(oid),
int UNUSED(flags), void *cb_data)
{
struct rename_info *rename = cb_data;
struct strbuf buf = STRBUF_INIT;
@ -953,7 +956,8 @@ static void free_remote_ref_states(struct ref_states *states)
}
static int append_ref_to_tracked_list(const char *refname,
const struct object_id *oid, int flags, void *cb_data)
const struct object_id *UNUSED(oid),
int flags, void *cb_data)
{
struct ref_states *states = cb_data;
struct refspec_item refspec;

View File

@ -514,9 +514,9 @@ struct midx_snapshot_ref_data {
int preferred;
};
static int midx_snapshot_ref_one(const char *refname,
static int midx_snapshot_ref_one(const char *UNUSED(refname),
const struct object_id *oid,
int flag, void *_data)
int UNUSED(flag), void *_data)
{
struct midx_snapshot_ref_data *data = _data;
struct object_id peeled;

View File

@ -195,7 +195,8 @@ static int show_default(void)
return 0;
}
static int show_reference(const char *refname, const struct object_id *oid, int flag, void *cb_data)
static int show_reference(const char *refname, const struct object_id *oid,
int UNUSED(flag), void *UNUSED(cb_data))
{
if (ref_excluded(ref_excludes, refname))
return 0;
@ -203,7 +204,8 @@ static int show_reference(const char *refname, const struct object_id *oid, int
return 0;
}
static int anti_reference(const char *refname, const struct object_id *oid, int flag, void *cb_data)
static int anti_reference(const char *refname, const struct object_id *oid,
int UNUSED(flag), void *UNUSED(cb_data))
{
show_rev(REVERSED, oid, refname);
return 0;

View File

@ -404,7 +404,7 @@ static int append_ref(const char *refname, const struct object_id *oid,
}
static int append_head_ref(const char *refname, const struct object_id *oid,
int flag, void *cb_data)
int UNUSED(flag), void *UNUSED(cb_data))
{
struct object_id tmp;
int ofs = 11;
@ -419,7 +419,7 @@ static int append_head_ref(const char *refname, const struct object_id *oid,
}
static int append_remote_ref(const char *refname, const struct object_id *oid,
int flag, void *cb_data)
int UNUSED(flag), void *UNUSED(cb_data))
{
struct object_id tmp;
int ofs = 13;
@ -434,7 +434,7 @@ static int append_remote_ref(const char *refname, const struct object_id *oid,
}
static int append_tag_ref(const char *refname, const struct object_id *oid,
int flag, void *cb_data)
int UNUSED(flag), void *UNUSED(cb_data))
{
if (!starts_with(refname, "refs/tags/"))
return 0;

View File

@ -47,7 +47,7 @@ static void show_one(const char *refname, const struct object_id *oid)
}
static int show_ref(const char *refname, const struct object_id *oid,
int flag, void *cbdata)
int UNUSED(flag), void *UNUSED(cbdata))
{
if (show_head && !strcmp(refname, "HEAD"))
goto match;
@ -77,8 +77,9 @@ match:
return 0;
}
static int add_existing(const char *refname, const struct object_id *oid,
int flag, void *cbdata)
static int add_existing(const char *refname,
const struct object_id *UNUSED(oid),
int UNUSED(flag), void *cbdata)
{
struct string_list *list = (struct string_list *)cbdata;
string_list_insert(list, refname);

View File

@ -622,8 +622,9 @@ static void print_status(unsigned int flags, char state, const char *path,
printf("\n");
}
static int handle_submodule_head_ref(const char *refname,
const struct object_id *oid, int flags,
static int handle_submodule_head_ref(const char *UNUSED(refname),
const struct object_id *oid,
int UNUSED(flags),
void *cb_data)
{
struct object_id *output = cb_data;

View File

@ -1639,9 +1639,9 @@ struct refs_cb_data {
struct progress *progress;
};
static int add_ref_to_set(const char *refname,
static int add_ref_to_set(const char *UNUSED(refname),
const struct object_id *oid,
int flags, void *cb_data)
int UNUSED(flags), void *cb_data)
{
struct object_id peeled;
struct refs_cb_data *data = (struct refs_cb_data *)cb_data;

View File

@ -365,7 +365,7 @@ static void add_ref_to_island(const char *island_name, const struct object_id *o
}
static int find_island_for_ref(const char *refname, const struct object_id *oid,
int flags, void *data)
int UNUSED(flags), void *UNUSED(data))
{
/*
* We should advertise 'ARRAY_SIZE(matches) - 2' as the max,

View File

@ -176,8 +176,10 @@ static int rev_list_insert_ref(struct fetch_negotiator *negotiator,
return 0;
}
static int rev_list_insert_ref_oid(const char *refname, const struct object_id *oid,
int flag, void *cb_data)
static int rev_list_insert_ref_oid(const char *UNUSED(refname),
const struct object_id *oid,
int UNUSED(flag),
void *cb_data)
{
return rev_list_insert_ref(cb_data, oid);
}
@ -580,8 +582,10 @@ static int mark_complete(const struct object_id *oid)
return 0;
}
static int mark_complete_oid(const char *refname, const struct object_id *oid,
int flag, void *cb_data)
static int mark_complete_oid(const char *UNUSED(refname),
const struct object_id *oid,
int UNUSED(flag),
void *UNUSED(cb_data))
{
return mark_complete(oid);
}

5
help.c
View File

@ -781,8 +781,9 @@ struct similar_ref_cb {
struct string_list *similar_refs;
};
static int append_similar_ref(const char *refname, const struct object_id *oid,
int flags, void *cb_data)
static int append_similar_ref(const char *refname,
const struct object_id *UNUSED(oid),
int UNUSED(flags), void *cb_data)
{
struct similar_ref_cb *cb = (struct similar_ref_cb *)(cb_data);
char *branch = strrchr(refname, '/') + 1;

View File

@ -505,7 +505,7 @@ static void run_service(const char **argv, int buffer_input)
}
static int show_text_ref(const char *name, const struct object_id *oid,
int flag, void *cb_data)
int UNUSED(flag), void *cb_data)
{
const char *name_nons = strip_namespace(name);
struct strbuf *buf = cb_data;

View File

@ -135,7 +135,8 @@ static int ref_filter_match(const char *refname,
}
static int add_ref_decoration(const char *refname, const struct object_id *oid,
int flags, void *cb_data)
int UNUSED(flags),
void *cb_data)
{
struct object *obj;
enum object_type objtype;

View File

@ -36,7 +36,8 @@ static void rev_list_push(struct negotiation_state *ns,
}
static int clear_marks(const char *refname, const struct object_id *oid,
int flag, void *cb_data)
int UNUSED(flag),
void *UNUSED(cb_data))
{
struct object *o = deref_tag(the_repository, parse_object(the_repository, oid), refname, 0);

View File

@ -72,7 +72,8 @@ static struct entry *rev_list_push(struct data *data, struct commit *commit, int
}
static int clear_marks(const char *refname, const struct object_id *oid,
int flag, void *cb_data)
int UNUSED(flag),
void *UNUSED(cb_data))
{
struct object *o = deref_tag(the_repository, parse_object(the_repository, oid), refname, 0);

View File

@ -924,8 +924,9 @@ out:
return ret;
}
static int string_list_add_one_ref(const char *refname, const struct object_id *oid,
int flag, void *cb)
static int string_list_add_one_ref(const char *refname,
const struct object_id *UNUSED(oid),
int UNUSED(flag), void *cb)
{
struct string_list *refs = cb;
if (!unsorted_string_list_has_string(refs, refname))

View File

@ -1306,7 +1306,8 @@ struct handle_one_ref_cb {
};
static int handle_one_ref(const char *path, const struct object_id *oid,
int flag, void *cb_data)
int UNUSED(flag),
void *cb_data)
{
struct handle_one_ref_cb *cb = cb_data;
struct commit_list **list = cb->list;

View File

@ -294,7 +294,8 @@ int should_expire_reflog_ent_verbose(struct object_id *ooid,
return expire;
}
static int push_tip_to_list(const char *refname, const struct object_id *oid,
static int push_tip_to_list(const char *UNUSED(refname),
const struct object_id *oid,
int flags, void *cb_data)
{
struct commit_list **list = cb_data;

11
refs.c
View File

@ -358,7 +358,8 @@ struct warn_if_dangling_data {
const char *msg_fmt;
};
static int warn_if_dangling_symref(const char *refname, const struct object_id *oid,
static int warn_if_dangling_symref(const char *refname,
const struct object_id *UNUSED(oid),
int flags, void *cb_data)
{
struct warn_if_dangling_data *d = cb_data;
@ -934,9 +935,11 @@ static int read_ref_at_ent(struct object_id *ooid, struct object_id *noid,
return cb->found_it;
}
static int read_ref_at_ent_newest(struct object_id *ooid, struct object_id *noid,
const char *email, timestamp_t timestamp,
int tz, const char *message, void *cb_data)
static int read_ref_at_ent_newest(struct object_id *UNUSED(ooid),
struct object_id *noid,
const char *UNUSED(email),
timestamp_t timestamp, int tz,
const char *message, void *cb_data)
{
struct read_ref_at_cb *cb = cb_data;

View File

@ -2995,7 +2995,9 @@ static int files_transaction_abort(struct ref_store *ref_store,
}
static int ref_present(const char *refname,
const struct object_id *oid, int flags, void *cb_data)
const struct object_id *UNUSED(oid),
int UNUSED(flags),
void *cb_data)
{
struct string_list *affected_refnames = cb_data;

View File

@ -2320,7 +2320,8 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb,
}
static int one_local_ref(const char *refname, const struct object_id *oid,
int flag, void *cb_data)
int UNUSED(flag),
void *cb_data)
{
struct ref ***local_tail = cb_data;
struct ref *ref;

View File

@ -9,7 +9,8 @@
static int register_replace_ref(struct repository *r,
const char *refname,
const struct object_id *oid,
int flag, void *cb_data)
int UNUSED(flag),
void *UNUSED(cb_data))
{
/* Get sha1 from refname */
const char *slash = strrchr(refname, '/');

View File

@ -1543,7 +1543,8 @@ int ref_excluded(struct string_list *ref_excludes, const char *path)
}
static int handle_one_ref(const char *path, const struct object_id *oid,
int flag, void *cb_data)
int UNUSED(flag),
void *cb_data)
{
struct all_refs_cb *cb = cb_data;
struct object *object;
@ -1627,8 +1628,8 @@ static int handle_one_reflog_ent(struct object_id *ooid, struct object_id *noid,
}
static int handle_one_reflog(const char *refname_in_wt,
const struct object_id *oid,
int flag, void *cb_data)
const struct object_id *UNUSED(oid),
int UNUSED(flag), void *cb_data)
{
struct all_refs_cb *cb = cb_data;
struct strbuf refname = STRBUF_INIT;

View File

@ -147,7 +147,8 @@ out:
}
static int add_info_ref(const char *path, const struct object_id *oid,
int flag, void *cb_data)
int UNUSED(flag),
void *cb_data)
{
struct update_info_ctx *uic = cb_data;
struct object *o = parse_object(the_repository, oid);

View File

@ -604,8 +604,10 @@ static void paint_down(struct paint_info *info, const struct object_id *oid,
free(tmp);
}
static int mark_uninteresting(const char *refname, const struct object_id *oid,
int flags, void *cb_data)
static int mark_uninteresting(const char *UNUSED(refname),
const struct object_id *oid,
int UNUSED(flags),
void *UNUSED(cb_data))
{
struct commit *commit = lookup_commit_reference_gently(the_repository,
oid, 1);
@ -715,8 +717,10 @@ struct commit_array {
int nr, alloc;
};
static int add_ref(const char *refname, const struct object_id *oid,
int flags, void *cb_data)
static int add_ref(const char *UNUSED(refname),
const struct object_id *oid,
int UNUSED(flags),
void *cb_data)
{
struct commit_array *ca = cb_data;
ALLOC_GROW(ca->commits, ca->nr + 1, ca->alloc);

View File

@ -940,8 +940,9 @@ static void free_submodules_data(struct string_list *submodules)
string_list_clear(submodules, 1);
}
static int has_remote(const char *refname, const struct object_id *oid,
int flags, void *cb_data)
static int has_remote(const char *UNUSED(refname),
const struct object_id *UNUSED(oid),
int UNUSED(flags), void *UNUSED(cb_data))
{
return 1;
}
@ -1243,8 +1244,9 @@ int push_unpushed_submodules(struct repository *r,
return ret;
}
static int append_oid_to_array(const char *ref, const struct object_id *oid,
int flags, void *data)
static int append_oid_to_array(const char *UNUSED(ref),
const struct object_id *oid,
int UNUSED(flags), void *data)
{
struct oid_array *array = data;
oid_array_append(array, oid);

View File

@ -161,7 +161,7 @@ static int cmd_rename_ref(struct ref_store *refs, const char **argv)
}
static int each_ref(const char *refname, const struct object_id *oid,
int flags, void *cb_data)
int flags, void *UNUSED(cb_data))
{
printf("%s %s 0x%x\n", oid_to_hex(oid), refname, flags);
return 0;

View File

@ -1170,7 +1170,7 @@ static int mark_our_ref(const char *refname, const char *refname_full,
}
static int check_ref(const char *refname_full, const struct object_id *oid,
int flag, void *cb_data)
int UNUSED(flag), void *UNUSED(cb_data))
{
const char *refname = strip_namespace(refname_full);
@ -1194,7 +1194,7 @@ static void format_session_id(struct strbuf *buf, struct upload_pack_data *d) {
}
static int send_ref(const char *refname, const struct object_id *oid,
int flag, void *cb_data)
int UNUSED(flag), void *cb_data)
{
static const char *capabilities = "multi_ack thin-pack side-band"
" side-band-64k ofs-delta shallow deepen-since deepen-not"
@ -1236,7 +1236,8 @@ static int send_ref(const char *refname, const struct object_id *oid,
return 0;
}
static int find_symref(const char *refname, const struct object_id *oid,
static int find_symref(const char *refname,
const struct object_id *UNUSED(oid),
int flag, void *cb_data)
{
const char *symref_target;

View File

@ -215,8 +215,10 @@ static int interpret_target(struct walker *walker, char *target, struct object_i
return -1;
}
static int mark_complete(const char *path, const struct object_id *oid,
int flag, void *cb_data)
static int mark_complete(const char *UNUSED(path),
const struct object_id *oid,
int UNUSED(flag),
void *UNUSED(cb_data))
{
struct commit *commit = lookup_commit_reference_gently(the_repository,
oid, 1);