Skip to content

Commit 5cf88fd

Browse files
avargitster
authored andcommitted
git-compat-util.h: use "UNUSED", not "UNUSED(var)"
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]>
1 parent 776515e commit 5cf88fd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+269
-269
lines changed

add-interactive.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ struct pathname_entry {
430430
struct file_item *item;
431431
};
432432

433-
static int pathname_entry_cmp(const void *UNUSED(cmp_data),
433+
static int pathname_entry_cmp(const void *cmp_data UNUSED,
434434
const struct hashmap_entry *he1,
435435
const struct hashmap_entry *he2,
436436
const void *name)

archive-tar.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ static struct archiver *find_tar_filter(const char *name, size_t len)
367367
}
368368

369369
static int tar_filter_config(const char *var, const char *value,
370-
void *UNUSED(data))
370+
void *data UNUSED)
371371
{
372372
struct archiver *ar;
373373
const char *name;
@@ -421,7 +421,7 @@ static int git_tar_config(const char *var, const char *value, void *cb)
421421
return tar_filter_config(var, value, cb);
422422
}
423423

424-
static int write_tar_archive(const struct archiver *UNUSED(ar),
424+
static int write_tar_archive(const struct archiver *ar UNUSED,
425425
struct archiver_args *args)
426426
{
427427
int err = 0;

archive-zip.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,12 +613,12 @@ static void dos_time(timestamp_t *timestamp, int *dos_date, int *dos_time)
613613
}
614614

615615
static int archive_zip_config(const char *var, const char *value,
616-
void *UNUSED(data))
616+
void *data UNUSED)
617617
{
618618
return userdiff_config(var, value);
619619
}
620620

621-
static int write_zip_archive(const struct archiver *UNUSED(ar),
621+
static int write_zip_archive(const struct archiver *ar UNUSED,
622622
struct archiver_args *args)
623623
{
624624
int err;

archive.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ struct path_exists_context {
382382
struct archiver_args *args;
383383
};
384384

385-
static int reject_entry(const struct object_id *UNUSED(oid),
385+
static int reject_entry(const struct object_id *oid UNUSED,
386386
struct strbuf *base,
387387
const char *filename, unsigned mode,
388388
void *context)

attr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ struct attr_hash_entry {
6161
};
6262

6363
/* attr_hashmap comparison function */
64-
static int attr_hash_entry_cmp(const void *UNUSED(cmp_data),
64+
static int attr_hash_entry_cmp(const void *cmp_data UNUSED,
6565
const struct hashmap_entry *eptr,
6666
const struct hashmap_entry *entry_or_key,
67-
const void *UNUSED(keydata))
67+
const void *keydata UNUSED)
6868
{
6969
const struct attr_hash_entry *a, *b;
7070

bisect.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ void find_bisection(struct commit_list **commit_list, int *reaches,
441441
}
442442

443443
static int register_ref(const char *refname, const struct object_id *oid,
444-
int UNUSED(flags), void *UNUSED(cb_data))
444+
int flags UNUSED, void *cb_data UNUSED)
445445
{
446446
struct strbuf good_prefix = STRBUF_INIT;
447447
strbuf_addstr(&good_prefix, term_good);
@@ -1161,8 +1161,8 @@ int estimate_bisect_steps(int all)
11611161
}
11621162

11631163
static int mark_for_removal(const char *refname,
1164-
const struct object_id *UNUSED(oid),
1165-
int UNUSED(flag), void *cb_data)
1164+
const struct object_id *oid UNUSED,
1165+
int flag UNUSED, void *cb_data)
11661166
{
11671167
struct string_list *refs = cb_data;
11681168
char *ref = xstrfmt("refs/bisect%s", refname);

bloom.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,10 @@ void init_bloom_filters(void)
163163
init_bloom_filter_slab(&bloom_filters);
164164
}
165165

166-
static int pathmap_cmp(const void *UNUSED(hashmap_cmp_fn_data),
166+
static int pathmap_cmp(const void *hashmap_cmp_fn_data UNUSED,
167167
const struct hashmap_entry *eptr,
168168
const struct hashmap_entry *entry_or_key,
169-
const void *UNUSED(keydata))
169+
const void *keydata UNUSED)
170170
{
171171
const struct pathmap_hash_entry *e1, *e2;
172172

builtin/am.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2301,7 +2301,7 @@ static int parse_opt_show_current_patch(const struct option *opt, const char *ar
23012301
return 0;
23022302
}
23032303

2304-
static int git_am_config(const char *k, const char *v, void *UNUSED(cb))
2304+
static int git_am_config(const char *k, const char *v, void *cb UNUSED)
23052305
{
23062306
int status;
23072307

builtin/bisect--helper.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -329,9 +329,9 @@ static int check_and_set_terms(struct bisect_terms *terms, const char *cmd)
329329
return 0;
330330
}
331331

332-
static int inc_nr(const char *UNUSED(refname),
333-
const struct object_id *UNUSED(oid),
334-
int UNUSED(flag), void *cb_data)
332+
static int inc_nr(const char *refname UNUSED,
333+
const struct object_id *oid UNUSED,
334+
int flag UNUSED, void *cb_data)
335335
{
336336
unsigned int *nr = (unsigned int *)cb_data;
337337
(*nr)++;
@@ -519,7 +519,7 @@ static int bisect_append_log_quoted(const char **argv)
519519
}
520520

521521
static int add_bisect_ref(const char *refname, const struct object_id *oid,
522-
int UNUSED(flags), void *cb)
522+
int flags UNUSED, void *cb)
523523
{
524524
struct add_bisect_ref_data *data = cb;
525525

@@ -1135,9 +1135,9 @@ static int bisect_visualize(struct bisect_terms *terms, const char **argv, int a
11351135
return res;
11361136
}
11371137

1138-
static int get_first_good(const char *UNUSED(refname),
1138+
static int get_first_good(const char *refname UNUSED,
11391139
const struct object_id *oid,
1140-
int UNUSED(flag), void *cb_data)
1140+
int flag UNUSED, void *cb_data)
11411141
{
11421142
oidcpy(cb_data, oid);
11431143
return 1;

builtin/checkout.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ static int post_checkout_hook(struct commit *old_commit, struct commit *new_comm
125125
}
126126

127127
static int update_some(const struct object_id *oid, struct strbuf *base,
128-
const char *pathname, unsigned mode, void *UNUSED(context))
128+
const char *pathname, unsigned mode, void *context UNUSED)
129129
{
130130
int len;
131131
struct cache_entry *ce;
@@ -990,7 +990,7 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
990990

991991
static int add_pending_uninteresting_ref(const char *refname,
992992
const struct object_id *oid,
993-
int UNUSED(flags), void *cb_data)
993+
int flags UNUSED, void *cb_data)
994994
{
995995
add_pending_oid(cb_data, refname, oid, UNINTERESTING);
996996
return 0;

0 commit comments

Comments
 (0)