Skip to content

Commit

Permalink
git-compat-util.h: use "UNUSED", not "UNUSED(var)"
Browse files Browse the repository at this point in the history
As reported in [1] the "UNUSED(var)" macro introduced in
2174b8c (Merge branch 'jk/unused-annotation' into next,
2022-08-24) breaks coccinelle's parsing of our sources in files where
it occurs.

Let's instead partially go with the approach suggested in [2] of
making this not take an argument. As noted in [1] "coccinelle" will
ignore such tokens in argument lists that it doesn't know about, and
it's less of a surprise to syntax highlighters.

This undoes the "help us notice when a parameter marked as unused is
actually use" part of 9b24034 (git-compat-util: add UNUSED macro,
2022-08-19), a subsequent commit will further tweak the macro to
implement a replacement for that functionality.

1. https://lore.kernel.org/git/[email protected]/
2. https://lore.kernel.org/git/[email protected]/

Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
avar authored and gitster committed Sep 1, 2022
1 parent 776515e commit 5cf88fd
Show file tree
Hide file tree
Showing 93 changed files with 269 additions and 269 deletions.
2 changes: 1 addition & 1 deletion add-interactive.c
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ struct pathname_entry {
struct file_item *item;
};

static int pathname_entry_cmp(const void *UNUSED(cmp_data),
static int pathname_entry_cmp(const void *cmp_data UNUSED,
const struct hashmap_entry *he1,
const struct hashmap_entry *he2,
const void *name)
Expand Down
4 changes: 2 additions & 2 deletions archive-tar.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ static struct archiver *find_tar_filter(const char *name, size_t len)
}

static int tar_filter_config(const char *var, const char *value,
void *UNUSED(data))
void *data UNUSED)
{
struct archiver *ar;
const char *name;
Expand Down Expand Up @@ -421,7 +421,7 @@ static int git_tar_config(const char *var, const char *value, void *cb)
return tar_filter_config(var, value, cb);
}

static int write_tar_archive(const struct archiver *UNUSED(ar),
static int write_tar_archive(const struct archiver *ar UNUSED,
struct archiver_args *args)
{
int err = 0;
Expand Down
4 changes: 2 additions & 2 deletions archive-zip.c
Original file line number Diff line number Diff line change
Expand Up @@ -613,12 +613,12 @@ static void dos_time(timestamp_t *timestamp, int *dos_date, int *dos_time)
}

static int archive_zip_config(const char *var, const char *value,
void *UNUSED(data))
void *data UNUSED)
{
return userdiff_config(var, value);
}

static int write_zip_archive(const struct archiver *UNUSED(ar),
static int write_zip_archive(const struct archiver *ar UNUSED,
struct archiver_args *args)
{
int err;
Expand Down
2 changes: 1 addition & 1 deletion archive.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ struct path_exists_context {
struct archiver_args *args;
};

static int reject_entry(const struct object_id *UNUSED(oid),
static int reject_entry(const struct object_id *oid UNUSED,
struct strbuf *base,
const char *filename, unsigned mode,
void *context)
Expand Down
4 changes: 2 additions & 2 deletions attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ struct attr_hash_entry {
};

/* attr_hashmap comparison function */
static int attr_hash_entry_cmp(const void *UNUSED(cmp_data),
static int attr_hash_entry_cmp(const void *cmp_data UNUSED,
const struct hashmap_entry *eptr,
const struct hashmap_entry *entry_or_key,
const void *UNUSED(keydata))
const void *keydata UNUSED)
{
const struct attr_hash_entry *a, *b;

Expand Down
6 changes: 3 additions & 3 deletions bisect.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 UNUSED(flags), void *UNUSED(cb_data))
int flags UNUSED, void *cb_data UNUSED)
{
struct strbuf good_prefix = STRBUF_INIT;
strbuf_addstr(&good_prefix, term_good);
Expand Down Expand Up @@ -1161,8 +1161,8 @@ int estimate_bisect_steps(int all)
}

static int mark_for_removal(const char *refname,
const struct object_id *UNUSED(oid),
int UNUSED(flag), void *cb_data)
const struct object_id *oid UNUSED,
int flag UNUSED, void *cb_data)
{
struct string_list *refs = cb_data;
char *ref = xstrfmt("refs/bisect%s", refname);
Expand Down
4 changes: 2 additions & 2 deletions bloom.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ void init_bloom_filters(void)
init_bloom_filter_slab(&bloom_filters);
}

static int pathmap_cmp(const void *UNUSED(hashmap_cmp_fn_data),
static int pathmap_cmp(const void *hashmap_cmp_fn_data UNUSED,
const struct hashmap_entry *eptr,
const struct hashmap_entry *entry_or_key,
const void *UNUSED(keydata))
const void *keydata UNUSED)
{
const struct pathmap_hash_entry *e1, *e2;

Expand Down
2 changes: 1 addition & 1 deletion builtin/am.c
Original file line number Diff line number Diff line change
Expand Up @@ -2301,7 +2301,7 @@ static int parse_opt_show_current_patch(const struct option *opt, const char *ar
return 0;
}

static int git_am_config(const char *k, const char *v, void *UNUSED(cb))
static int git_am_config(const char *k, const char *v, void *cb UNUSED)
{
int status;

Expand Down
12 changes: 6 additions & 6 deletions builtin/bisect--helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,9 @@ static int check_and_set_terms(struct bisect_terms *terms, const char *cmd)
return 0;
}

static int inc_nr(const char *UNUSED(refname),
const struct object_id *UNUSED(oid),
int UNUSED(flag), void *cb_data)
static int inc_nr(const char *refname UNUSED,
const struct object_id *oid UNUSED,
int flag UNUSED, void *cb_data)
{
unsigned int *nr = (unsigned int *)cb_data;
(*nr)++;
Expand Down Expand Up @@ -519,7 +519,7 @@ static int bisect_append_log_quoted(const char **argv)
}

static int add_bisect_ref(const char *refname, const struct object_id *oid,
int UNUSED(flags), void *cb)
int flags UNUSED, void *cb)
{
struct add_bisect_ref_data *data = cb;

Expand Down Expand Up @@ -1135,9 +1135,9 @@ static int bisect_visualize(struct bisect_terms *terms, const char **argv, int a
return res;
}

static int get_first_good(const char *UNUSED(refname),
static int get_first_good(const char *refname UNUSED,
const struct object_id *oid,
int UNUSED(flag), void *cb_data)
int flag UNUSED, void *cb_data)
{
oidcpy(cb_data, oid);
return 1;
Expand Down
4 changes: 2 additions & 2 deletions builtin/checkout.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ static int post_checkout_hook(struct commit *old_commit, struct commit *new_comm
}

static int update_some(const struct object_id *oid, struct strbuf *base,
const char *pathname, unsigned mode, void *UNUSED(context))
const char *pathname, unsigned mode, void *context UNUSED)
{
int len;
struct cache_entry *ce;
Expand Down Expand Up @@ -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 UNUSED(flags), void *cb_data)
int flags UNUSED, void *cb_data)
{
add_pending_oid(cb_data, refname, oid, UNINTERESTING);
return 0;
Expand Down
2 changes: 1 addition & 1 deletion builtin/commit-graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ static int write_option_max_new_filters(const struct option *opt,
}

static int git_commit_graph_write_config(const char *var, const char *value,
void *UNUSED(cb))
void *cb UNUSED)
{
if (!strcmp(var, "commitgraph.maxnewfilters"))
write_opts.max_new_filters = git_config_int(var, value);
Expand Down
6 changes: 3 additions & 3 deletions builtin/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ static void show_config_scope(struct strbuf *buf)
}

static int show_all_config(const char *key_, const char *value_,
void *UNUSED(cb))
void *cb UNUSED)
{
if (show_origin || show_scope) {
struct strbuf buf = STRBUF_INIT;
Expand Down Expand Up @@ -460,7 +460,7 @@ static const char *get_colorbool_slot;
static char parsed_color[COLOR_MAXLEN];

static int git_get_color_config(const char *var, const char *value,
void *UNUSED(cb))
void *cb UNUSED)
{
if (!strcmp(var, get_color_slot)) {
if (!value)
Expand Down Expand Up @@ -492,7 +492,7 @@ static int get_colorbool_found;
static int get_diff_color_found;
static int get_color_ui_found;
static int git_get_colorbool_config(const char *var, const char *value,
void *UNUSED(data))
void *data UNUSED)
{
if (!strcmp(var, get_colorbool_slot))
get_colorbool_found = git_config_colorbool(var, value);
Expand Down
4 changes: 2 additions & 2 deletions builtin/describe.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static const char *prio_names[] = {
N_("head"), N_("lightweight"), N_("annotated"),
};

static int commit_name_neq(const void *UNUSED(cmp_data),
static int commit_name_neq(const void *cmp_data UNUSED,
const struct hashmap_entry *eptr,
const struct hashmap_entry *entry_or_key,
const void *peeled)
Expand Down Expand Up @@ -141,7 +141,7 @@ static void add_to_known_names(const char *path,
}

static int get_name(const char *path, const struct object_id *oid,
int UNUSED(flag), void *UNUSED(cb_data))
int flag UNUSED, void *cb_data UNUSED)
{
int is_tag = 0;
struct object_id peeled;
Expand Down
10 changes: 5 additions & 5 deletions builtin/difftool.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ struct working_tree_entry {
char path[FLEX_ARRAY];
};

static int working_tree_entry_cmp(const void *UNUSED(cmp_data),
static int working_tree_entry_cmp(const void *cmp_data UNUSED,
const struct hashmap_entry *eptr,
const struct hashmap_entry *entry_or_key,
const void *UNUSED(keydata))
const void *keydata UNUSED)
{
const struct working_tree_entry *a, *b;

Expand All @@ -148,10 +148,10 @@ struct pair_entry {
const char path[FLEX_ARRAY];
};

static int pair_cmp(const void *UNUSED(cmp_data),
static int pair_cmp(const void *cmp_data UNUSED,
const struct hashmap_entry *eptr,
const struct hashmap_entry *entry_or_key,
const void *UNUSED(keydata))
const void *keydata UNUSED)
{
const struct pair_entry *a, *b;

Expand Down Expand Up @@ -184,7 +184,7 @@ struct path_entry {
char path[FLEX_ARRAY];
};

static int path_entry_cmp(const void *UNUSED(cmp_data),
static int path_entry_cmp(const void *cmp_data UNUSED,
const struct hashmap_entry *eptr,
const struct hashmap_entry *entry_or_key,
const void *key)
Expand Down
2 changes: 1 addition & 1 deletion builtin/fast-export.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ struct anonymized_entry_key {
size_t orig_len;
};

static int anonymized_entry_cmp(const void *UNUSED(cmp_data),
static int anonymized_entry_cmp(const void *cmp_data UNUSED,
const struct hashmap_entry *eptr,
const struct hashmap_entry *entry_or_key,
const void *keydata)
Expand Down
2 changes: 1 addition & 1 deletion builtin/fast-import.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ struct object_entry {
depth : DEPTH_BITS;
};

static int object_entry_hashcmp(const void *UNUSED(map_data),
static int object_entry_hashcmp(const void *map_data UNUSED,
const struct hashmap_entry *eptr,
const struct hashmap_entry *entry_or_key,
const void *keydata)
Expand Down
8 changes: 4 additions & 4 deletions builtin/fetch.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ struct refname_hash_entry {
char refname[FLEX_ARRAY];
};

static int refname_hash_entry_cmp(const void *UNUSED(hashmap_cmp_fn_data),
static int refname_hash_entry_cmp(const void *hashmap_cmp_fn_data UNUSED,
const struct hashmap_entry *eptr,
const struct hashmap_entry *entry_or_key,
const void *keydata)
Expand Down Expand Up @@ -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 UNUSED(flag), void *cbdata)
int flag UNUSED, void *cbdata)
{
struct hashmap *refname_map = cbdata;

Expand Down Expand Up @@ -1462,9 +1462,9 @@ static void set_option(struct transport *transport, const char *name, const char
}


static int add_oid(const char *UNUSED(refname),
static int add_oid(const char *refname UNUSED,
const struct object_id *oid,
int UNUSED(flags), void *cb_data)
int flags UNUSED, void *cb_data)
{
struct oid_array *oids = cb_data;

Expand Down
12 changes: 6 additions & 6 deletions builtin/fsck.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,9 +488,9 @@ static void fsck_handle_reflog_oid(const char *refname, struct object_id *oid,
}

static int fsck_handle_reflog_ent(struct object_id *ooid, struct object_id *noid,
const char *UNUSED(email),
timestamp_t timestamp, int UNUSED(tz),
const char *UNUSED(message), void *cb_data)
const char *email UNUSED,
timestamp_t timestamp, int tz UNUSED,
const char *message UNUSED, void *cb_data)
{
const char *refname = cb_data;

Expand All @@ -504,8 +504,8 @@ static int fsck_handle_reflog_ent(struct object_id *ooid, struct object_id *noid
}

static int fsck_handle_reflog(const char *logname,
const struct object_id *UNUSED(oid),
int UNUSED(flag), void *cb_data)
const struct object_id *oid UNUSED,
int flag UNUSED, void *cb_data)
{
struct strbuf refname = STRBUF_INIT;

Expand All @@ -516,7 +516,7 @@ static int fsck_handle_reflog(const char *logname,
}

static int fsck_handle_ref(const char *refname, const struct object_id *oid,
int UNUSED(flag), void *UNUSED(cb_data))
int flag UNUSED, void *cb_data UNUSED)
{
struct object *obj;

Expand Down
4 changes: 2 additions & 2 deletions builtin/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -782,9 +782,9 @@ struct cg_auto_data {
int limit;
};

static int dfs_on_ref(const char *UNUSED(refname),
static int dfs_on_ref(const char *refname UNUSED,
const struct object_id *oid,
int UNUSED(flags),
int flags UNUSED,
void *cb_data)
{
struct cg_auto_data *data = (struct cg_auto_data *)cb_data;
Expand Down
4 changes: 2 additions & 2 deletions builtin/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -645,8 +645,8 @@ static int show_tag_object(const struct object_id *oid, struct rev_info *rev)
return 0;
}

static int show_tree_object(const struct object_id *UNUSED(oid),
struct strbuf *UNUSED(base),
static int show_tree_object(const struct object_id *oid UNUSED,
struct strbuf *base UNUSED,
const char *pathname, unsigned mode,
void *context)
{
Expand Down
10 changes: 5 additions & 5 deletions builtin/ls-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ static int show_recursive(const char *base, size_t baselen, const char *pathname
}

static int show_tree_fmt(const struct object_id *oid, struct strbuf *base,
const char *pathname, unsigned mode, void *UNUSED(context))
const char *pathname, unsigned mode, void *context UNUSED)
{
size_t baselen;
int recurse = 0;
Expand Down Expand Up @@ -213,7 +213,7 @@ static void show_tree_common_default_long(struct strbuf *base,

static int show_tree_default(const struct object_id *oid, struct strbuf *base,
const char *pathname, unsigned mode,
void *UNUSED(context))
void *context UNUSED)
{
int early;
int recurse;
Expand All @@ -231,7 +231,7 @@ static int show_tree_default(const struct object_id *oid, struct strbuf *base,

static int show_tree_long(const struct object_id *oid, struct strbuf *base,
const char *pathname, unsigned mode,
void *UNUSED(context))
void *context UNUSED)
{
int early;
int recurse;
Expand Down Expand Up @@ -261,7 +261,7 @@ static int show_tree_long(const struct object_id *oid, struct strbuf *base,

static int show_tree_name_only(const struct object_id *oid, struct strbuf *base,
const char *pathname, unsigned mode,
void *UNUSED(context))
void *context UNUSED)
{
int early;
int recurse;
Expand All @@ -282,7 +282,7 @@ static int show_tree_name_only(const struct object_id *oid, struct strbuf *base,

static int show_tree_object(const struct object_id *oid, struct strbuf *base,
const char *pathname, unsigned mode,
void *UNUSED(context))
void *context UNUSED)
{
int early;
int recurse;
Expand Down
Loading

0 comments on commit 5cf88fd

Please sign in to comment.