{"thread":{"id":"58328","subject":"[PATCH 0/11] annotating unused function parameters","startedAt":"2022-08-19T10:07:07Z","lastAt":"2022-08-26T16:37:21Z","messageCount":22,"participants":["Jeff King","Ævar Arnfjörð Bjarmason","Derrick Stolee","Junio C Hamano","Phillip Wood"],"isPatch":true,"patchVersion":1,"patchTotal":11},"messages":[{"id":"461526","messageId":"Yv9gxqH6nK2KYnNj@coredump.intra.peff.net","threadId":"58328","inReplyTo":null,"subject":"[PATCH 0/11] annotating unused function parameters","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2022-08-19T10:07:02Z","receivedAt":"2022-08-19T10:07:07Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"I've been carrying a bunch of patches (for almost 4 years now!) that get\nthe code base compiling cleanly with -Wunused-parameter. This is a\nuseful warning in my opinion; it found real bugs[1] when applied to the\nwhole code base. So it would be nice to be able to turn it on all the\ntime and get the same protection going forward.\n\nUnfortunately, there's a catch: some functions really do need to have\nunused parameters, because they're conforming to a specific interface.\nSome reasons might be:\n\n  - they're passed as callback function pointers\n\n  - they're virtual functions called as pointers via a struct\n\n  - they're compat functions that implement a well-known interface (this\n    is especially true for \"trivial\" wrappers that are noops, or return\n    ENOSYS, etc)\n\nSo we need some way to annotate the acceptable cases. This series\nintroduces a macro to do so. That's in the first patch. The other ten\napply it in various situations, with the end goal being that we could\nflip the warning on for DEVELOPER=1 builds. This series doesn't get us\nall the way there! I have ~100 more patches adding similar annotations.\nMy goal here is to give a taste of the direction and make sure it's\nwhere we want to go.\n\nI've grouped related annotations into a single patch. They should be\nfairly easy to review. The annotation macro is written in such a way\nthat the compiler will complain if it's wrong. So really what you care\nabout in each is:\n\n  - is this a case where we really want to be annotating and not\n    removing unused parameters (or using them)? Each commit should\n    explain this, and it's usually obvious (e.g., a specific type of\n    callback)\n\n  - does each hunk in the patch match the group\n\n  - did I introduce any formatting problems along the way :)\n\n  - (optional) are there other cases that should be in the group. This\n    is probably not worth your time to go digging for. The other ~100\n    patches aren't carefully organized and written up yet, so it's quite\n    possible that I've mistakenly left a related case there that _could_\n    be folded in. But those shake out much easier as the number of cases\n    is reduced, and you can ask -Wunused-parameter to find them for you.\n\nAnd of course the most important question is: do we like this direction\noverall. This mass-annotation is a one-time pain. Going forward, the\nonly work would be requiring people to annotate new functions they add\n(which again, is mostly going to be callbacks). IMHO it's worth it. In\naddition to possibly finding errors, I think the annotations serve as an\nextra clue for people reading the code about what the author intended.\n\nSo without further ado, the patches are:\n\n  [01/11]: git-compat-util: add UNUSED macro\n  [02/11]: refs: mark unused each_ref_fn parameters\n  [03/11]: refs: mark unused reflog callback parameters\n  [04/11]: refs: mark unused virtual method parameters\n  [05/11]: transport: mark bundle transport_options as unused\n  [06/11]: streaming: mark unused virtual method parameters\n  [07/11]: config: mark unused callback parameters\n  [08/11]: hashmap: mark unused callback parameters\n  [09/11]: mark unused read_tree_recursive() callback parameters\n  [10/11]: run-command: mark unused async callback parameters\n  [11/11]: is_path_owned_by_current_uid(): mark \"report\" parameter as unused\n\n add-interactive.c           |  2 +-\n archive-tar.c               |  5 +++--\n archive-zip.c               |  5 +++--\n archive.c                   |  3 ++-\n attr.c                      |  4 ++--\n bisect.c                    |  7 ++++---\n bloom.c                     |  4 ++--\n builtin/am.c                |  2 +-\n builtin/bisect--helper.c    | 12 +++++++-----\n builtin/checkout.c          |  4 ++--\n builtin/commit-graph.c      |  2 +-\n builtin/config.c            |  8 +++++---\n builtin/describe.c          |  5 +++--\n builtin/difftool.c          | 10 +++++-----\n builtin/fast-export.c       |  2 +-\n builtin/fast-import.c       |  2 +-\n builtin/fetch.c             |  9 +++++----\n builtin/fsck.c              | 12 +++++++-----\n builtin/gc.c                |  5 +++--\n builtin/log.c               |  7 ++++---\n builtin/ls-tree.c           | 13 ++++++++-----\n builtin/multi-pack-index.c  |  2 +-\n builtin/name-rev.c          |  3 ++-\n builtin/pack-objects.c      | 12 +++++++-----\n builtin/receive-pack.c      |  4 ++--\n builtin/reflog.c            |  3 ++-\n builtin/remote.c            | 14 +++++++++-----\n builtin/repack.c            |  4 ++--\n builtin/rev-parse.c         |  6 ++++--\n builtin/show-branch.c       |  6 +++---\n builtin/show-ref.c          |  7 ++++---\n builtin/stash.c             |  9 ++++++---\n builtin/submodule--helper.c |  5 +++--\n color.c                     |  2 +-\n commit-graph.c              |  4 ++--\n commit.c                    |  5 +++--\n compat/terminal.c           |  2 +-\n config.c                    |  7 ++++---\n convert.c                   |  4 ++--\n delta-islands.c             |  4 ++--\n diff.c                      |  5 +++--\n dir.c                       |  4 ++--\n environment.c               |  4 ++--\n fetch-pack.c                | 14 +++++++++-----\n git-compat-util.h           | 13 +++++++++++--\n gpg-interface.c             |  2 +-\n hashmap.c                   | 10 +++++-----\n help.c                      |  5 +++--\n http-backend.c              |  2 +-\n ident.c                     |  2 +-\n ll-merge.c                  |  3 ++-\n log-tree.c                  |  3 ++-\n ls-refs.c                   |  3 ++-\n merge-recursive.c           | 12 ++++++------\n name-hash.c                 |  4 ++--\n negotiator/default.c        |  3 ++-\n negotiator/skipping.c       |  3 ++-\n notes.c                     |  5 +++--\n object-name.c               | 10 +++++++---\n object-store.h              |  2 +-\n oidmap.c                    |  2 +-\n packfile.c                  |  2 +-\n pager.c                     |  3 ++-\n patch-ids.c                 |  2 +-\n pretty.c                    |  3 ++-\n range-diff.c                |  6 ++++--\n ref-filter.c                |  2 +-\n reflog.c                    | 16 ++++++++++------\n refs.c                      | 23 ++++++++++++++---------\n refs/files-backend.c        | 14 ++++++++------\n refs/iterator.c             |  6 +++---\n refs/packed-backend.c       | 14 ++++++++------\n remote.c                    | 22 +++++++++++++---------\n replace-object.c            |  3 ++-\n revision.c                  | 18 +++++++++++-------\n send-pack.c                 |  2 +-\n sequencer.c                 |  5 +++--\n server-info.c               |  3 ++-\n shallow.c                   | 12 ++++++++----\n streaming.c                 |  6 +++---\n strmap.c                    |  4 ++--\n sub-process.c               |  4 ++--\n submodule-config.c          |  8 ++++----\n submodule.c                 | 13 ++++++++-----\n t/helper/test-config.c      |  2 +-\n t/helper/test-ref-store.c   |  4 ++--\n t/helper/test-userdiff.c    |  2 +-\n trailer.c                   |  6 ++++--\n transport.c                 |  2 +-\n upload-pack.c               |  7 ++++---\n walker.c                    |  6 ++++--\n wt-status.c                 | 14 +++++++++-----\n 92 files changed, 337 insertions(+), 234 deletions(-)\n\n-Peff\n\n[1] Here are some examples of bugs found by -Wunused-parameter:\n\n     - https://lore.kernel.org/git/20181102063156.GA30252@sigill.intra.peff.net/\n     - https://lore.kernel.org/git/20181102052239.GA19162@sigill.intra.peff.net/\n\n"},{"id":"461527","messageId":"Yv9hG/12/yvqZOnf@coredump.intra.peff.net","threadId":"58328","inReplyTo":"Yv9gxqH6nK2KYnNj@coredump.intra.peff.net","subject":"[PATCH 01/11] git-compat-util: add UNUSED macro","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2022-08-19T10:08:27Z","receivedAt":"2022-08-19T10:08:37Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"In preparation for compiling with -Wunused-parameter, we'd like to be\nable to annotate some function parameters as false positives (e.g.,\nparameters which must exist to conform to a callback interface).\n\nIdeally our annotation will:\n\n  - be portable, turning into nothing on platforms which don't support\n    it\n\n  - be easy to read, without looking too syntactically odd or taking\n    attention away from the rest of the parameters\n\n  - help us notice when a parameter marked as unused is actually used,\n    which keeps our annotations accurate. In theory a compiler could\n    tell us this easily, but gcc has no such warning. Clang has\n    -Wused-but-marked-unused, but it triggers false positives with our\n    MAYBE_UNUSED annotation (e.g., for commit-slab functions)\n\nThis patch introduces an UNUSED() macro which takes the parameter name\nas an argument. That lets us tweak the name in such a way that we'll\nnotice if somebody tries to use it. It looks like this in use:\n\n  int some_ref_cb(const char *refname,\n                  const struct object_id *UNUSED(oid),\n                  int UNUSED(flags),\n                  void *UNUSED(data))\n  {\n        printf(\"got refname %s\", refname);\n        return 0;\n  }\n\nBecause the unused parameter names are rewritten behind the scenes to\nUNUSED_oid, etc, adding code like:\n\n  printf(\"oid is %s\", oid_to_hex(oid));\n\nwill fail compilation with \"oid undeclared\". Sadly, the \"did you mean\"\nfeature of modern compilers is not generally smart enough to suggest the\n\"unused\" name. If we used a very short prefix like U_oid, that does\nconvince gcc to say \"did you mean\", but since the \"U_\" in the suggestion\nisn't much of a hint, it doesn't really help. In practice, a look at the\nfunction definition usually makes the problem pretty obvious.\n\nNote that we have to put the definition of UNUSED early in\ngit-compat-util.h, because it will eventually be used for some compat\nfunctions themselves (both directly here and in mingw.h).\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n git-compat-util.h | 6 ++++++\n 1 file changed, 6 insertions(+)\n\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex 36a25ae252..c6669db07d 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -189,6 +189,12 @@ struct strbuf;\n #define _NETBSD_SOURCE 1\n #define _SGI_SOURCE 1\n \n+#if defined(__GNUC__)\n+#define UNUSED(var) UNUSED_##var __attribute__((unused))\n+#else\n+#define UNUSED(var) UNUSED_##var\n+#endif\n+\n #if defined(WIN32) && !defined(__CYGWIN__) /* Both MinGW and MSVC */\n # if !defined(_WIN32_WINNT)\n #  define _WIN32_WINNT 0x0600\n-- \n2.37.2.928.g0821088f4a\n\n"},{"id":"461528","messageId":"Yv9hIG/TbBLdOAwa@coredump.intra.peff.net","threadId":"58328","inReplyTo":"Yv9gxqH6nK2KYnNj@coredump.intra.peff.net","subject":"[PATCH 02/11] refs: mark unused each_ref_fn parameters","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2022-08-19T10:08:32Z","receivedAt":"2022-08-19T10:08:39Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"Functions used with for_each_ref(), etc, need to conform to the\neach_ref_fn interface. But most of them don't need every parameter;\nlet's annotate the unused ones to quiet -Wunused-parameter.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n bisect.c                    |  7 ++++---\n builtin/bisect--helper.c    | 12 +++++++-----\n builtin/checkout.c          |  2 +-\n builtin/describe.c          |  3 ++-\n builtin/fetch.c             |  7 ++++---\n builtin/fsck.c              |  7 ++++---\n builtin/gc.c                |  5 +++--\n builtin/name-rev.c          |  3 ++-\n builtin/pack-objects.c      | 12 +++++++-----\n builtin/receive-pack.c      |  2 +-\n builtin/reflog.c            |  3 ++-\n builtin/remote.c            | 12 ++++++++----\n builtin/repack.c            |  4 ++--\n builtin/rev-parse.c         |  6 ++++--\n builtin/show-branch.c       |  6 +++---\n builtin/show-ref.c          |  7 ++++---\n builtin/submodule--helper.c |  5 +++--\n commit-graph.c              |  4 ++--\n delta-islands.c             |  2 +-\n fetch-pack.c                | 12 ++++++++----\n help.c                      |  5 +++--\n http-backend.c              |  2 +-\n log-tree.c                  |  3 ++-\n negotiator/default.c        |  3 ++-\n negotiator/skipping.c       |  3 ++-\n notes.c                     |  5 +++--\n object-name.c               |  3 ++-\n reflog.c                    |  3 ++-\n refs.c                      | 11 +++++++----\n refs/files-backend.c        |  4 +++-\n remote.c                    |  3 ++-\n replace-object.c            |  3 ++-\n revision.c                  |  7 ++++---\n server-info.c               |  3 ++-\n shallow.c                   | 12 ++++++++----\n submodule.c                 | 10 ++++++----\n t/helper/test-ref-store.c   |  2 +-\n upload-pack.c               |  7 ++++---\n walker.c                    |  6 ++++--\n 39 files changed, 132 insertions(+), 84 deletions(-)\n\ndiff --git a/bisect.c b/bisect.c\nindex 38b3891f3a..07ccd1bce6 100644\n--- a/bisect.c\n+++ b/bisect.c\n@@ -441,7 +441,7 @@ void find_bisection(struct commit_list **commit_list, int *reaches,\n }\n \n static int register_ref(const char *refname, const struct object_id *oid,\n-\t\t\tint flags, void *cb_data)\n+\t\t\tint UNUSED(flags), void *UNUSED(cb_data))\n {\n \tstruct strbuf good_prefix = STRBUF_INIT;\n \tstrbuf_addstr(&good_prefix, term_good);\n@@ -1160,8 +1160,9 @@ int estimate_bisect_steps(int all)\n \treturn (e < 3 * x) ? n : n - 1;\n }\n \n-static int mark_for_removal(const char *refname, const struct object_id *oid,\n-\t\t\t    int flag, void *cb_data)\n+static int mark_for_removal(const char *refname,\n+\t\t\t    const struct object_id *UNUSED(oid),\n+\t\t\t    int UNUSED(flag), void *cb_data)\n {\n \tstruct string_list *refs = cb_data;\n \tchar *ref = xstrfmt(\"refs/bisect%s\", refname);\ndiff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c\nindex 8a052c7111..87c8b2d818 100644\n--- a/builtin/bisect--helper.c\n+++ b/builtin/bisect--helper.c\n@@ -329,8 +329,9 @@ static int check_and_set_terms(struct bisect_terms *terms, const char *cmd)\n \treturn 0;\n }\n \n-static int inc_nr(const char *refname, const struct object_id *oid,\n-\t\t  int flag, void *cb_data)\n+static int inc_nr(const char *UNUSED(refname),\n+\t\t  const struct object_id *UNUSED(oid),\n+\t\t  int UNUSED(flag), void *cb_data)\n {\n \tunsigned int *nr = (unsigned int *)cb_data;\n \t(*nr)++;\n@@ -518,7 +519,7 @@ static int bisect_append_log_quoted(const char **argv)\n }\n \n static int add_bisect_ref(const char *refname, const struct object_id *oid,\n-\t\t\t  int flags, void *cb)\n+\t\t\t  int UNUSED(flags), void *cb)\n {\n \tstruct add_bisect_ref_data *data = cb;\n \n@@ -1134,8 +1135,9 @@ static int bisect_visualize(struct bisect_terms *terms, const char **argv, int a\n \treturn res;\n }\n \n-static int get_first_good(const char *refname, const struct object_id *oid,\n-\t\t\t  int flag, void *cb_data)\n+static int get_first_good(const char *UNUSED(refname),\n+\t\t\t  const struct object_id *oid,\n+\t\t\t  int UNUSED(flag), void *cb_data)\n {\n \toidcpy(cb_data, oid);\n \treturn 1;\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex f9d63d80b9..713410ce2c 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -990,7 +990,7 @@ static void update_refs_for_switch(const struct checkout_opts *opts,\n \n static int add_pending_uninteresting_ref(const char *refname,\n \t\t\t\t\t const struct object_id *oid,\n-\t\t\t\t\t int flags, void *cb_data)\n+\t\t\t\t\t int UNUSED(flags), void *cb_data)\n {\n \tadd_pending_oid(cb_data, refname, oid, UNINTERESTING);\n \treturn 0;\ndiff --git a/builtin/describe.c b/builtin/describe.c\nindex a76f1a1a7a..3af36483f2 100644\n--- a/builtin/describe.c\n+++ b/builtin/describe.c\n@@ -140,7 +140,8 @@ static void add_to_known_names(const char *path,\n \t}\n }\n \n-static int get_name(const char *path, const struct object_id *oid, int flag, void *cb_data)\n+static int get_name(const char *path, const struct object_id *oid,\n+\t\t    int UNUSED(flag), void *UNUSED(cb_data))\n {\n \tint is_tag = 0;\n \tstruct object_id peeled;\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex fc5cecb483..9e7c8099fe 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -329,7 +329,7 @@ static struct refname_hash_entry *refname_hash_add(struct hashmap *map,\n \n static int add_one_refname(const char *refname,\n \t\t\t   const struct object_id *oid,\n-\t\t\t   int flag, void *cbdata)\n+\t\t\t   int UNUSED(flag), void *cbdata)\n {\n \tstruct hashmap *refname_map = cbdata;\n \n@@ -1462,8 +1462,9 @@ static void set_option(struct transport *transport, const char *name, const char\n }\n \n \n-static int add_oid(const char *refname, const struct object_id *oid, int flags,\n-\t\t   void *cb_data)\n+static int add_oid(const char *UNUSED(refname),\n+\t\t   const struct object_id *oid,\n+\t\t   int UNUSED(flags), void *cb_data)\n {\n \tstruct oid_array *oids = cb_data;\n \ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex 6c73092f10..36f1524614 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -502,8 +502,9 @@ static int fsck_handle_reflog_ent(struct object_id *ooid, struct object_id *noid\n \treturn 0;\n }\n \n-static int fsck_handle_reflog(const char *logname, const struct object_id *oid,\n-\t\t\t      int flag, void *cb_data)\n+static int fsck_handle_reflog(const char *logname,\n+\t\t\t      const struct object_id *UNUSED(oid),\n+\t\t\t      int UNUSED(flag), void *cb_data)\n {\n \tstruct strbuf refname = STRBUF_INIT;\n \n@@ -514,7 +515,7 @@ static int fsck_handle_reflog(const char *logname, const struct object_id *oid,\n }\n \n static int fsck_handle_ref(const char *refname, const struct object_id *oid,\n-\t\t\t   int flag, void *cb_data)\n+\t\t\t   int UNUSED(flag), void *UNUSED(cb_data))\n {\n \tstruct object *obj;\n \ndiff --git a/builtin/gc.c b/builtin/gc.c\nindex eeff2b760e..e4ede128c9 100644\n--- a/builtin/gc.c\n+++ b/builtin/gc.c\n@@ -782,8 +782,9 @@ struct cg_auto_data {\n \tint limit;\n };\n \n-static int dfs_on_ref(const char *refname,\n-\t\t      const struct object_id *oid, int flags,\n+static int dfs_on_ref(const char *UNUSED(refname),\n+\t\t      const struct object_id *oid,\n+\t\t      int UNUSED(flags),\n \t\t      void *cb_data)\n {\n \tstruct cg_auto_data *data = (struct cg_auto_data *)cb_data;\ndiff --git a/builtin/name-rev.c b/builtin/name-rev.c\nindex 580b1eb170..c4dc143c4b 100644\n--- a/builtin/name-rev.c\n+++ b/builtin/name-rev.c\n@@ -344,7 +344,8 @@ static int cmp_by_tag_and_age(const void *a_, const void *b_)\n \treturn a->taggerdate != b->taggerdate;\n }\n \n-static int name_ref(const char *path, const struct object_id *oid, int flags, void *cb_data)\n+static int name_ref(const char *path, const struct object_id *oid,\n+\t\t    int UNUSED(flags), void *cb_data)\n {\n \tstruct object *o = parse_object(the_repository, oid);\n \tstruct name_ref_data *data = cb_data;\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 39e28cfcaf..eb93e5c8fe 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -759,8 +759,8 @@ static enum write_one_status write_one(struct hashfile *f,\n \treturn WRITE_ONE_WRITTEN;\n }\n \n-static int mark_tagged(const char *path, const struct object_id *oid, int flag,\n-\t\t       void *cb_data)\n+static int mark_tagged(const char *UNUSED(path), const struct object_id *oid,\n+\t\t       int UNUSED(flag), void *UNUSED(cb_data))\n {\n \tstruct object_id peeled;\n \tstruct object_entry *entry = packlist_find(&to_pack, oid);\n@@ -3035,7 +3035,8 @@ static void add_tag_chain(const struct object_id *oid)\n \t}\n }\n \n-static int add_ref_tag(const char *tag, const struct object_id *oid, int flag, void *cb_data)\n+static int add_ref_tag(const char *UNUSED(tag), const struct object_id *oid,\n+\t\t       int UNUSED(flag), void *UNUSED(cb_data))\n {\n \tstruct object_id peeled;\n \n@@ -3950,8 +3951,9 @@ static void record_recent_commit(struct commit *commit, void *data)\n }\n \n static int mark_bitmap_preferred_tip(const char *refname,\n-\t\t\t\t     const struct object_id *oid, int flags,\n-\t\t\t\t     void *_data)\n+\t\t\t\t     const struct object_id *oid,\n+\t\t\t\t     int UNUSED(flags),\n+\t\t\t\t     void *UNUSED(data))\n {\n \tstruct object_id peeled;\n \tstruct object *object;\ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex 31b48e728b..afd36c9c53 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -291,7 +291,7 @@ static void show_ref(const char *path, const struct object_id *oid)\n }\n \n static int show_ref_cb(const char *path_full, const struct object_id *oid,\n-\t\t       int flag, void *data)\n+\t\t       int UNUSED(flag), void *data)\n {\n \tstruct oidset *seen = data;\n \tconst char *path = strip_namespace(path_full);\ndiff --git a/builtin/reflog.c b/builtin/reflog.c\nindex 8123956847..ab54d73611 100644\n--- a/builtin/reflog.c\n+++ b/builtin/reflog.c\n@@ -56,7 +56,8 @@ struct worktree_reflogs {\n \tstruct string_list reflogs;\n };\n \n-static int collect_reflog(const char *ref, const struct object_id *oid, int unused, void *cb_data)\n+static int collect_reflog(const char *ref, const struct object_id *UNUSED(oid),\n+\t\t\t  int UNUSED(flags), void *cb_data)\n {\n \tstruct worktree_reflogs *cb = cb_data;\n \tstruct worktree *worktree = cb->worktree;\ndiff --git a/builtin/remote.c b/builtin/remote.c\nindex c713463d89..b390360f07 100644\n--- a/builtin/remote.c\n+++ b/builtin/remote.c\n@@ -264,7 +264,8 @@ static const char *abbrev_ref(const char *name, const char *prefix)\n }\n #define abbrev_branch(name) abbrev_ref((name), \"refs/heads/\")\n \n-static int config_read_branches(const char *key, const char *value, void *cb)\n+static int config_read_branches(const char *key, const char *value,\n+\t\t\t\tvoid *UNUSED(data))\n {\n \tconst char *orig_key = key;\n \tchar *name;\n@@ -538,7 +539,8 @@ struct branches_for_remote {\n };\n \n static int add_branch_for_removal(const char *refname,\n-\tconst struct object_id *oid, int flags, void *cb_data)\n+\t\t\t\t  const struct object_id *UNUSED(oid),\n+\t\t\t\t  int UNUSED(flags), void *cb_data)\n {\n \tstruct branches_for_remote *branches = cb_data;\n \tstruct refspec_item refspec;\n@@ -580,7 +582,8 @@ struct rename_info {\n };\n \n static int read_remote_branches(const char *refname,\n-\tconst struct object_id *oid, int flags, void *cb_data)\n+\t\t\t\tconst struct object_id *UNUSED(oid),\n+\t\t\t\tint UNUSED(flags), void *cb_data)\n {\n \tstruct rename_info *rename = cb_data;\n \tstruct strbuf buf = STRBUF_INIT;\n@@ -953,7 +956,8 @@ static void free_remote_ref_states(struct ref_states *states)\n }\n \n static int append_ref_to_tracked_list(const char *refname,\n-\tconst struct object_id *oid, int flags, void *cb_data)\n+\t\t\t\t      const struct object_id *UNUSED(oid),\n+\t\t\t\t      int flags, void *cb_data)\n {\n \tstruct ref_states *states = cb_data;\n \tstruct refspec_item refspec;\ndiff --git a/builtin/repack.c b/builtin/repack.c\nindex 482b66f57d..ff952dec48 100644\n--- a/builtin/repack.c\n+++ b/builtin/repack.c\n@@ -514,9 +514,9 @@ struct midx_snapshot_ref_data {\n \tint preferred;\n };\n \n-static int midx_snapshot_ref_one(const char *refname,\n+static int midx_snapshot_ref_one(const char *UNUSED(refname),\n \t\t\t\t const struct object_id *oid,\n-\t\t\t\t int flag, void *_data)\n+\t\t\t\t int UNUSED(flag), void *_data)\n {\n \tstruct midx_snapshot_ref_data *data = _data;\n \tstruct object_id peeled;\ndiff --git a/builtin/rev-parse.c b/builtin/rev-parse.c\nindex b259d8990a..3c448d438b 100644\n--- a/builtin/rev-parse.c\n+++ b/builtin/rev-parse.c\n@@ -195,15 +195,17 @@ static int show_default(void)\n \treturn 0;\n }\n \n-static int show_reference(const char *refname, const struct object_id *oid, int flag, void *cb_data)\n+static int show_reference(const char *refname, const struct object_id *oid,\n+\t\t\t  int UNUSED(flag), void *UNUSED(cb_data))\n {\n \tif (ref_excluded(ref_excludes, refname))\n \t\treturn 0;\n \tshow_rev(NORMAL, oid, refname);\n \treturn 0;\n }\n \n-static int anti_reference(const char *refname, const struct object_id *oid, int flag, void *cb_data)\n+static int anti_reference(const char *refname, const struct object_id *oid,\n+\t\t\t  int UNUSED(flag), void *UNUSED(cb_data))\n {\n \tshow_rev(REVERSED, oid, refname);\n \treturn 0;\ndiff --git a/builtin/show-branch.c b/builtin/show-branch.c\nindex 64c649c6a2..3ec011bea4 100644\n--- a/builtin/show-branch.c\n+++ b/builtin/show-branch.c\n@@ -404,7 +404,7 @@ static int append_ref(const char *refname, const struct object_id *oid,\n }\n \n static int append_head_ref(const char *refname, const struct object_id *oid,\n-\t\t\t   int flag, void *cb_data)\n+\t\t\t   int UNUSED(flag), void *UNUSED(cb_data))\n {\n \tstruct object_id tmp;\n \tint ofs = 11;\n@@ -419,7 +419,7 @@ static int append_head_ref(const char *refname, const struct object_id *oid,\n }\n \n static int append_remote_ref(const char *refname, const struct object_id *oid,\n-\t\t\t     int flag, void *cb_data)\n+\t\t\t     int UNUSED(flag), void *UNUSED(cb_data))\n {\n \tstruct object_id tmp;\n \tint ofs = 13;\n@@ -434,7 +434,7 @@ static int append_remote_ref(const char *refname, const struct object_id *oid,\n }\n \n static int append_tag_ref(const char *refname, const struct object_id *oid,\n-\t\t\t  int flag, void *cb_data)\n+\t\t\t  int UNUSED(flag), void *UNUSED(cb_data))\n {\n \tif (!starts_with(refname, \"refs/tags/\"))\n \t\treturn 0;\ndiff --git a/builtin/show-ref.c b/builtin/show-ref.c\nindex 5fa207a044..9746537220 100644\n--- a/builtin/show-ref.c\n+++ b/builtin/show-ref.c\n@@ -47,7 +47,7 @@ static void show_one(const char *refname, const struct object_id *oid)\n }\n \n static int show_ref(const char *refname, const struct object_id *oid,\n-\t\t    int flag, void *cbdata)\n+\t\t    int UNUSED(flag), void *UNUSED(cbdata))\n {\n \tif (show_head && !strcmp(refname, \"HEAD\"))\n \t\tgoto match;\n@@ -77,8 +77,9 @@ static int show_ref(const char *refname, const struct object_id *oid,\n \treturn 0;\n }\n \n-static int add_existing(const char *refname, const struct object_id *oid,\n-\t\t\tint flag, void *cbdata)\n+static int add_existing(const char *refname,\n+\t\t\tconst struct object_id *UNUSED(oid),\n+\t\t\tint UNUSED(flag), void *cbdata)\n {\n \tstruct string_list *list = (struct string_list *)cbdata;\n \tstring_list_insert(list, refname);\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex b63f420ece..e24e721458 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -622,8 +622,9 @@ static void print_status(unsigned int flags, char state, const char *path,\n \tprintf(\"\\n\");\n }\n \n-static int handle_submodule_head_ref(const char *refname,\n-\t\t\t\t     const struct object_id *oid, int flags,\n+static int handle_submodule_head_ref(const char *UNUSED(refname),\n+\t\t\t\t     const struct object_id *oid,\n+\t\t\t\t     int UNUSED(flags),\n \t\t\t\t     void *cb_data)\n {\n \tstruct object_id *output = cb_data;\ndiff --git a/commit-graph.c b/commit-graph.c\nindex f2a36032f8..1ab5c3233f 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -1639,9 +1639,9 @@ struct refs_cb_data {\n \tstruct progress *progress;\n };\n \n-static int add_ref_to_set(const char *refname,\n+static int add_ref_to_set(const char *UNUSED(refname),\n \t\t\t  const struct object_id *oid,\n-\t\t\t  int flags, void *cb_data)\n+\t\t\t  int UNUSED(flags), void *cb_data)\n {\n \tstruct object_id peeled;\n \tstruct refs_cb_data *data = (struct refs_cb_data *)cb_data;\ndiff --git a/delta-islands.c b/delta-islands.c\nindex aa98b2e541..13eb96e0c4 100644\n--- a/delta-islands.c\n+++ b/delta-islands.c\n@@ -365,7 +365,7 @@ static void add_ref_to_island(const char *island_name, const struct object_id *o\n }\n \n static int find_island_for_ref(const char *refname, const struct object_id *oid,\n-\t\t\t       int flags, void *data)\n+\t\t\t       int UNUSED(flags), void *UNUSED(data))\n {\n \t/*\n \t * We should advertise 'ARRAY_SIZE(matches) - 2' as the max,\ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex d35be4177b..bda9d0f433 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -176,8 +176,10 @@ static int rev_list_insert_ref(struct fetch_negotiator *negotiator,\n \treturn 0;\n }\n \n-static int rev_list_insert_ref_oid(const char *refname, const struct object_id *oid,\n-\t\t\t\t   int flag, void *cb_data)\n+static int rev_list_insert_ref_oid(const char *UNUSED(refname),\n+\t\t\t\t   const struct object_id *oid,\n+\t\t\t\t   int UNUSED(flag),\n+\t\t\t\t   void *cb_data)\n {\n \treturn rev_list_insert_ref(cb_data, oid);\n }\n@@ -580,8 +582,10 @@ static int mark_complete(const struct object_id *oid)\n \treturn 0;\n }\n \n-static int mark_complete_oid(const char *refname, const struct object_id *oid,\n-\t\t\t     int flag, void *cb_data)\n+static int mark_complete_oid(const char *UNUSED(refname),\n+\t\t\t     const struct object_id *oid,\n+\t\t\t     int UNUSED(flag),\n+\t\t\t     void *UNUSED(cb_data))\n {\n \treturn mark_complete(oid);\n }\ndiff --git a/help.c b/help.c\nindex 991e33f8a6..c5b5848188 100644\n--- a/help.c\n+++ b/help.c\n@@ -781,8 +781,9 @@ struct similar_ref_cb {\n \tstruct string_list *similar_refs;\n };\n \n-static int append_similar_ref(const char *refname, const struct object_id *oid,\n-\t\t\t      int flags, void *cb_data)\n+static int append_similar_ref(const char *refname,\n+\t\t\t      const struct object_id *UNUSED(oid),\n+\t\t\t      int UNUSED(flags), void *cb_data)\n {\n \tstruct similar_ref_cb *cb = (struct similar_ref_cb *)(cb_data);\n \tchar *branch = strrchr(refname, '/') + 1;\ndiff --git a/http-backend.c b/http-backend.c\nindex 58b83a9f66..20db0ea620 100644\n--- a/http-backend.c\n+++ b/http-backend.c\n@@ -505,7 +505,7 @@ static void run_service(const char **argv, int buffer_input)\n }\n \n static int show_text_ref(const char *name, const struct object_id *oid,\n-\t\t\t int flag, void *cb_data)\n+\t\t\t int UNUSED(flag), void *cb_data)\n {\n \tconst char *name_nons = strip_namespace(name);\n \tstruct strbuf *buf = cb_data;\ndiff --git a/log-tree.c b/log-tree.c\nindex 82d9b5f650..4ca872eef4 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -135,7 +135,8 @@ static int ref_filter_match(const char *refname,\n }\n \n static int add_ref_decoration(const char *refname, const struct object_id *oid,\n-\t\t\t      int flags, void *cb_data)\n+\t\t\t      int UNUSED(flags),\n+\t\t\t      void *cb_data)\n {\n \tstruct object *obj;\n \tenum object_type objtype;\ndiff --git a/negotiator/default.c b/negotiator/default.c\nindex 434189ae5d..10f0a46e62 100644\n--- a/negotiator/default.c\n+++ b/negotiator/default.c\n@@ -36,7 +36,8 @@ static void rev_list_push(struct negotiation_state *ns,\n }\n \n static int clear_marks(const char *refname, const struct object_id *oid,\n-\t\t       int flag, void *cb_data)\n+\t\t       int UNUSED(flag),\n+\t\t       void *UNUSED(cb_data))\n {\n \tstruct object *o = deref_tag(the_repository, parse_object(the_repository, oid), refname, 0);\n \ndiff --git a/negotiator/skipping.c b/negotiator/skipping.c\nindex 1236e79224..f2aa58af92 100644\n--- a/negotiator/skipping.c\n+++ b/negotiator/skipping.c\n@@ -72,7 +72,8 @@ static struct entry *rev_list_push(struct data *data, struct commit *commit, int\n }\n \n static int clear_marks(const char *refname, const struct object_id *oid,\n-\t\t       int flag, void *cb_data)\n+\t\t       int UNUSED(flag),\n+\t\t       void *UNUSED(cb_data))\n {\n \tstruct object *o = deref_tag(the_repository, parse_object(the_repository, oid), refname, 0);\n \ndiff --git a/notes.c b/notes.c\nindex 7452e71cc8..3be98e7085 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -924,8 +924,9 @@ int combine_notes_cat_sort_uniq(struct object_id *cur_oid,\n \treturn ret;\n }\n \n-static int string_list_add_one_ref(const char *refname, const struct object_id *oid,\n-\t\t\t\t   int flag, void *cb)\n+static int string_list_add_one_ref(const char *refname,\n+\t\t\t\t   const struct object_id *UNUSED(oid),\n+\t\t\t\t   int UNUSED(flag), void *cb)\n {\n \tstruct string_list *refs = cb;\n \tif (!unsorted_string_list_has_string(refs, refname))\ndiff --git a/object-name.c b/object-name.c\nindex 4d2746574c..052644977e 100644\n--- a/object-name.c\n+++ b/object-name.c\n@@ -1306,7 +1306,8 @@ struct handle_one_ref_cb {\n };\n \n static int handle_one_ref(const char *path, const struct object_id *oid,\n-\t\t\t  int flag, void *cb_data)\n+\t\t\t  int UNUSED(flag),\n+\t\t\t  void *cb_data)\n {\n \tstruct handle_one_ref_cb *cb = cb_data;\n \tstruct commit_list **list = cb->list;\ndiff --git a/reflog.c b/reflog.c\nindex 135a1a6e41..ee8aaa78f5 100644\n--- a/reflog.c\n+++ b/reflog.c\n@@ -294,7 +294,8 @@ int should_expire_reflog_ent_verbose(struct object_id *ooid,\n \treturn expire;\n }\n \n-static int push_tip_to_list(const char *refname, const struct object_id *oid,\n+static int push_tip_to_list(const char *UNUSED(refname),\n+\t\t\t    const struct object_id *oid,\n \t\t\t    int flags, void *cb_data)\n {\n \tstruct commit_list **list = cb_data;\ndiff --git a/refs.c b/refs.c\nindex 90bcb27168..34373e8087 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -358,7 +358,8 @@ struct warn_if_dangling_data {\n \tconst char *msg_fmt;\n };\n \n-static int warn_if_dangling_symref(const char *refname, const struct object_id *oid,\n+static int warn_if_dangling_symref(const char *refname,\n+\t\t\t\t   const struct object_id *UNUSED(oid),\n \t\t\t\t   int flags, void *cb_data)\n {\n \tstruct warn_if_dangling_data *d = cb_data;\n@@ -934,9 +935,11 @@ static int read_ref_at_ent(struct object_id *ooid, struct object_id *noid,\n \treturn cb->found_it;\n }\n \n-static int read_ref_at_ent_newest(struct object_id *ooid, struct object_id *noid,\n-\t\t\t\t  const char *email, timestamp_t timestamp,\n-\t\t\t\t  int tz, const char *message, void *cb_data)\n+static int read_ref_at_ent_newest(struct object_id *UNUSED(ooid),\n+\t\t\t\t  struct object_id *noid,\n+\t\t\t\t  const char *UNUSED(email),\n+\t\t\t\t  timestamp_t timestamp, int tz,\n+\t\t\t\t  const char *message, void *cb_data)\n {\n \tstruct read_ref_at_cb *cb = cb_data;\n \ndiff --git a/refs/files-backend.c b/refs/files-backend.c\nindex 8db7882aac..972701ce00 100644\n--- a/refs/files-backend.c\n+++ b/refs/files-backend.c\n@@ -2995,7 +2995,9 @@ static int files_transaction_abort(struct ref_store *ref_store,\n }\n \n static int ref_present(const char *refname,\n-\t\t       const struct object_id *oid, int flags, void *cb_data)\n+\t\t       const struct object_id *UNUSED(oid),\n+\t\t       int UNUSED(flags),\n+\t\t       void *cb_data)\n {\n \tstruct string_list *affected_refnames = cb_data;\n \ndiff --git a/remote.c b/remote.c\nindex 618ad5a0f1..723aa8841c 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -2320,7 +2320,8 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb,\n }\n \n static int one_local_ref(const char *refname, const struct object_id *oid,\n-\t\t\t int flag, void *cb_data)\n+\t\t\t int UNUSED(flag),\n+\t\t\t void *cb_data)\n {\n \tstruct ref ***local_tail = cb_data;\n \tstruct ref *ref;\ndiff --git a/replace-object.c b/replace-object.c\nindex 7bd9aba6ee..17810e5a3a 100644\n--- a/replace-object.c\n+++ b/replace-object.c\n@@ -9,7 +9,8 @@\n static int register_replace_ref(struct repository *r,\n \t\t\t\tconst char *refname,\n \t\t\t\tconst struct object_id *oid,\n-\t\t\t\tint flag, void *cb_data)\n+\t\t\t\tint UNUSED(flag),\n+\t\t\t\tvoid *UNUSED(cb_data))\n {\n \t/* Get sha1 from refname */\n \tconst char *slash = strrchr(refname, '/');\ndiff --git a/revision.c b/revision.c\nindex f4eee11cc8..23c2bba0d8 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -1543,7 +1543,8 @@ int ref_excluded(struct string_list *ref_excludes, const char *path)\n }\n \n static int handle_one_ref(const char *path, const struct object_id *oid,\n-\t\t\t  int flag, void *cb_data)\n+\t\t\t  int UNUSED(flag),\n+\t\t\t  void *cb_data)\n {\n \tstruct all_refs_cb *cb = cb_data;\n \tstruct object *object;\n@@ -1627,8 +1628,8 @@ static int handle_one_reflog_ent(struct object_id *ooid, struct object_id *noid,\n }\n \n static int handle_one_reflog(const char *refname_in_wt,\n-\t\t\t     const struct object_id *oid,\n-\t\t\t     int flag, void *cb_data)\n+\t\t\t     const struct object_id *UNUSED(oid),\n+\t\t\t     int UNUSED(flag), void *cb_data)\n {\n \tstruct all_refs_cb *cb = cb_data;\n \tstruct strbuf refname = STRBUF_INIT;\ndiff --git a/server-info.c b/server-info.c\nindex 7701d7c20a..d99d9d5f61 100644\n--- a/server-info.c\n+++ b/server-info.c\n@@ -147,7 +147,8 @@ static int update_info_file(char *path,\n }\n \n static int add_info_ref(const char *path, const struct object_id *oid,\n-\t\t\tint flag, void *cb_data)\n+\t\t\tint UNUSED(flag),\n+\t\t\tvoid *cb_data)\n {\n \tstruct update_info_ctx *uic = cb_data;\n \tstruct object *o = parse_object(the_repository, oid);\ndiff --git a/shallow.c b/shallow.c\nindex 8cb768ee5f..71ab04f935 100644\n--- a/shallow.c\n+++ b/shallow.c\n@@ -604,8 +604,10 @@ static void paint_down(struct paint_info *info, const struct object_id *oid,\n \tfree(tmp);\n }\n \n-static int mark_uninteresting(const char *refname, const struct object_id *oid,\n-\t\t\t      int flags, void *cb_data)\n+static int mark_uninteresting(const char *UNUSED(refname),\n+\t\t\t      const struct object_id *oid,\n+\t\t\t      int UNUSED(flags),\n+\t\t\t      void *UNUSED(cb_data))\n {\n \tstruct commit *commit = lookup_commit_reference_gently(the_repository,\n \t\t\t\t\t\t\t       oid, 1);\n@@ -715,8 +717,10 @@ struct commit_array {\n \tint nr, alloc;\n };\n \n-static int add_ref(const char *refname, const struct object_id *oid,\n-\t\t   int flags, void *cb_data)\n+static int add_ref(const char *UNUSED(refname),\n+\t\t   const struct object_id *oid,\n+\t\t   int UNUSED(flags),\n+\t\t   void *cb_data)\n {\n \tstruct commit_array *ca = cb_data;\n \tALLOC_GROW(ca->commits, ca->nr + 1, ca->alloc);\ndiff --git a/submodule.c b/submodule.c\nindex 3fa5db3ecd..d99c978fa5 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -940,8 +940,9 @@ static void free_submodules_data(struct string_list *submodules)\n \tstring_list_clear(submodules, 1);\n }\n \n-static int has_remote(const char *refname, const struct object_id *oid,\n-\t\t      int flags, void *cb_data)\n+static int has_remote(const char *UNUSED(refname),\n+\t\t      const struct object_id *UNUSED(oid),\n+\t\t      int UNUSED(flags), void *UNUSED(cb_data))\n {\n \treturn 1;\n }\n@@ -1243,8 +1244,9 @@ int push_unpushed_submodules(struct repository *r,\n \treturn ret;\n }\n \n-static int append_oid_to_array(const char *ref, const struct object_id *oid,\n-\t\t\t       int flags, void *data)\n+static int append_oid_to_array(const char *UNUSED(ref),\n+\t\t\t       const struct object_id *oid,\n+\t\t\t       int UNUSED(flags), void *data)\n {\n \tstruct oid_array *array = data;\n \toid_array_append(array, oid);\ndiff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c\nindex 4d18bfb1ca..a98775d1a6 100644\n--- a/t/helper/test-ref-store.c\n+++ b/t/helper/test-ref-store.c\n@@ -161,7 +161,7 @@ static int cmd_rename_ref(struct ref_store *refs, const char **argv)\n }\n \n static int each_ref(const char *refname, const struct object_id *oid,\n-\t\t    int flags, void *cb_data)\n+\t\t    int flags, void *UNUSED(cb_data))\n {\n \tprintf(\"%s %s 0x%x\\n\", oid_to_hex(oid), refname, flags);\n \treturn 0;\ndiff --git a/upload-pack.c b/upload-pack.c\nindex b217a1f469..b2cbca1e8b 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -1170,7 +1170,7 @@ static int mark_our_ref(const char *refname, const char *refname_full,\n }\n \n static int check_ref(const char *refname_full, const struct object_id *oid,\n-\t\t     int flag, void *cb_data)\n+\t\t     int UNUSED(flag), void *UNUSED(cb_data))\n {\n \tconst char *refname = strip_namespace(refname_full);\n \n@@ -1194,7 +1194,7 @@ static void format_session_id(struct strbuf *buf, struct upload_pack_data *d) {\n }\n \n static int send_ref(const char *refname, const struct object_id *oid,\n-\t\t    int flag, void *cb_data)\n+\t\t    int UNUSED(flag), void *cb_data)\n {\n \tstatic const char *capabilities = \"multi_ack thin-pack side-band\"\n \t\t\" side-band-64k ofs-delta shallow deepen-since deepen-not\"\n@@ -1236,7 +1236,8 @@ static int send_ref(const char *refname, const struct object_id *oid,\n \treturn 0;\n }\n \n-static int find_symref(const char *refname, const struct object_id *oid,\n+static int find_symref(const char *refname,\n+\t\t       const struct object_id *UNUSED(oid),\n \t\t       int flag, void *cb_data)\n {\n \tconst char *symref_target;\ndiff --git a/walker.c b/walker.c\nindex c5e2921979..f945d021f8 100644\n--- a/walker.c\n+++ b/walker.c\n@@ -215,8 +215,10 @@ static int interpret_target(struct walker *walker, char *target, struct object_i\n \treturn -1;\n }\n \n-static int mark_complete(const char *path, const struct object_id *oid,\n-\t\t\t int flag, void *cb_data)\n+static int mark_complete(const char *UNUSED(path),\n+\t\t\t const struct object_id *oid,\n+\t\t\t int UNUSED(flag),\n+\t\t\t void *UNUSED(cb_data))\n {\n \tstruct commit *commit = lookup_commit_reference_gently(the_repository,\n \t\t\t\t\t\t\t       oid, 1);\n-- \n2.37.2.928.g0821088f4a\n\n"},{"id":"461529","messageId":"Yv9hIzQRuxlOUi3F@coredump.intra.peff.net","threadId":"58328","inReplyTo":"Yv9gxqH6nK2KYnNj@coredump.intra.peff.net","subject":"[PATCH 03/11] refs: mark unused reflog callback parameters","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2022-08-19T10:08:35Z","receivedAt":"2022-08-19T10:08:42Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"Functions used with for_each_reflog_ent() need to conform to a\nparticular interface, but not every function needs all of the\nparameters. Mark the unused ones to make -Wunused-parameter happy.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n builtin/fsck.c            |  5 +++--\n builtin/stash.c           |  9 ++++++---\n commit.c                  |  5 +++--\n object-name.c             |  7 +++++--\n reflog.c                  | 13 ++++++++-----\n refs.c                    | 10 ++++++----\n remote.c                  | 15 +++++++++------\n revision.c                |  7 +++++--\n t/helper/test-ref-store.c |  2 +-\n wt-status.c               | 14 +++++++++-----\n 10 files changed, 55 insertions(+), 32 deletions(-)\n\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex 36f1524614..31d3da8954 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -488,8 +488,9 @@ static void fsck_handle_reflog_oid(const char *refname, struct object_id *oid,\n }\n \n static int fsck_handle_reflog_ent(struct object_id *ooid, struct object_id *noid,\n-\t\tconst char *email, timestamp_t timestamp, int tz,\n-\t\tconst char *message, void *cb_data)\n+\t\t\t\t  const char *UNUSED(email),\n+\t\t\t\t  timestamp_t timestamp, int UNUSED(tz),\n+\t\t\t\t  const char *UNUSED(message), void *cb_data)\n {\n \tconst char *refname = cb_data;\n \ndiff --git a/builtin/stash.c b/builtin/stash.c\nindex 30fa101460..a741b920b3 100644\n--- a/builtin/stash.c\n+++ b/builtin/stash.c\n@@ -638,9 +638,12 @@ static int apply_stash(int argc, const char **argv, const char *prefix)\n \treturn ret;\n }\n \n-static int reject_reflog_ent(struct object_id *ooid, struct object_id *noid,\n-\t\t\t     const char *email, timestamp_t timestamp, int tz,\n-\t\t\t     const char *message, void *cb_data)\n+static int reject_reflog_ent(struct object_id *UNUSED(ooid),\n+\t\t\t     struct object_id *UNUSED(noid),\n+\t\t\t     const char *UNUSED(email),\n+\t\t\t     timestamp_t UNUSED(timestamp),\n+\t\t\t     int UNUSED(tz), const char *UNUSED(message),\n+\t\t\t     void *UNUSED(cb_data))\n {\n \treturn 1;\n }\ndiff --git a/commit.c b/commit.c\nindex 0db461f973..cb20082736 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -951,8 +951,9 @@ static void add_one_commit(struct object_id *oid, struct rev_collect *revs)\n }\n \n static int collect_one_reflog_ent(struct object_id *ooid, struct object_id *noid,\n-\t\t\t\t  const char *ident, timestamp_t timestamp,\n-\t\t\t\t  int tz, const char *message, void *cbdata)\n+\t\t\t\t  const char *UNUSED(ident),\n+\t\t\t\t  timestamp_t UNUSED(timestamp), int UNUSED(tz),\n+\t\t\t\t  const char *UNUSED(message), void *cbdata)\n {\n \tstruct rev_collect *revs = cbdata;\n \ndiff --git a/object-name.c b/object-name.c\nindex 052644977e..3f7fce8322 100644\n--- a/object-name.c\n+++ b/object-name.c\n@@ -1385,8 +1385,11 @@ struct grab_nth_branch_switch_cbdata {\n \tstruct strbuf *sb;\n };\n \n-static int grab_nth_branch_switch(struct object_id *ooid, struct object_id *noid,\n-\t\t\t\t  const char *email, timestamp_t timestamp, int tz,\n+static int grab_nth_branch_switch(struct object_id *UNUSED(ooid),\n+\t\t\t\t  struct object_id *UNUSED(noid),\n+\t\t\t\t  const char *UNUSED(email),\n+\t\t\t\t  timestamp_t UNUSED(timestamp),\n+\t\t\t\t  int UNUSED(tz),\n \t\t\t\t  const char *message, void *cb_data)\n {\n \tstruct grab_nth_branch_switch_cbdata *cb = cb_data;\ndiff --git a/reflog.c b/reflog.c\nindex ee8aaa78f5..56ea3ba762 100644\n--- a/reflog.c\n+++ b/reflog.c\n@@ -240,8 +240,9 @@ static int unreachable(struct expire_reflog_policy_cb *cb, struct commit *commit\n  * Return true iff the specified reflog entry should be expired.\n  */\n int should_expire_reflog_ent(struct object_id *ooid, struct object_id *noid,\n-\t\t\t     const char *email, timestamp_t timestamp, int tz,\n-\t\t\t     const char *message, void *cb_data)\n+\t\t\t     const char *UNUSED(email),\n+\t\t\t     timestamp_t timestamp, int UNUSED(tz),\n+\t\t\t     const char *UNUSED(message), void *cb_data)\n {\n \tstruct expire_reflog_policy_cb *cb = cb_data;\n \tstruct commit *old_commit, *new_commit;\n@@ -379,9 +380,11 @@ void reflog_expiry_cleanup(void *cb_data)\n \t}\n }\n \n-int count_reflog_ent(struct object_id *ooid, struct object_id *noid,\n-\t\t     const char *email, timestamp_t timestamp, int tz,\n-\t\t     const char *message, void *cb_data)\n+int count_reflog_ent(struct object_id *UNUSED(ooid),\n+\t\t     struct object_id *UNUSED(noid),\n+\t\t     const char *UNUSED(email),\n+\t\t     timestamp_t timestamp, int UNUSED(tz),\n+\t\t     const char *UNUSED(message), void *cb_data)\n {\n \tstruct cmd_reflog_expire_cb *cb = cb_data;\n \tif (!cb->expire_total || timestamp < cb->expire_total)\ndiff --git a/refs.c b/refs.c\nindex 34373e8087..38b1165189 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -894,8 +894,9 @@ static void set_read_ref_cutoffs(struct read_ref_at_cb *cb,\n }\n \n static int read_ref_at_ent(struct object_id *ooid, struct object_id *noid,\n-\t\tconst char *email, timestamp_t timestamp, int tz,\n-\t\tconst char *message, void *cb_data)\n+\t\t\t   const char *UNUSED(email),\n+\t\t\t   timestamp_t timestamp, int tz,\n+\t\t\t   const char *message, void *cb_data)\n {\n \tstruct read_ref_at_cb *cb = cb_data;\n \tint reached_count;\n@@ -950,8 +951,9 @@ static int read_ref_at_ent_newest(struct object_id *UNUSED(ooid),\n }\n \n static int read_ref_at_ent_oldest(struct object_id *ooid, struct object_id *noid,\n-\t\t\t\t  const char *email, timestamp_t timestamp,\n-\t\t\t\t  int tz, const char *message, void *cb_data)\n+\t\t\t\t  const char *UNUSED(email),\n+\t\t\t\t  timestamp_t timestamp, int tz,\n+\t\t\t\t  const char *message, void *cb_data)\n {\n \tstruct read_ref_at_cb *cb = cb_data;\n \ndiff --git a/remote.c b/remote.c\nindex 723aa8841c..029fc630b9 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -2577,19 +2577,22 @@ struct check_and_collect_until_cb_data {\n };\n \n /* Get the timestamp of the latest entry. */\n-static int peek_reflog(struct object_id *o_oid, struct object_id *n_oid,\n-\t\t       const char *ident, timestamp_t timestamp,\n-\t\t       int tz, const char *message, void *cb_data)\n+static int peek_reflog(struct object_id *UNUSED(o_oid),\n+\t\t       struct object_id *UNUSED(n_oid),\n+\t\t       const char *UNUSED(ident),\n+\t\t       timestamp_t timestamp, int UNUSED(tz),\n+\t\t       const char *UNUSED(message), void *cb_data)\n {\n \ttimestamp_t *ts = cb_data;\n \t*ts = timestamp;\n \treturn 1;\n }\n \n-static int check_and_collect_until(struct object_id *o_oid,\n+static int check_and_collect_until(struct object_id *UNUSED(o_oid),\n \t\t\t\t   struct object_id *n_oid,\n-\t\t\t\t   const char *ident, timestamp_t timestamp,\n-\t\t\t\t   int tz, const char *message, void *cb_data)\n+\t\t\t\t   const char *UNUSED(ident),\n+\t\t\t\t   timestamp_t timestamp, int UNUSED(tz),\n+\t\t\t\t   const char *UNUSED(message), void *cb_data)\n {\n \tstruct commit *commit;\n \tstruct check_and_collect_until_cb_data *cb = cb_data;\ndiff --git a/revision.c b/revision.c\nindex 23c2bba0d8..6c7250d6a8 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -1619,8 +1619,11 @@ static void handle_one_reflog_commit(struct object_id *oid, void *cb_data)\n }\n \n static int handle_one_reflog_ent(struct object_id *ooid, struct object_id *noid,\n-\t\tconst char *email, timestamp_t timestamp, int tz,\n-\t\tconst char *message, void *cb_data)\n+\t\t\t\t const char *UNUSED(email),\n+\t\t\t\t timestamp_t UNUSED(timestamp),\n+\t\t\t\t int UNUSED(tz),\n+\t\t\t\t const char *UNUSED(message),\n+\t\t\t\t void *cb_data)\n {\n \thandle_one_reflog_commit(ooid, cb_data);\n \thandle_one_reflog_commit(noid, cb_data);\ndiff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c\nindex a98775d1a6..8f930ad358 100644\n--- a/t/helper/test-ref-store.c\n+++ b/t/helper/test-ref-store.c\n@@ -207,7 +207,7 @@ static int cmd_for_each_reflog(struct ref_store *refs, const char **argv)\n \n static int each_reflog(struct object_id *old_oid, struct object_id *new_oid,\n \t\t       const char *committer, timestamp_t timestamp,\n-\t\t       int tz, const char *msg, void *cb_data)\n+\t\t       int tz, const char *msg, void *UNUSED(cb_data))\n {\n \tprintf(\"%s %s %s %\" PRItime \" %+05d%s%s\", oid_to_hex(old_oid),\n \t       oid_to_hex(new_oid), committer, timestamp, tz,\ndiff --git a/wt-status.c b/wt-status.c\nindex 867e3e417e..38d0900aa9 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -947,9 +947,11 @@ static void wt_longstatus_print_changed(struct wt_status *s)\n \twt_longstatus_print_trailer(s);\n }\n \n-static int stash_count_refs(struct object_id *ooid, struct object_id *noid,\n-\t\t\t    const char *email, timestamp_t timestamp, int tz,\n-\t\t\t    const char *message, void *cb_data)\n+static int stash_count_refs(struct object_id *UNUSED(ooid),\n+\t\t\t    struct object_id *UNUSED(noid),\n+\t\t\t    const char *UNUSED(email),\n+\t\t\t    timestamp_t UNUSED(timestamp), int UNUSED(tz),\n+\t\t\t    const char *UNUSED(message), void *cb_data)\n {\n \tint *c = cb_data;\n \t(*c)++;\n@@ -1612,8 +1614,10 @@ struct grab_1st_switch_cbdata {\n \tstruct object_id noid;\n };\n \n-static int grab_1st_switch(struct object_id *ooid, struct object_id *noid,\n-\t\t\t   const char *email, timestamp_t timestamp, int tz,\n+static int grab_1st_switch(struct object_id *UNUSED(ooid),\n+\t\t\t   struct object_id *noid,\n+\t\t\t   const char *UNUSED(email),\n+\t\t\t   timestamp_t UNUSED(timestamp), int UNUSED(tz),\n \t\t\t   const char *message, void *cb_data)\n {\n \tstruct grab_1st_switch_cbdata *cb = cb_data;\n-- \n2.37.2.928.g0821088f4a\n\n"},{"id":"461530","messageId":"Yv9hJXCU+M/lATSv@coredump.intra.peff.net","threadId":"58328","inReplyTo":"Yv9gxqH6nK2KYnNj@coredump.intra.peff.net","subject":"[PATCH 04/11] refs: mark unused virtual method parameters","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2022-08-19T10:08:37Z","receivedAt":"2022-08-19T10:08:46Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"The refs code uses various polymorphic types (e.g., loose vs packed\nref_stores, abstracted iterators). Not every virtual function or\ncallback needs all of its parameters. Let's mark the unused ones to\nquiet -Wunused-parameter.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n refs/files-backend.c  | 10 +++++-----\n refs/iterator.c       |  6 +++---\n refs/packed-backend.c | 14 ++++++++------\n 3 files changed, 16 insertions(+), 14 deletions(-)\n\ndiff --git a/refs/files-backend.c b/refs/files-backend.c\nindex 972701ce00..13bfdb7701 100644\n--- a/refs/files-backend.c\n+++ b/refs/files-backend.c\n@@ -2202,8 +2202,8 @@ static int files_reflog_iterator_advance(struct ref_iterator *ref_iterator)\n \treturn ok;\n }\n \n-static int files_reflog_iterator_peel(struct ref_iterator *ref_iterator,\n-\t\t\t\t      struct object_id *peeled)\n+static int files_reflog_iterator_peel(struct ref_iterator *UNUSED(ref_iterator),\n+\t\t\t\t      struct object_id *UNUSED(peeled))\n {\n \tBUG(\"ref_iterator_peel() called for reflog_iterator\");\n }\n@@ -2257,7 +2257,7 @@ static struct ref_iterator *reflog_iterator_begin(struct ref_store *ref_store,\n static enum iterator_selection reflog_iterator_select(\n \tstruct ref_iterator *iter_worktree,\n \tstruct ref_iterator *iter_common,\n-\tvoid *cb_data)\n+\tvoid *UNUSED(cb_data))\n {\n \tif (iter_worktree) {\n \t\t/*\n@@ -2985,7 +2985,7 @@ static int files_transaction_finish(struct ref_store *ref_store,\n \n static int files_transaction_abort(struct ref_store *ref_store,\n \t\t\t\t   struct ref_transaction *transaction,\n-\t\t\t\t   struct strbuf *err)\n+\t\t\t\t   struct strbuf *UNUSED(err))\n {\n \tstruct files_ref_store *refs =\n \t\tfiles_downcast(ref_store, 0, \"ref_transaction_abort\");\n@@ -3261,7 +3261,7 @@ static int files_reflog_expire(struct ref_store *ref_store,\n \treturn -1;\n }\n \n-static int files_init_db(struct ref_store *ref_store, struct strbuf *err)\n+static int files_init_db(struct ref_store *ref_store, struct strbuf *UNUSED(err))\n {\n \tstruct files_ref_store *refs =\n \t\tfiles_downcast(ref_store, REF_STORE_WRITE, \"init_db\");\ndiff --git a/refs/iterator.c b/refs/iterator.c\nindex b2e56bae1c..e34921db72 100644\n--- a/refs/iterator.c\n+++ b/refs/iterator.c\n@@ -51,8 +51,8 @@ static int empty_ref_iterator_advance(struct ref_iterator *ref_iterator)\n \treturn ref_iterator_abort(ref_iterator);\n }\n \n-static int empty_ref_iterator_peel(struct ref_iterator *ref_iterator,\n-\t\t\t\t   struct object_id *peeled)\n+static int empty_ref_iterator_peel(struct ref_iterator *UNUSED(ref_iterator),\n+\t\t\t\t   struct object_id *UNUSED(peeled))\n {\n \tBUG(\"peel called for empty iterator\");\n }\n@@ -238,7 +238,7 @@ struct ref_iterator *merge_ref_iterator_begin(\n  */\n static enum iterator_selection overlay_iterator_select(\n \t\tstruct ref_iterator *front, struct ref_iterator *back,\n-\t\tvoid *cb_data)\n+\t\tvoid *UNUSED(cb_data))\n {\n \tint cmp;\n \ndiff --git a/refs/packed-backend.c b/refs/packed-backend.c\nindex 97b6837767..a45bb686f0 100644\n--- a/refs/packed-backend.c\n+++ b/refs/packed-backend.c\n@@ -726,7 +726,7 @@ static struct snapshot *get_snapshot(struct packed_ref_store *refs)\n }\n \n static int packed_read_raw_ref(struct ref_store *ref_store, const char *refname,\n-\t\t\t       struct object_id *oid, struct strbuf *referent,\n+\t\t\t       struct object_id *oid, struct strbuf *UNUSED(referent),\n \t\t\t       unsigned int *type, int *failure_errno)\n {\n \tstruct packed_ref_store *refs =\n@@ -1078,7 +1078,8 @@ int packed_refs_is_locked(struct ref_store *ref_store)\n static const char PACKED_REFS_HEADER[] =\n \t\"# pack-refs with: peeled fully-peeled sorted \\n\";\n \n-static int packed_init_db(struct ref_store *ref_store, struct strbuf *err)\n+static int packed_init_db(struct ref_store *UNUSED(ref_store),\n+\t\t\t  struct strbuf *UNUSED(err))\n {\n \t/* Nothing to do. */\n \treturn 0;\n@@ -1473,7 +1474,7 @@ static int packed_transaction_prepare(struct ref_store *ref_store,\n \n static int packed_transaction_abort(struct ref_store *ref_store,\n \t\t\t\t    struct ref_transaction *transaction,\n-\t\t\t\t    struct strbuf *err)\n+\t\t\t\t    struct strbuf *UNUSED(err))\n {\n \tstruct packed_ref_store *refs = packed_downcast(\n \t\t\tref_store,\n@@ -1512,7 +1513,7 @@ static int packed_transaction_finish(struct ref_store *ref_store,\n \treturn ret;\n }\n \n-static int packed_initial_transaction_commit(struct ref_store *ref_store,\n+static int packed_initial_transaction_commit(struct ref_store *UNUSED(ref_store),\n \t\t\t\t\t    struct ref_transaction *transaction,\n \t\t\t\t\t    struct strbuf *err)\n {\n@@ -1568,7 +1569,8 @@ static int packed_delete_refs(struct ref_store *ref_store, const char *msg,\n \treturn ret;\n }\n \n-static int packed_pack_refs(struct ref_store *ref_store, unsigned int flags)\n+static int packed_pack_refs(struct ref_store *UNUSED(ref_store),\n+\t\t\t    unsigned int UNUSED(flags))\n {\n \t/*\n \t * Packed refs are already packed. It might be that loose refs\n@@ -1578,7 +1580,7 @@ static int packed_pack_refs(struct ref_store *ref_store, unsigned int flags)\n \treturn 0;\n }\n \n-static struct ref_iterator *packed_reflog_iterator_begin(struct ref_store *ref_store)\n+static struct ref_iterator *packed_reflog_iterator_begin(struct ref_store *UNUSED(ref_store))\n {\n \treturn empty_ref_iterator_begin();\n }\n-- \n2.37.2.928.g0821088f4a\n\n"},{"id":"461531","messageId":"Yv9hJ0vAKqwR1BE0@coredump.intra.peff.net","threadId":"58328","inReplyTo":"Yv9gxqH6nK2KYnNj@coredump.intra.peff.net","subject":"[PATCH 05/11] transport: mark bundle transport_options as unused","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2022-08-19T10:08:39Z","receivedAt":"2022-08-19T10:08:49Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"get_refs_from_bundle() is a virtual function which must match the\nsignature of other transports, but it doesn't look at its\ntransport_options at all. This isn't a bug, because not all transports\nnecessarily support all options. Let's mark it as unused to appease\n-Wunused-parameter.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n transport.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/transport.c b/transport.c\nindex b51e991e44..551cad22dd 100644\n--- a/transport.c\n+++ b/transport.c\n@@ -142,7 +142,7 @@ static void get_refs_from_bundle_inner(struct transport *transport)\n \n static struct ref *get_refs_from_bundle(struct transport *transport,\n \t\t\t\t\tint for_push,\n-\t\t\t\t\tstruct transport_ls_refs_options *transport_options)\n+\t\t\t\t\tstruct transport_ls_refs_options *UNUSED(transport_options))\n {\n \tstruct bundle_transport_data *data = transport->data;\n \tstruct ref *result = NULL;\n-- \n2.37.2.928.g0821088f4a\n\n"},{"id":"461532","messageId":"Yv9hKkGZxeqE1Ep3@coredump.intra.peff.net","threadId":"58328","inReplyTo":"Yv9gxqH6nK2KYnNj@coredump.intra.peff.net","subject":"[PATCH 06/11] streaming: mark unused virtual method parameters","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2022-08-19T10:08:42Z","receivedAt":"2022-08-19T10:09:01Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"Streaming \"open\" functions need to conform to the same virtual function\ninterface, but not every implementation needs every parameter. Mark the\nunused ones as such to appease -Wunused-parameter.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n streaming.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/streaming.c b/streaming.c\nindex fe54665d86..4b34e2a748 100644\n--- a/streaming.c\n+++ b/streaming.c\n@@ -328,9 +328,9 @@ static int close_istream_pack_non_delta(struct git_istream *st)\n }\n \n static int open_istream_pack_non_delta(struct git_istream *st,\n-\t\t\t\t       struct repository *r,\n-\t\t\t\t       const struct object_id *oid,\n-\t\t\t\t       enum object_type *type)\n+\t\t\t\t       struct repository *UNUSED(r),\n+\t\t\t\t       const struct object_id *UNUSED(oid),\n+\t\t\t\t       enum object_type *UNUSED(type))\n {\n \tstruct pack_window *window;\n \tenum object_type in_pack_type;\n-- \n2.37.2.928.g0821088f4a\n\n"},{"id":"461533","messageId":"Yv9hLNIv3Y7aNqTb@coredump.intra.peff.net","threadId":"58328","inReplyTo":"Yv9gxqH6nK2KYnNj@coredump.intra.peff.net","subject":"[PATCH 07/11] config: mark unused callback parameters","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2022-08-19T10:08:44Z","receivedAt":"2022-08-19T10:09:03Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"The callback passed to git_config() must conform to a particular\ninterface. But most callbacks don't actually look at the extra \"void\n*data\" parameter. Let's mark the unused parameters to make\n-Wunused-parameter happy.\n\nNote there's one unusual case here in get_remote_default() where we\nactually ignore the \"value\" parameter. That's because it's only checking\nwhether the option is found at all, and not parsing its value.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n archive-tar.c              | 3 ++-\n archive-zip.c              | 3 ++-\n builtin/am.c               | 2 +-\n builtin/commit-graph.c     | 2 +-\n builtin/config.c           | 8 +++++---\n builtin/multi-pack-index.c | 2 +-\n builtin/remote.c           | 2 +-\n color.c                    | 2 +-\n config.c                   | 3 ++-\n convert.c                  | 2 +-\n delta-islands.c            | 2 +-\n diff.c                     | 3 ++-\n git-compat-util.h          | 4 +++-\n gpg-interface.c            | 2 +-\n ident.c                    | 2 +-\n ll-merge.c                 | 3 ++-\n ls-refs.c                  | 3 ++-\n pager.c                    | 3 ++-\n pretty.c                   | 3 ++-\n submodule.c                | 3 ++-\n t/helper/test-config.c     | 2 +-\n t/helper/test-userdiff.c   | 2 +-\n trailer.c                  | 6 ++++--\n 23 files changed, 41 insertions(+), 26 deletions(-)\n\ndiff --git a/archive-tar.c b/archive-tar.c\nindex 3d77e0f750..45e5d91407 100644\n--- a/archive-tar.c\n+++ b/archive-tar.c\n@@ -366,7 +366,8 @@ static struct archiver *find_tar_filter(const char *name, size_t len)\n \treturn NULL;\n }\n \n-static int tar_filter_config(const char *var, const char *value, void *data)\n+static int tar_filter_config(const char *var, const char *value,\n+\t\t\t     void *UNUSED(data))\n {\n \tstruct archiver *ar;\n \tconst char *name;\ndiff --git a/archive-zip.c b/archive-zip.c\nindex 9fe43d740d..854bceb018 100644\n--- a/archive-zip.c\n+++ b/archive-zip.c\n@@ -612,7 +612,8 @@ static void dos_time(timestamp_t *timestamp, int *dos_date, int *dos_time)\n \t*dos_time = tm.tm_sec / 2 + tm.tm_min * 32 + tm.tm_hour * 2048;\n }\n \n-static int archive_zip_config(const char *var, const char *value, void *data)\n+static int archive_zip_config(const char *var, const char *value,\n+\t\t\t      void *UNUSED(data))\n {\n \treturn userdiff_config(var, value);\n }\ndiff --git a/builtin/am.c b/builtin/am.c\nindex 93bec62afa..0811b9ff67 100644\n--- a/builtin/am.c\n+++ b/builtin/am.c\n@@ -2301,7 +2301,7 @@ static int parse_opt_show_current_patch(const struct option *opt, const char *ar\n \treturn 0;\n }\n \n-static int git_am_config(const char *k, const char *v, void *cb)\n+static int git_am_config(const char *k, const char *v, void *UNUSED(cb))\n {\n \tint status;\n \ndiff --git a/builtin/commit-graph.c b/builtin/commit-graph.c\nindex 51c4040ea6..ea923ea33a 100644\n--- a/builtin/commit-graph.c\n+++ b/builtin/commit-graph.c\n@@ -179,7 +179,7 @@ static int write_option_max_new_filters(const struct option *opt,\n }\n \n static int git_commit_graph_write_config(const char *var, const char *value,\n-\t\t\t\t\t void *cb)\n+\t\t\t\t\t void *UNUSED(cb))\n {\n \tif (!strcmp(var, \"commitgraph.maxnewfilters\"))\n \t\twrite_opts.max_new_filters = git_config_int(var, value);\ndiff --git a/builtin/config.c b/builtin/config.c\nindex e7b88a9c08..bdc8b1d1a8 100644\n--- a/builtin/config.c\n+++ b/builtin/config.c\n@@ -207,7 +207,8 @@ static void show_config_scope(struct strbuf *buf)\n \tstrbuf_addch(buf, term);\n }\n \n-static int show_all_config(const char *key_, const char *value_, void *cb)\n+static int show_all_config(const char *key_, const char *value_,\n+\t\t\t   void *UNUSED(cb))\n {\n \tif (show_origin || show_scope) {\n \t\tstruct strbuf buf = STRBUF_INIT;\n@@ -458,7 +459,8 @@ static const char *get_color_slot;\n static const char *get_colorbool_slot;\n static char parsed_color[COLOR_MAXLEN];\n \n-static int git_get_color_config(const char *var, const char *value, void *cb)\n+static int git_get_color_config(const char *var, const char *value,\n+\t\t\t\tvoid *UNUSED(cb))\n {\n \tif (!strcmp(var, get_color_slot)) {\n \t\tif (!value)\n@@ -490,7 +492,7 @@ static int get_colorbool_found;\n static int get_diff_color_found;\n static int get_color_ui_found;\n static int git_get_colorbool_config(const char *var, const char *value,\n-\t\tvoid *cb)\n+\t\t\t\t    void *UNUSED(data))\n {\n \tif (!strcmp(var, get_colorbool_slot))\n \t\tget_colorbool_found = git_config_colorbool(var, value);\ndiff --git a/builtin/multi-pack-index.c b/builtin/multi-pack-index.c\nindex 8f24d59a75..8d156766af 100644\n--- a/builtin/multi-pack-index.c\n+++ b/builtin/multi-pack-index.c\n@@ -78,7 +78,7 @@ static struct option *add_common_options(struct option *prev)\n }\n \n static int git_multi_pack_index_write_config(const char *var, const char *value,\n-\t\t\t\t\t     void *cb)\n+\t\t\t\t\t     void *UNUSED(cb))\n {\n \tif (!strcmp(var, \"pack.writebitmaphashcache\")) {\n \t\tif (git_config_bool(var, value))\ndiff --git a/builtin/remote.c b/builtin/remote.c\nindex b390360f07..87dda7c37b 100644\n--- a/builtin/remote.c\n+++ b/builtin/remote.c\n@@ -1486,7 +1486,7 @@ static int prune(int argc, const char **argv)\n \treturn result;\n }\n \n-static int get_remote_default(const char *key, const char *value, void *priv)\n+static int get_remote_default(const char *key, const char *UNUSED(value), void *priv)\n {\n \tif (strcmp(key, \"remotes.default\") == 0) {\n \t\tint *found = priv;\ndiff --git a/color.c b/color.c\nindex 4f884c6b3d..04ad0a8bf7 100644\n--- a/color.c\n+++ b/color.c\n@@ -415,7 +415,7 @@ int want_color_fd(int fd, int var)\n \treturn var;\n }\n \n-int git_color_config(const char *var, const char *value, void *cb)\n+int git_color_config(const char *var, const char *value, void *UNUSED(cb))\n {\n \tif (!strcmp(var, \"color.ui\")) {\n \t\tgit_use_color_default = git_config_colorbool(var, value);\ndiff --git a/config.c b/config.c\nindex e8ebef77d5..589dec9028 100644\n--- a/config.c\n+++ b/config.c\n@@ -362,7 +362,8 @@ static void populate_remote_urls(struct config_include_data *inc)\n \tcurrent_parsing_scope = store_scope;\n }\n \n-static int forbid_remote_url(const char *var, const char *value, void *data)\n+static int forbid_remote_url(const char *var, const char *UNUSED(value),\n+\t\t\t     void *UNUSED(data))\n {\n \tconst char *remote_name;\n \tsize_t remote_name_len;\ndiff --git a/convert.c b/convert.c\nindex 4d153729da..b31a25b536 100644\n--- a/convert.c\n+++ b/convert.c\n@@ -1008,7 +1008,7 @@ static int apply_filter(const char *path, const char *src, size_t len,\n \treturn 0;\n }\n \n-static int read_convert_config(const char *var, const char *value, void *cb)\n+static int read_convert_config(const char *var, const char *value, void *UNUSED(cb))\n {\n \tconst char *key, *name;\n \tsize_t namelen;\ndiff --git a/delta-islands.c b/delta-islands.c\nindex 13eb96e0c4..c64333f9de 100644\n--- a/delta-islands.c\n+++ b/delta-islands.c\n@@ -316,7 +316,7 @@ static regex_t *island_regexes;\n static unsigned int island_regexes_alloc, island_regexes_nr;\n static const char *core_island_name;\n \n-static int island_config_callback(const char *k, const char *v, void *cb)\n+static int island_config_callback(const char *k, const char *v, void *UNUSED(cb))\n {\n \tif (!strcmp(k, \"pack.island\")) {\n \t\tstruct strbuf re = STRBUF_INIT;\ndiff --git a/diff.c b/diff.c\nindex 974626a621..8a9c9083f3 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -264,7 +264,8 @@ void init_diff_ui_defaults(void)\n \tdiff_detect_rename_default = DIFF_DETECT_RENAME;\n }\n \n-int git_diff_heuristic_config(const char *var, const char *value, void *cb)\n+int git_diff_heuristic_config(const char *var, const char *value,\n+\t\t\t      void *UNUSED(cb))\n {\n \tif (!strcmp(var, \"diff.indentheuristic\"))\n \t\tdiff_indent_heuristic = git_config_bool(var, value);\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex c6669db07d..12239fedf7 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -403,7 +403,9 @@ typedef uintmax_t timestamp_t;\n #endif\n \n #ifndef platform_core_config\n-static inline int noop_core_config(const char *var, const char *value, void *cb)\n+static inline int noop_core_config(const char *UNUSED(var),\n+\t\t\t\t   const char *UNUSED(value),\n+\t\t\t\t   void *UNUSED(cb))\n {\n \treturn 0;\n }\ndiff --git a/gpg-interface.c b/gpg-interface.c\nindex 6dff241460..721d69bf42 100644\n--- a/gpg-interface.c\n+++ b/gpg-interface.c\n@@ -699,7 +699,7 @@ void set_signing_key(const char *key)\n \tconfigured_signing_key = xstrdup(key);\n }\n \n-int git_gpg_config(const char *var, const char *value, void *cb)\n+int git_gpg_config(const char *var, const char *value, void *UNUSED(cb))\n {\n \tstruct gpg_format *fmt = NULL;\n \tchar *fmtname = NULL;\ndiff --git a/ident.c b/ident.c\nindex 7f66beda42..48745a1f0e 100644\n--- a/ident.c\n+++ b/ident.c\n@@ -668,7 +668,7 @@ static int set_ident(const char *var, const char *value)\n \treturn 0;\n }\n \n-int git_ident_config(const char *var, const char *value, void *data)\n+int git_ident_config(const char *var, const char *value, void *UNUSED(data))\n {\n \tif (!strcmp(var, \"user.useconfigonly\")) {\n \t\tident_use_config_only = git_config_bool(var, value);\ndiff --git a/ll-merge.c b/ll-merge.c\nindex 14b8362019..9f3ae1f8fe 100644\n--- a/ll-merge.c\n+++ b/ll-merge.c\n@@ -249,7 +249,8 @@ static enum ll_merge_result ll_ext_merge(const struct ll_merge_driver *fn,\n static struct ll_merge_driver *ll_user_merge, **ll_user_merge_tail;\n static const char *default_ll_merge;\n \n-static int read_merge_config(const char *var, const char *value, void *cb)\n+static int read_merge_config(const char *var, const char *value,\n+\t\t\t     void *UNUSED(cb))\n {\n \tstruct ll_merge_driver *fn;\n \tconst char *key, *name;\ndiff --git a/ls-refs.c b/ls-refs.c\nindex 98e69373c8..e54b883e87 100644\n--- a/ls-refs.c\n+++ b/ls-refs.c\n@@ -136,7 +136,8 @@ static void send_possibly_unborn_head(struct ls_refs_data *data)\n \tstrbuf_release(&namespaced);\n }\n \n-static int ls_refs_config(const char *var, const char *value, void *data)\n+static int ls_refs_config(const char *var, const char *value,\n+\t\t\t  void *UNUSED(data))\n {\n \t/*\n \t * We only serve fetches over v2 for now, so respect only \"uploadpack\"\ndiff --git a/pager.c b/pager.c\nindex 5cfe23b025..19c016ff54 100644\n--- a/pager.c\n+++ b/pager.c\n@@ -38,7 +38,8 @@ static void wait_for_pager_signal(int signo)\n \traise(signo);\n }\n \n-static int core_pager_config(const char *var, const char *value, void *data)\n+static int core_pager_config(const char *var, const char *value,\n+\t\t\t     void *UNUSED(data))\n {\n \tif (!strcmp(var, \"core.pager\"))\n \t\treturn git_config_string(&pager_program, var, value);\ndiff --git a/pretty.c b/pretty.c\nindex 6d819103fb..584026b746 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -43,7 +43,8 @@ static void save_user_format(struct rev_info *rev, const char *cp, int is_tforma\n \trev->commit_format = CMIT_FMT_USERFORMAT;\n }\n \n-static int git_pretty_formats_config(const char *var, const char *value, void *cb)\n+static int git_pretty_formats_config(const char *var, const char *value,\n+\t\t\t\t     void *UNUSED(cb))\n {\n \tstruct cmt_fmt_map *commit_format = NULL;\n \tconst char *name;\ndiff --git a/submodule.c b/submodule.c\nindex d99c978fa5..597a347f85 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -213,7 +213,8 @@ void set_diffopt_flags_from_submodule_config(struct diff_options *diffopt,\n }\n \n /* Cheap function that only determines if we're interested in submodules at all */\n-int git_default_submodule_config(const char *var, const char *value, void *cb)\n+int git_default_submodule_config(const char *var, const char *value,\n+\t\t\t\t void *UNUSED(cb))\n {\n \tif (!strcmp(var, \"submodule.recurse\")) {\n \t\tint v = git_config_bool(var, value) ?\ndiff --git a/t/helper/test-config.c b/t/helper/test-config.c\nindex a6e936721f..ddd538b838 100644\n--- a/t/helper/test-config.c\n+++ b/t/helper/test-config.c\n@@ -37,7 +37,7 @@\n  *\n  */\n \n-static int iterate_cb(const char *var, const char *value, void *data)\n+static int iterate_cb(const char *var, const char *value, void *UNUSED(data))\n {\n \tstatic int nr;\n \ndiff --git a/t/helper/test-userdiff.c b/t/helper/test-userdiff.c\nindex f013f8a31e..64538a0c20 100644\n--- a/t/helper/test-userdiff.c\n+++ b/t/helper/test-userdiff.c\n@@ -12,7 +12,7 @@ static int driver_cb(struct userdiff_driver *driver,\n \treturn 0;\n }\n \n-static int cmd__userdiff_config(const char *var, const char *value, void *cb)\n+static int cmd__userdiff_config(const char *var, const char *value, void *UNUSED(cb))\n {\n \tif (userdiff_config(var, value) < 0)\n \t\treturn -1;\ndiff --git a/trailer.c b/trailer.c\nindex d419c20735..a1e80478ab 100644\n--- a/trailer.c\n+++ b/trailer.c\n@@ -478,7 +478,8 @@ static struct {\n \t{ \"ifmissing\", TRAILER_IF_MISSING }\n };\n \n-static int git_trailer_default_config(const char *conf_key, const char *value, void *cb)\n+static int git_trailer_default_config(const char *conf_key, const char *value,\n+\t\t\t\t      void *UNUSED(cb))\n {\n \tconst char *trailer_item, *variable_name;\n \n@@ -509,7 +510,8 @@ static int git_trailer_default_config(const char *conf_key, const char *value, v\n \treturn 0;\n }\n \n-static int git_trailer_config(const char *conf_key, const char *value, void *cb)\n+static int git_trailer_config(const char *conf_key, const char *value,\n+\t\t\t      void *UNUSED(cb))\n {\n \tconst char *trailer_item, *variable_name;\n \tstruct arg_item *item;\n-- \n2.37.2.928.g0821088f4a\n\n"},{"id":"461534","messageId":"Yv9hLg3lGQIMZMG1@coredump.intra.peff.net","threadId":"58328","inReplyTo":"Yv9gxqH6nK2KYnNj@coredump.intra.peff.net","subject":"[PATCH 08/11] hashmap: mark unused callback parameters","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2022-08-19T10:08:46Z","receivedAt":"2022-08-19T10:09:12Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"Hashmap comparison functions must conform to a particular callback\ninterface, but many don't use all of their parameters. Especially the\nvoid cmp_data pointer, but some do not use keydata either (because they\ncan easily form a full struct to pass when doing lookups). Let's mark\nthese to make -Wunused-parameter happy.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n add-interactive.c     |  2 +-\n attr.c                |  4 ++--\n bloom.c               |  4 ++--\n builtin/describe.c    |  2 +-\n builtin/difftool.c    | 10 +++++-----\n builtin/fast-export.c |  2 +-\n builtin/fast-import.c |  2 +-\n builtin/fetch.c       |  2 +-\n compat/terminal.c     |  2 +-\n config.c              |  4 ++--\n diff.c                |  2 +-\n dir.c                 |  4 ++--\n environment.c         |  4 ++--\n hashmap.c             | 10 +++++-----\n merge-recursive.c     | 10 +++++-----\n name-hash.c           |  4 ++--\n object-store.h        |  2 +-\n oidmap.c              |  2 +-\n packfile.c            |  2 +-\n patch-ids.c           |  2 +-\n range-diff.c          |  6 ++++--\n ref-filter.c          |  2 +-\n refs.c                |  2 +-\n remote.c              |  4 ++--\n revision.c            |  4 ++--\n sequencer.c           |  5 +++--\n strmap.c              |  4 ++--\n sub-process.c         |  4 ++--\n submodule-config.c    |  8 ++++----\n 29 files changed, 59 insertions(+), 56 deletions(-)\n\ndiff --git a/add-interactive.c b/add-interactive.c\nindex 22fcd3412c..2fcad67654 100644\n--- a/add-interactive.c\n+++ b/add-interactive.c\n@@ -430,7 +430,7 @@ struct pathname_entry {\n \tstruct file_item *item;\n };\n \n-static int pathname_entry_cmp(const void *unused_cmp_data,\n+static int pathname_entry_cmp(const void *UNUSED(cmp_data),\n \t\t\t      const struct hashmap_entry *he1,\n \t\t\t      const struct hashmap_entry *he2,\n \t\t\t      const void *name)\ndiff --git a/attr.c b/attr.c\nindex 8a78dde69e..63e1a756dd 100644\n--- a/attr.c\n+++ b/attr.c\n@@ -61,10 +61,10 @@ struct attr_hash_entry {\n };\n \n /* attr_hashmap comparison function */\n-static int attr_hash_entry_cmp(const void *unused_cmp_data,\n+static int attr_hash_entry_cmp(const void *UNUSED(cmp_data),\n \t\t\t       const struct hashmap_entry *eptr,\n \t\t\t       const struct hashmap_entry *entry_or_key,\n-\t\t\t       const void *unused_keydata)\n+\t\t\t       const void *UNUSED(keydata))\n {\n \tconst struct attr_hash_entry *a, *b;\n \ndiff --git a/bloom.c b/bloom.c\nindex 816f063dca..94fb97e60e 100644\n--- a/bloom.c\n+++ b/bloom.c\n@@ -163,10 +163,10 @@ void init_bloom_filters(void)\n \tinit_bloom_filter_slab(&bloom_filters);\n }\n \n-static int pathmap_cmp(const void *hashmap_cmp_fn_data,\n+static int pathmap_cmp(const void *UNUSED(hashmap_cmp_fn_data),\n \t\t       const struct hashmap_entry *eptr,\n \t\t       const struct hashmap_entry *entry_or_key,\n-\t\t       const void *keydata)\n+\t\t       const void *UNUSED(keydata))\n {\n \tconst struct pathmap_hash_entry *e1, *e2;\n \ndiff --git a/builtin/describe.c b/builtin/describe.c\nindex 3af36483f2..084fa00f2a 100644\n--- a/builtin/describe.c\n+++ b/builtin/describe.c\n@@ -63,7 +63,7 @@ static const char *prio_names[] = {\n \tN_(\"head\"), N_(\"lightweight\"), N_(\"annotated\"),\n };\n \n-static int commit_name_neq(const void *unused_cmp_data,\n+static int commit_name_neq(const void *UNUSED(cmp_data),\n \t\t\t   const struct hashmap_entry *eptr,\n \t\t\t   const struct hashmap_entry *entry_or_key,\n \t\t\t   const void *peeled)\ndiff --git a/builtin/difftool.c b/builtin/difftool.c\nindex b3c509b8de..a570200e66 100644\n--- a/builtin/difftool.c\n+++ b/builtin/difftool.c\n@@ -125,10 +125,10 @@ struct working_tree_entry {\n \tchar path[FLEX_ARRAY];\n };\n \n-static int working_tree_entry_cmp(const void *unused_cmp_data,\n+static int working_tree_entry_cmp(const void *UNUSED(cmp_data),\n \t\t\t\t  const struct hashmap_entry *eptr,\n \t\t\t\t  const struct hashmap_entry *entry_or_key,\n-\t\t\t\t  const void *unused_keydata)\n+\t\t\t\t  const void *UNUSED(keydata))\n {\n \tconst struct working_tree_entry *a, *b;\n \n@@ -148,10 +148,10 @@ struct pair_entry {\n \tconst char path[FLEX_ARRAY];\n };\n \n-static int pair_cmp(const void *unused_cmp_data,\n+static int pair_cmp(const void *UNUSED(cmp_data),\n \t\t    const struct hashmap_entry *eptr,\n \t\t    const struct hashmap_entry *entry_or_key,\n-\t\t    const void *unused_keydata)\n+\t\t    const void *UNUSED(keydata))\n {\n \tconst struct pair_entry *a, *b;\n \n@@ -184,7 +184,7 @@ struct path_entry {\n \tchar path[FLEX_ARRAY];\n };\n \n-static int path_entry_cmp(const void *unused_cmp_data,\n+static int path_entry_cmp(const void *UNUSED(cmp_data),\n \t\t\t  const struct hashmap_entry *eptr,\n \t\t\t  const struct hashmap_entry *entry_or_key,\n \t\t\t  const void *key)\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex e1748fb98b..bb05b50a5a 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -119,7 +119,7 @@ struct anonymized_entry_key {\n \tsize_t orig_len;\n };\n \n-static int anonymized_entry_cmp(const void *unused_cmp_data,\n+static int anonymized_entry_cmp(const void *UNUSED(cmp_data),\n \t\t\t\tconst struct hashmap_entry *eptr,\n \t\t\t\tconst struct hashmap_entry *entry_or_key,\n \t\t\t\tconst void *keydata)\ndiff --git a/builtin/fast-import.c b/builtin/fast-import.c\nindex 14113cfd82..76ed0c2db9 100644\n--- a/builtin/fast-import.c\n+++ b/builtin/fast-import.c\n@@ -46,7 +46,7 @@ struct object_entry {\n \t\tdepth : DEPTH_BITS;\n };\n \n-static int object_entry_hashcmp(const void *map_data,\n+static int object_entry_hashcmp(const void *UNUSED(map_data),\n \t\t\t\tconst struct hashmap_entry *eptr,\n \t\t\t\tconst struct hashmap_entry *entry_or_key,\n \t\t\t\tconst void *keydata)\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex 9e7c8099fe..5fddaef480 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -301,7 +301,7 @@ struct refname_hash_entry {\n \tchar refname[FLEX_ARRAY];\n };\n \n-static int refname_hash_entry_cmp(const void *hashmap_cmp_fn_data,\n+static int refname_hash_entry_cmp(const void *UNUSED(hashmap_cmp_fn_data),\n \t\t\t\t  const struct hashmap_entry *eptr,\n \t\t\t\t  const struct hashmap_entry *entry_or_key,\n \t\t\t\t  const void *keydata)\ndiff --git a/compat/terminal.c b/compat/terminal.c\nindex 7db330c52d..0b0caae857 100644\n--- a/compat/terminal.c\n+++ b/compat/terminal.c\n@@ -477,7 +477,7 @@ struct escape_sequence_entry {\n \tchar sequence[FLEX_ARRAY];\n };\n \n-static int sequence_entry_cmp(const void *hashmap_cmp_fn_data,\n+static int sequence_entry_cmp(const void *UNUSED(hashmap_cmp_fn_data),\n \t\t\t      const struct escape_sequence_entry *e1,\n \t\t\t      const struct escape_sequence_entry *e2,\n \t\t\t      const void *keydata)\ndiff --git a/config.c b/config.c\nindex 589dec9028..c92f1efd6b 100644\n--- a/config.c\n+++ b/config.c\n@@ -2338,10 +2338,10 @@ static int configset_add_value(struct config_set *cs, const char *key, const cha\n \treturn 0;\n }\n \n-static int config_set_element_cmp(const void *unused_cmp_data,\n+static int config_set_element_cmp(const void *UNUSED(cmp_data),\n \t\t\t\t  const struct hashmap_entry *eptr,\n \t\t\t\t  const struct hashmap_entry *entry_or_key,\n-\t\t\t\t  const void *unused_keydata)\n+\t\t\t\t  const void *UNUSED(keydata))\n {\n \tconst struct config_set_element *e1, *e2;\n \ndiff --git a/diff.c b/diff.c\nindex 8a9c9083f3..7c7d53d277 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -917,7 +917,7 @@ struct interned_diff_symbol {\n static int interned_diff_symbol_cmp(const void *hashmap_cmp_fn_data,\n \t\t\t\t    const struct hashmap_entry *eptr,\n \t\t\t\t    const struct hashmap_entry *entry_or_key,\n-\t\t\t\t    const void *keydata)\n+\t\t\t\t    const void *UNUSED(keydata))\n {\n \tconst struct diff_options *diffopt = hashmap_cmp_fn_data;\n \tconst struct emitted_diff_symbol *a, *b;\ndiff --git a/dir.c b/dir.c\nindex 50eeb8b11e..e8b225eed4 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -655,10 +655,10 @@ void parse_path_pattern(const char **pattern,\n \t*patternlen = len;\n }\n \n-int pl_hashmap_cmp(const void *unused_cmp_data,\n+int pl_hashmap_cmp(const void *UNUSED(cmp_data),\n \t\t   const struct hashmap_entry *a,\n \t\t   const struct hashmap_entry *b,\n-\t\t   const void *key)\n+\t\t   const void *UNUSED(key))\n {\n \tconst struct pattern_entry *ee1 =\n \t\t\tcontainer_of(a, struct pattern_entry, ent);\ndiff --git a/environment.c b/environment.c\nindex b3296ce7d1..a0ceb6d655 100644\n--- a/environment.c\n+++ b/environment.c\n@@ -333,10 +333,10 @@ static void set_git_dir_1(const char *path)\n \tsetup_git_env(path);\n }\n \n-static void update_relative_gitdir(const char *name,\n+static void update_relative_gitdir(const char *UNUSED(name),\n \t\t\t\t   const char *old_cwd,\n \t\t\t\t   const char *new_cwd,\n-\t\t\t\t   void *data)\n+\t\t\t\t   void *UNUSED(data))\n {\n \tchar *path = reparent_relative_path(old_cwd, new_cwd, get_git_dir());\n \tstruct tmp_objdir *tmp_objdir = tmp_objdir_unapply_primary_odb();\ndiff --git a/hashmap.c b/hashmap.c\nindex 134d2eec80..763aa1d8a3 100644\n--- a/hashmap.c\n+++ b/hashmap.c\n@@ -142,10 +142,10 @@ static inline struct hashmap_entry **find_entry_ptr(const struct hashmap *map,\n \treturn e;\n }\n \n-static int always_equal(const void *unused_cmp_data,\n-\t\t\tconst struct hashmap_entry *unused1,\n-\t\t\tconst struct hashmap_entry *unused2,\n-\t\t\tconst void *unused_keydata)\n+static int always_equal(const void *UNUSED(cmp_data),\n+\t\t\tconst struct hashmap_entry *UNUSED(entry1),\n+\t\t\tconst struct hashmap_entry *UNUSED(entry2),\n+\t\t\tconst void *UNUSED(keydata))\n {\n \treturn 0;\n }\n@@ -313,7 +313,7 @@ struct pool_entry {\n \tunsigned char data[FLEX_ARRAY];\n };\n \n-static int pool_entry_cmp(const void *unused_cmp_data,\n+static int pool_entry_cmp(const void *UNUSED(cmp_data),\n \t\t\t  const struct hashmap_entry *eptr,\n \t\t\t  const struct hashmap_entry *entry_or_key,\n \t\t\t  const void *keydata)\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex b83a129b43..775ebe2182 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -45,7 +45,7 @@ struct path_hashmap_entry {\n \tchar path[FLEX_ARRAY];\n };\n \n-static int path_hashmap_cmp(const void *cmp_data,\n+static int path_hashmap_cmp(const void *UNUSED(cmp_data),\n \t\t\t    const struct hashmap_entry *eptr,\n \t\t\t    const struct hashmap_entry *entry_or_key,\n \t\t\t    const void *keydata)\n@@ -89,10 +89,10 @@ static struct dir_rename_entry *dir_rename_find_entry(struct hashmap *hashmap,\n \treturn hashmap_get_entry(hashmap, &key, ent, NULL);\n }\n \n-static int dir_rename_cmp(const void *unused_cmp_data,\n+static int dir_rename_cmp(const void *UNUSED(cmp_data),\n \t\t\t  const struct hashmap_entry *eptr,\n \t\t\t  const struct hashmap_entry *entry_or_key,\n-\t\t\t  const void *unused_keydata)\n+\t\t\t  const void *UNUSED(keydata))\n {\n \tconst struct dir_rename_entry *e1, *e2;\n \n@@ -134,10 +134,10 @@ static struct collision_entry *collision_find_entry(struct hashmap *hashmap,\n \treturn hashmap_get_entry(hashmap, &key, ent, NULL);\n }\n \n-static int collision_cmp(const void *unused_cmp_data,\n+static int collision_cmp(const void *UNUSED(cmp_data),\n \t\t\t const struct hashmap_entry *eptr,\n \t\t\t const struct hashmap_entry *entry_or_key,\n-\t\t\t const void *unused_keydata)\n+\t\t\t const void *UNUSED(keydata))\n {\n \tconst struct collision_entry *e1, *e2;\n \ndiff --git a/name-hash.c b/name-hash.c\nindex 7487d33124..d0da6db564 100644\n--- a/name-hash.c\n+++ b/name-hash.c\n@@ -18,7 +18,7 @@ struct dir_entry {\n \tchar name[FLEX_ARRAY];\n };\n \n-static int dir_entry_cmp(const void *unused_cmp_data,\n+static int dir_entry_cmp(const void *UNUSED(cmp_data),\n \t\t\t const struct hashmap_entry *eptr,\n \t\t\t const struct hashmap_entry *entry_or_key,\n \t\t\t const void *keydata)\n@@ -120,7 +120,7 @@ static void hash_index_entry(struct index_state *istate, struct cache_entry *ce)\n \t\tadd_dir_entry(istate, ce);\n }\n \n-static int cache_entry_cmp(const void *unused_cmp_data,\n+static int cache_entry_cmp(const void *UNUSED(cmp_data),\n \t\t\t   const struct hashmap_entry *eptr,\n \t\t\t   const struct hashmap_entry *entry_or_key,\n \t\t\t   const void *remove)\ndiff --git a/object-store.h b/object-store.h\nindex 5222ee5460..cf5494af80 100644\n--- a/object-store.h\n+++ b/object-store.h\n@@ -141,7 +141,7 @@ struct packed_git {\n \n struct multi_pack_index;\n \n-static inline int pack_map_entry_cmp(const void *unused_cmp_data,\n+static inline int pack_map_entry_cmp(const void *UNUSED(cmp_data),\n \t\t\t\t     const struct hashmap_entry *entry,\n \t\t\t\t     const struct hashmap_entry *entry2,\n \t\t\t\t     const void *keydata)\ndiff --git a/oidmap.c b/oidmap.c\nindex 286a04a53c..32aeb0526f 100644\n--- a/oidmap.c\n+++ b/oidmap.c\n@@ -1,7 +1,7 @@\n #include \"cache.h\"\n #include \"oidmap.h\"\n \n-static int oidmap_neq(const void *hashmap_cmp_fn_data,\n+static int oidmap_neq(const void *UNUSED(hashmap_cmp_fn_data),\n \t\t      const struct hashmap_entry *e1,\n \t\t      const struct hashmap_entry *e2,\n \t\t      const void *keydata)\ndiff --git a/packfile.c b/packfile.c\nindex 5ae3ce8ea9..d7cf8382de 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -1392,7 +1392,7 @@ static int delta_base_cache_key_eq(const struct delta_base_cache_key *a,\n \treturn a->p == b->p && a->base_offset == b->base_offset;\n }\n \n-static int delta_base_cache_hash_cmp(const void *unused_cmp_data,\n+static int delta_base_cache_hash_cmp(const void *UNUSED(cmp_data),\n \t\t\t\t     const struct hashmap_entry *va,\n \t\t\t\t     const struct hashmap_entry *vb,\n \t\t\t\t     const void *vkey)\ndiff --git a/patch-ids.c b/patch-ids.c\nindex 8bf425555d..cdfa513549 100644\n--- a/patch-ids.c\n+++ b/patch-ids.c\n@@ -38,7 +38,7 @@ int commit_patch_id(struct commit *commit, struct diff_options *options,\n static int patch_id_neq(const void *cmpfn_data,\n \t\t\tconst struct hashmap_entry *eptr,\n \t\t\tconst struct hashmap_entry *entry_or_key,\n-\t\t\tconst void *unused_keydata)\n+\t\t\tconst void *UNUSED(keydata))\n {\n \t/* NEEDSWORK: const correctness? */\n \tstruct diff_options *opt = (void *)cmpfn_data;\ndiff --git a/range-diff.c b/range-diff.c\nindex f63b3ffc20..1528fdd0db 100644\n--- a/range-diff.c\n+++ b/range-diff.c\n@@ -224,8 +224,10 @@ static int read_patches(const char *range, struct string_list *list,\n \treturn ret;\n }\n \n-static int patch_util_cmp(const void *dummy, const struct patch_util *a,\n-\t\t\t  const struct patch_util *b, const char *keydata)\n+static int patch_util_cmp(const void *UNUSED(cmp_data),\n+\t\t\t  const struct patch_util *a,\n+\t\t\t  const struct patch_util *b,\n+\t\t\t  const char *keydata)\n {\n \treturn strcmp(a->diff, keydata ? keydata : b->diff);\n }\ndiff --git a/ref-filter.c b/ref-filter.c\nindex bdf39fa761..baf252b77d 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -89,7 +89,7 @@ struct ref_to_worktree_entry {\n \tstruct worktree *wt; /* key is wt->head_ref */\n };\n \n-static int ref_to_worktree_map_cmpfnc(const void *unused_lookupdata,\n+static int ref_to_worktree_map_cmpfnc(const void *UNUSED(lookupdata),\n \t\t\t\t      const struct hashmap_entry *eptr,\n \t\t\t\t      const struct hashmap_entry *kptr,\n \t\t\t\t      const void *keydata_aka_refname)\ndiff --git a/refs.c b/refs.c\nindex 38b1165189..5012bba357 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -1815,7 +1815,7 @@ struct ref_store_hash_entry\n \tchar name[FLEX_ARRAY];\n };\n \n-static int ref_store_hash_cmp(const void *unused_cmp_data,\n+static int ref_store_hash_cmp(const void *UNUSED(cmp_data),\n \t\t\t      const struct hashmap_entry *eptr,\n \t\t\t      const struct hashmap_entry *entry_or_key,\n \t\t\t      const void *keydata)\ndiff --git a/remote.c b/remote.c\nindex 029fc630b9..ef12aba91d 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -86,7 +86,7 @@ struct remotes_hash_key {\n \tint len;\n };\n \n-static int remotes_hash_cmp(const void *unused_cmp_data,\n+static int remotes_hash_cmp(const void *UNUSED(cmp_data),\n \t\t\t    const struct hashmap_entry *eptr,\n \t\t\t    const struct hashmap_entry *entry_or_key,\n \t\t\t    const void *keydata)\n@@ -170,7 +170,7 @@ struct branches_hash_key {\n \tint len;\n };\n \n-static int branches_hash_cmp(const void *unused_cmp_data,\n+static int branches_hash_cmp(const void *UNUSED(cmp_data),\n \t\t\t     const struct hashmap_entry *eptr,\n \t\t\t     const struct hashmap_entry *entry_or_key,\n \t\t\t     const void *keydata)\ndiff --git a/revision.c b/revision.c\nindex 6c7250d6a8..5eb71e32d0 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -119,10 +119,10 @@ struct path_and_oids_entry {\n \tstruct oidset trees;\n };\n \n-static int path_and_oids_cmp(const void *hashmap_cmp_fn_data,\n+static int path_and_oids_cmp(const void *UNUSED(hashmap_cmp_fn_data),\n \t\t\t     const struct hashmap_entry *eptr,\n \t\t\t     const struct hashmap_entry *entry_or_key,\n-\t\t\t     const void *keydata)\n+\t\t\t     const void *UNUSED(keydata))\n {\n \tconst struct path_and_oids_entry *e1, *e2;\n \ndiff --git a/sequencer.c b/sequencer.c\nindex 5f22b7cd37..e5b52651f8 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -5254,7 +5254,8 @@ struct labels_entry {\n \tchar label[FLEX_ARRAY];\n };\n \n-static int labels_cmp(const void *fndata, const struct hashmap_entry *eptr,\n+static int labels_cmp(const void *UNUSED(fndata),\n+\t\t      const struct hashmap_entry *eptr,\n \t\t      const struct hashmap_entry *entry_or_key, const void *key)\n {\n \tconst struct labels_entry *a, *b;\n@@ -6131,7 +6132,7 @@ struct subject2item_entry {\n \tchar subject[FLEX_ARRAY];\n };\n \n-static int subject2item_cmp(const void *fndata,\n+static int subject2item_cmp(const void *UNUSED(fndata),\n \t\t\t    const struct hashmap_entry *eptr,\n \t\t\t    const struct hashmap_entry *entry_or_key,\n \t\t\t    const void *key)\ndiff --git a/strmap.c b/strmap.c\nindex ee48635708..4e79734e4f 100644\n--- a/strmap.c\n+++ b/strmap.c\n@@ -2,10 +2,10 @@\n #include \"strmap.h\"\n #include \"mem-pool.h\"\n \n-int cmp_strmap_entry(const void *hashmap_cmp_fn_data,\n+int cmp_strmap_entry(const void *UNUSED(hashmap_cmp_fn_data),\n \t\t     const struct hashmap_entry *entry1,\n \t\t     const struct hashmap_entry *entry2,\n-\t\t     const void *keydata)\n+\t\t     const void *UNUSED(keydata))\n {\n \tconst struct strmap_entry *e1, *e2;\n \ndiff --git a/sub-process.c b/sub-process.c\nindex cae56ae6b8..bd6a372a67 100644\n--- a/sub-process.c\n+++ b/sub-process.c\n@@ -5,10 +5,10 @@\n #include \"sigchain.h\"\n #include \"pkt-line.h\"\n \n-int cmd2process_cmp(const void *unused_cmp_data,\n+int cmd2process_cmp(const void *UNUSED(cmp_data),\n \t\t    const struct hashmap_entry *eptr,\n \t\t    const struct hashmap_entry *entry_or_key,\n-\t\t    const void *unused_keydata)\n+\t\t    const void *UNUSED(keydata))\n {\n \tconst struct subprocess_entry *e1, *e2;\n \ndiff --git a/submodule-config.c b/submodule-config.c\nindex c2ac7e7bf3..d7a8ca0269 100644\n--- a/submodule-config.c\n+++ b/submodule-config.c\n@@ -38,10 +38,10 @@ enum lookup_type {\n \tlookup_path\n };\n \n-static int config_path_cmp(const void *unused_cmp_data,\n+static int config_path_cmp(const void *UNUSED(cmp_data),\n \t\t\t   const struct hashmap_entry *eptr,\n \t\t\t   const struct hashmap_entry *entry_or_key,\n-\t\t\t   const void *unused_keydata)\n+\t\t\t   const void *UNUSED(keydata))\n {\n \tconst struct submodule_entry *a, *b;\n \n@@ -52,10 +52,10 @@ static int config_path_cmp(const void *unused_cmp_data,\n \t       !oideq(&a->config->gitmodules_oid, &b->config->gitmodules_oid);\n }\n \n-static int config_name_cmp(const void *unused_cmp_data,\n+static int config_name_cmp(const void *UNUSED(cmp_data),\n \t\t\t   const struct hashmap_entry *eptr,\n \t\t\t   const struct hashmap_entry *entry_or_key,\n-\t\t\t   const void *unused_keydata)\n+\t\t\t   const void *UNUSED(keydata))\n {\n \tconst struct submodule_entry *a, *b;\n \n-- \n2.37.2.928.g0821088f4a\n\n"},{"id":"461535","messageId":"Yv9hMTaIwk2Ui6/7@coredump.intra.peff.net","threadId":"58328","inReplyTo":"Yv9gxqH6nK2KYnNj@coredump.intra.peff.net","subject":"[PATCH 09/11] mark unused read_tree_recursive() callback parameters","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2022-08-19T10:08:49Z","receivedAt":"2022-08-19T10:09:15Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"We pass a callback to read_tree_recursive(), but not every callback\nneeds every parameter. Let's mark the unused ones to satisfy\n-Wunused-parameter.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n archive-tar.c      |  2 +-\n archive-zip.c      |  2 +-\n archive.c          |  3 ++-\n builtin/checkout.c |  2 +-\n builtin/log.c      |  7 ++++---\n builtin/ls-tree.c  | 13 ++++++++-----\n merge-recursive.c  |  2 +-\n 7 files changed, 18 insertions(+), 13 deletions(-)\n\ndiff --git a/archive-tar.c b/archive-tar.c\nindex 45e5d91407..0d66a1e0a8 100644\n--- a/archive-tar.c\n+++ b/archive-tar.c\n@@ -421,7 +421,7 @@ static int git_tar_config(const char *var, const char *value, void *cb)\n \treturn tar_filter_config(var, value, cb);\n }\n \n-static int write_tar_archive(const struct archiver *ar,\n+static int write_tar_archive(const struct archiver *UNUSED(ar),\n \t\t\t     struct archiver_args *args)\n {\n \tint err = 0;\ndiff --git a/archive-zip.c b/archive-zip.c\nindex 854bceb018..d63782dc31 100644\n--- a/archive-zip.c\n+++ b/archive-zip.c\n@@ -618,7 +618,7 @@ static int archive_zip_config(const char *var, const char *value,\n \treturn userdiff_config(var, value);\n }\n \n-static int write_zip_archive(const struct archiver *ar,\n+static int write_zip_archive(const struct archiver *UNUSED(ar),\n \t\t\t     struct archiver_args *args)\n {\n \tint err;\ndiff --git a/archive.c b/archive.c\nindex d5109abb89..8b165e935b 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -382,7 +382,8 @@ struct path_exists_context {\n \tstruct archiver_args *args;\n };\n \n-static int reject_entry(const struct object_id *oid, struct strbuf *base,\n+static int reject_entry(const struct object_id *UNUSED(oid),\n+\t\t\tstruct strbuf *base,\n \t\t\tconst char *filename, unsigned mode,\n \t\t\tvoid *context)\n {\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex 713410ce2c..d18c8c886e 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -125,7 +125,7 @@ static int post_checkout_hook(struct commit *old_commit, struct commit *new_comm\n }\n \n static int update_some(const struct object_id *oid, struct strbuf *base,\n-\t\tconst char *pathname, unsigned mode, void *context)\n+\t\t       const char *pathname, unsigned mode, void *UNUSED(context))\n {\n \tint len;\n \tstruct cache_entry *ce;\ndiff --git a/builtin/log.c b/builtin/log.c\nindex 9b937d59b8..79a2e4d0bb 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -645,9 +645,10 @@ static int show_tag_object(const struct object_id *oid, struct rev_info *rev)\n \treturn 0;\n }\n \n-static int show_tree_object(const struct object_id *oid,\n-\t\tstruct strbuf *base,\n-\t\tconst char *pathname, unsigned mode, void *context)\n+static int show_tree_object(const struct object_id *UNUSED(oid),\n+\t\t\t    struct strbuf *UNUSED(base),\n+\t\t\t    const char *pathname, unsigned mode,\n+\t\t\t    void *context)\n {\n \tFILE *file = context;\n \tfprintf(file, \"%s%s\\n\", pathname, S_ISDIR(mode) ? \"/\" : \"\");\ndiff --git a/builtin/ls-tree.c b/builtin/ls-tree.c\nindex e279be8bb6..48df337605 100644\n--- a/builtin/ls-tree.c\n+++ b/builtin/ls-tree.c\n@@ -142,7 +142,7 @@ static int show_recursive(const char *base, size_t baselen, const char *pathname\n }\n \n static int show_tree_fmt(const struct object_id *oid, struct strbuf *base,\n-\t\t\t const char *pathname, unsigned mode, void *context)\n+\t\t\t const char *pathname, unsigned mode, void *UNUSED(context))\n {\n \tsize_t baselen;\n \tint recurse = 0;\n@@ -213,7 +213,7 @@ static void show_tree_common_default_long(struct strbuf *base,\n \n static int show_tree_default(const struct object_id *oid, struct strbuf *base,\n \t\t\t     const char *pathname, unsigned mode,\n-\t\t\t     void *context)\n+\t\t\t     void *UNUSED(context))\n {\n \tint early;\n \tint recurse;\n@@ -230,7 +230,8 @@ static int show_tree_default(const struct object_id *oid, struct strbuf *base,\n }\n \n static int show_tree_long(const struct object_id *oid, struct strbuf *base,\n-\t\t\t  const char *pathname, unsigned mode, void *context)\n+\t\t\t  const char *pathname, unsigned mode,\n+\t\t\t  void *UNUSED(context))\n {\n \tint early;\n \tint recurse;\n@@ -259,7 +260,8 @@ static int show_tree_long(const struct object_id *oid, struct strbuf *base,\n }\n \n static int show_tree_name_only(const struct object_id *oid, struct strbuf *base,\n-\t\t\t       const char *pathname, unsigned mode, void *context)\n+\t\t\t       const char *pathname, unsigned mode,\n+\t\t\t       void *UNUSED(context))\n {\n \tint early;\n \tint recurse;\n@@ -279,7 +281,8 @@ static int show_tree_name_only(const struct object_id *oid, struct strbuf *base,\n }\n \n static int show_tree_object(const struct object_id *oid, struct strbuf *base,\n-\t\t\t    const char *pathname, unsigned mode, void *context)\n+\t\t\t    const char *pathname, unsigned mode,\n+\t\t\t    void *UNUSED(context))\n {\n \tint early;\n \tint recurse;\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 775ebe2182..08c1c36d33 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -456,7 +456,7 @@ static void unpack_trees_finish(struct merge_options *opt)\n \tclear_unpack_trees_porcelain(&opt->priv->unpack_opts);\n }\n \n-static int save_files_dirs(const struct object_id *oid,\n+static int save_files_dirs(const struct object_id *UNUSED(oid),\n \t\t\t   struct strbuf *base, const char *path,\n \t\t\t   unsigned int mode, void *context)\n {\n-- \n2.37.2.928.g0821088f4a\n\n"},{"id":"461536","messageId":"Yv9hNGG2Ft4vT5S7@coredump.intra.peff.net","threadId":"58328","inReplyTo":"Yv9gxqH6nK2KYnNj@coredump.intra.peff.net","subject":"[PATCH 10/11] run-command: mark unused async callback parameters","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2022-08-19T10:08:52Z","receivedAt":"2022-08-19T10:09:16Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"The start_async(), etc, functions need a \"proc\" callback that conforms\nto a particular interface. Not every callback needs every parameter\n(e.g., the caller might not even ask to open an input descriptor, in\nwhich case there is no point in the callback looking at it). Let's mark\nthese for -Wunused-parameter.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n builtin/receive-pack.c | 2 +-\n convert.c              | 2 +-\n fetch-pack.c           | 2 +-\n send-pack.c            | 2 +-\n 4 files changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex afd36c9c53..6882d526e6 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -465,7 +465,7 @@ static void rp_error(const char *err, ...)\n \tva_end(params);\n }\n \n-static int copy_to_sideband(int in, int out, void *arg)\n+static int copy_to_sideband(int in, int UNUSED(out), void *UNUSED(arg))\n {\n \tchar data[128];\n \tint keepalive_active = 0;\ndiff --git a/convert.c b/convert.c\nindex b31a25b536..25d89fa83b 100644\n--- a/convert.c\n+++ b/convert.c\n@@ -619,7 +619,7 @@ struct filter_params {\n \tconst char *path;\n };\n \n-static int filter_buffer_or_fd(int in, int out, void *data)\n+static int filter_buffer_or_fd(int UNUSED(in), int out, void *data)\n {\n \t/*\n \t * Spawn cmd and feed the buffer contents through its stdin.\ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex bda9d0f433..9f2933e868 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -823,7 +823,7 @@ static int everything_local(struct fetch_pack_args *args,\n \treturn retval;\n }\n \n-static int sideband_demux(int in, int out, void *data)\n+static int sideband_demux(int UNUSED(in), int out, void *data)\n {\n \tint *xd = data;\n \tint ret;\ndiff --git a/send-pack.c b/send-pack.c\nindex 662f7c2aeb..7e99c64e6b 100644\n--- a/send-pack.c\n+++ b/send-pack.c\n@@ -266,7 +266,7 @@ static int receive_status(struct packet_reader *reader, struct ref *refs)\n \treturn ret;\n }\n \n-static int sideband_demux(int in, int out, void *data)\n+static int sideband_demux(int UNUSED(in), int out, void *data)\n {\n \tint *fd = data, ret;\n \tif (async_with_fork())\n-- \n2.37.2.928.g0821088f4a\n\n"},{"id":"461537","messageId":"Yv9hNh1U5Gj3MbTL@coredump.intra.peff.net","threadId":"58328","inReplyTo":"Yv9gxqH6nK2KYnNj@coredump.intra.peff.net","subject":"[PATCH 11/11] is_path_owned_by_current_uid(): mark \"report\" parameter as unused","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2022-08-19T10:08:54Z","receivedAt":"2022-08-19T10:09:19Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"In the non-Windows version of this function, we never have any errors to\nreport, and thus the \"report\" parameter is unused. But we can't drop it,\nbecause we have to maintain function call compatibility with the version\nin compat/mingw.h, which does use this parameter.\n\nNote that there's an extra level of indirection here; the common\nfunction is actually is_path_owned_by_current_user, which is a macro\npointing to \"by_current_uid\" or \"by_current_sid\", depending on the\nplatform. So an alternative here is to eat the unused parameter in the\nmacro, since -Wunused-parameter doesn't complain about macros. But I\nthink the UNUSED() annotation is less obfuscated for somebody reading\nthe code later.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n git-compat-util.h | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex 12239fedf7..a9690126bb 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -498,7 +498,8 @@ static inline void extract_id_from_env(const char *env, uid_t *id)\n \t}\n }\n \n-static inline int is_path_owned_by_current_uid(const char *path, struct strbuf *report)\n+static inline int is_path_owned_by_current_uid(const char *path,\n+\t\t\t\t\t       struct strbuf *UNUSED(report))\n {\n \tstruct stat st;\n \tuid_t euid;\n-- \n2.37.2.928.g0821088f4a\n"},{"id":"461552","messageId":"220819.861qtc8gug.gmgdl@evledraar.gmail.com","threadId":"58328","inReplyTo":"Yv9gxqH6nK2KYnNj@coredump.intra.peff.net","subject":"Re: [PATCH 0/11] annotating unused function parameters","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-08-19T13:58:19Z","receivedAt":"2022-08-19T14:10:07Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Fri, Aug 19 2022, Jeff King wrote:\n\n> I've been carrying a bunch of patches (for almost 4 years now!) that get\n> the code base compiling cleanly with -Wunused-parameter. This is a\n> useful warning in my opinion; it found real bugs[1] when applied to the\n> whole code base. So it would be nice to be able to turn it on all the\n> time and get the same protection going forward.\n> [...]\n> And of course the most important question is: do we like this direction\n> overall. This mass-annotation is a one-time pain. Going forward, the\n> only work would be requiring people to annotate new functions they add\n> (which again, is mostly going to be callbacks). IMHO it's worth it. In\n> addition to possibly finding errors, I think the annotations serve as an\n> extra clue for people reading the code about what the author intended.\n\nI've known you've had this out-of-tree for a while, and really like that\nit's on the path to getting integrated.\n\nBut I have a hang-up about it, which is that I though __attribute__\n(unused) didn't work like *that*.\n\nWhat it means (and maybe only I find this counter-intuitive) is \"trust\nme, this is unused, but don't check!\", furthermore it causes the\ncompiler to completely ignore the variable for the purposes of *all*\nwarnings, not just the unused one.\n\nI may still be missing something, but I wonder if this squashed in\nwouldn't be much better:\n\t\n\tdiff --git a/git-compat-util.h b/git-compat-util.h\n\tindex a9690126bb0..e02e2fc3f6d 100644\n\t--- a/git-compat-util.h\n\t+++ b/git-compat-util.h\n\t@@ -190,9 +190,9 @@ struct strbuf;\n\t #define _SGI_SOURCE 1\n\t \n\t #if defined(__GNUC__)\n\t-#define UNUSED(var) UNUSED_##var __attribute__((unused))\n\t+#define UNUSED(var) var __attribute__((deprecated (\"not 'deprecated', but expected not to be used!\")))\n\t #else\n\t-#define UNUSED(var) UNUSED_##var\n\t+#define UNUSED(var) var\n\t #endif\n\t \n\t #if defined(WIN32) && !defined(__CYGWIN__) /* Both MinGW and MSVC */\n\nI.e. it's a bit counter-intuitive to mark these as \"deprecated\", but you\ncan add a custom message (with both GCC and clang). Improvements to the\nmessage welcome.\n\nNow as in this series we stay silent if the variable is not used, but we\n*don't* stay silent if an UNUSED(var) is actually used, that'll now be\nan error:\n\t\n\txdiff/xdiffi.c: In function ‘xdl_call_hunk_func’:\n\txdiff/xdiffi.c:981:9: error: ‘xe’ is deprecated: not 'deprecated', but expected not to be used! [-Werror=deprecated-declarations]\n\t  981 |         fprintf(stderr, \"%p\", (void*)xe);\n\t      |         ^~~~~~~\n\nThis also means that you don't need to rename the variable just to avoid\n\"accidental\" use, which also has the benefit of not tripping up the\nvariable typo detection.\n"},{"id":"461605","messageId":"c22a8317-7d43-d84b-f63f-df2da31b4658@github.com","threadId":"58328","inReplyTo":"220819.861qtc8gug.gmgdl@evledraar.gmail.com","subject":"Re: [PATCH 0/11] annotating unused function parameters","fromName":"Derrick Stolee","fromEmail":"derrickstolee@github.com","sentAt":"2022-08-19T18:59:35Z","receivedAt":"2022-08-19T18:59:39Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 8/19/2022 9:58 AM, Ævar Arnfjörð Bjarmason wrote:\n> \n> On Fri, Aug 19 2022, Jeff King wrote:\n> \n>> I've been carrying a bunch of patches (for almost 4 years now!) that get\n>> the code base compiling cleanly with -Wunused-parameter. This is a\n>> useful warning in my opinion; it found real bugs[1] when applied to the\n>> whole code base. So it would be nice to be able to turn it on all the\n>> time and get the same protection going forward.\n>> [...]\n>> And of course the most important question is: do we like this direction\n>> overall. This mass-annotation is a one-time pain. Going forward, the\n>> only work would be requiring people to annotate new functions they add\n>> (which again, is mostly going to be callbacks). IMHO it's worth it. In\n>> addition to possibly finding errors, I think the annotations serve as an\n>> extra clue for people reading the code about what the author intended.\n> \n> I've known you've had this out-of-tree for a while, and really like that\n> it's on the path to getting integrated.\n> \n> But I have a hang-up about it, which is that I though __attribute__\n> (unused) didn't work like *that*.\n> \n> What it means (and maybe only I find this counter-intuitive) is \"trust\n> me, this is unused, but don't check!\", furthermore it causes the\n> compiler to completely ignore the variable for the purposes of *all*\n> warnings, not just the unused one.\n\nThat's not the reason for the attribute at all. It's supposed to say \"I\nknow this is unused, but I still need it to be in the parameter list for\nother reasons. Don't create a warning for this case.\"\n\nInterpreting it the way you are means \"don't do the analysis. Just throw a\nwarning.\" which doesn't make any sense.\n\n> I may still be missing something, but I wonder if this squashed in\n> wouldn't be much better:\n> \t\n> \tdiff --git a/git-compat-util.h b/git-compat-util.h\n> \tindex a9690126bb0..e02e2fc3f6d 100644\n> \t--- a/git-compat-util.h\n> \t+++ b/git-compat-util.h\n> \t@@ -190,9 +190,9 @@ struct strbuf;\n> \t #define _SGI_SOURCE 1\n> \t \n> \t #if defined(__GNUC__)\n> \t-#define UNUSED(var) UNUSED_##var __attribute__((unused))\n> \t+#define UNUSED(var) var __attribute__((deprecated (\"not 'deprecated', but expected not to be used!\")))\n> \t #else\n> \t-#define UNUSED(var) UNUSED_##var\n> \t+#define UNUSED(var) var\n> \t #endif\n\nDoes the deprecated attribute imply unused? Or at the very least, does it\navoid the -Wunused-parameter warnings?\n\nIt might be helpful to _also_ have a deprecated annotation so we know to\nremove the UNUSED macro if a parameter starts being used again. The\nexisting macro changes the variable name so we would get compiler errors\nif we started using it, but we could have a better message indicating\nexactly why things are not working.\n\nSo in that sense, you are onto something. Should we use both attributes?\n\nAt the very least, the warning message you recommend in the 'deprecated'\nattribute could be more direct about what we expect.\n\t \n\t #if defined(__GNUC__)\n\t-#define UNUSED(var) UNUSED_##var __attribute__((unused))\n\t+#define UNUSED(var) var __attribute__((unused)) \\\n\t\t\t\t __attribute__((deprecated (\"remove UNUSED macro before using\")))\n\t #else\n\t-#define UNUSED(var) UNUSED_##var\n\t+#define UNUSED(var) var\n\t #endif\n\t \n\t #if defined(WIN32) && !defined(__CYGWIN__) /* Both MinGW and MSVC */\n\nThanks,\n-Stolee\n"},{"id":"461617","messageId":"220819.868rnk54ju.gmgdl@evledraar.gmail.com","threadId":"58328","inReplyTo":"c22a8317-7d43-d84b-f63f-df2da31b4658@github.com","subject":"Re: [PATCH 0/11] annotating unused function parameters","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-08-19T20:58:08Z","receivedAt":"2022-08-19T21:03:57Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Fri, Aug 19 2022, Derrick Stolee wrote:\n\n> On 8/19/2022 9:58 AM, Ævar Arnfjörð Bjarmason wrote:\n>> \n>> On Fri, Aug 19 2022, Jeff King wrote:\n>> \n>>> I've been carrying a bunch of patches (for almost 4 years now!) that get\n>>> the code base compiling cleanly with -Wunused-parameter. This is a\n>>> useful warning in my opinion; it found real bugs[1] when applied to the\n>>> whole code base. So it would be nice to be able to turn it on all the\n>>> time and get the same protection going forward.\n>>> [...]\n>>> And of course the most important question is: do we like this direction\n>>> overall. This mass-annotation is a one-time pain. Going forward, the\n>>> only work would be requiring people to annotate new functions they add\n>>> (which again, is mostly going to be callbacks). IMHO it's worth it. In\n>>> addition to possibly finding errors, I think the annotations serve as an\n>>> extra clue for people reading the code about what the author intended.\n>> \n>> I've known you've had this out-of-tree for a while, and really like that\n>> it's on the path to getting integrated.\n>> \n>> But I have a hang-up about it, which is that I though __attribute__\n>> (unused) didn't work like *that*.\n>> \n>> What it means (and maybe only I find this counter-intuitive) is \"trust\n>> me, this is unused, but don't check!\", furthermore it causes the\n>> compiler to completely ignore the variable for the purposes of *all*\n>> warnings, not just the unused one.\n>\n> That's not the reason for the attribute at all. It's supposed to say \"I\n> know this is unused, but I still need it to be in the parameter list for\n> other reasons. Don't create a warning for this case.\"\n>\n> Interpreting it the way you are means \"don't do the analysis. Just throw a\n> warning.\" which doesn't make any sense.\n>\n>> I may still be missing something, but I wonder if this squashed in\n>> wouldn't be much better:\n>> \t\n>> \tdiff --git a/git-compat-util.h b/git-compat-util.h\n>> \tindex a9690126bb0..e02e2fc3f6d 100644\n>> \t--- a/git-compat-util.h\n>> \t+++ b/git-compat-util.h\n>> \t@@ -190,9 +190,9 @@ struct strbuf;\n>> \t #define _SGI_SOURCE 1\n>> \t \n>> \t #if defined(__GNUC__)\n>> \t-#define UNUSED(var) UNUSED_##var __attribute__((unused))\n>> \t+#define UNUSED(var) var __attribute__((deprecated (\"not 'deprecated', but expected not to be used!\")))\n>> \t #else\n>> \t-#define UNUSED(var) UNUSED_##var\n>> \t+#define UNUSED(var) var\n>> \t #endif\n>\n> Does the deprecated attribute imply unused? Or at the very least, does it\n> avoid the -Wunused-parameter warnings?\n>\n> It might be helpful to _also_ have a deprecated annotation so we know to\n> remove the UNUSED macro if a parameter starts being used again. The\n> existing macro changes the variable name so we would get compiler errors\n> if we started using it, but we could have a better message indicating\n> exactly why things are not working.\n>\n> So in that sense, you are onto something. Should we use both attributes?\n>\n> At the very least, the warning message you recommend in the 'deprecated'\n> attribute could be more direct about what we expect.\n> \t \n> \t #if defined(__GNUC__)\n> \t-#define UNUSED(var) UNUSED_##var __attribute__((unused))\n> \t+#define UNUSED(var) var __attribute__((unused)) \\\n> \t\t\t\t __attribute__((deprecated (\"remove UNUSED macro before using\")))\n> \t #else\n> \t-#define UNUSED(var) UNUSED_##var\n> \t+#define UNUSED(var) var\n> \t #endif\n> \t \n> \t #if defined(WIN32) && !defined(__CYGWIN__) /* Both MinGW and MSVC */\n\nYes, I spoke too soon, sorry. We still need ((unused)). FWIW the below\non top of master and doing:\n\n\t make bisect.o CFLAGS=-Wunused-parameter\n\nDoes the right thing for me, and then warns if you uncomment that \"//\"\ncommented fprintf().\n\nThe reason I was confused is that -Wunused-parameter is *not* needed\nwith ((deprecated)) to error if the variable is used, but it *is* needed\nto hide it from -Wunused-parameter if you're trying to find the next\nthing to mark as \"UNUSED\" (or to refactor away).\n\nI think the below version of it also shows that you don't need to pass\nthe variable name to the macro. If the only reason for that was to avoid\naccidental use it seems like the ((deprecated)) attribute should cover\nit.\n\nI'd prefer it if we could avoid the funny syntax, it's highlighted a bit\nweirdly in my editor, and I suspect I'm not the only one, but mainly\nhaving the extra compiler-enforced sanity checking of checking if it's\naccidentally used, without renaming the variable, which seems like a bit\nof a hack.\n\ndiff --git a/bisect.c b/bisect.c\nindex 38b3891f3a6..fd581b85a72 100644\n--- a/bisect.c\n+++ b/bisect.c\n@@ -441,7 +441,7 @@ void find_bisection(struct commit_list **commit_list, int *reaches,\n }\n \n static int register_ref(const char *refname, const struct object_id *oid,\n-\t\t\tint flags, void *cb_data)\n+\t\t\tint flags UNUSED, void *cb_data UNUSED)\n {\n \tstruct strbuf good_prefix = STRBUF_INIT;\n \tstrbuf_addstr(&good_prefix, term_good);\n@@ -1160,8 +1160,9 @@ int estimate_bisect_steps(int all)\n \treturn (e < 3 * x) ? n : n - 1;\n }\n \n-static int mark_for_removal(const char *refname, const struct object_id *oid,\n-\t\t\t    int flag, void *cb_data)\n+static int mark_for_removal(const char *refname,\n+\t\t\t    const struct object_id *oid UNUSED,\n+\t\t\t    int flag UNUSED, void *cb_data)\n {\n \tstruct string_list *refs = cb_data;\n \tchar *ref = xstrfmt(\"refs/bisect%s\", refname);\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex 36a25ae252f..7f7395fc9f7 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -189,6 +189,12 @@ struct strbuf;\n #define _NETBSD_SOURCE 1\n #define _SGI_SOURCE 1\n \n+#if defined(__GNUC__)\n+#define UNUSED __attribute__((unused)) __attribute__((deprecated (\"marked with UNUSED\")))\n+#else\n+#define UNUSED\n+#endif\n+\n #if defined(WIN32) && !defined(__CYGWIN__) /* Both MinGW and MSVC */\n # if !defined(_WIN32_WINNT)\n #  define _WIN32_WINNT 0x0600\n@@ -302,7 +308,8 @@ typedef unsigned long uintptr_t;\n #ifdef PRECOMPOSE_UNICODE\n #include \"compat/precompose_utf8.h\"\n #else\n-static inline const char *precompose_argv_prefix(int argc, const char **argv, const char *prefix)\n+static inline const char *precompose_argv_prefix(int argc UNUSED, const char **argv UNUSED,\n+\t\t\t\t\t\t const char *prefix)\n {\n \treturn prefix;\n }\n@@ -397,7 +404,8 @@ typedef uintmax_t timestamp_t;\n #endif\n \n #ifndef platform_core_config\n-static inline int noop_core_config(const char *var, const char *value, void *cb)\n+static inline int noop_core_config(const char *var UNUSED, const char *value UNUSED,\n+\t\t\t\t   void *cb UNUSED)\n {\n \treturn 0;\n }\n@@ -410,7 +418,7 @@ int lstat_cache_aware_rmdir(const char *path);\n #endif\n \n #ifndef has_dos_drive_prefix\n-static inline int git_has_dos_drive_prefix(const char *path)\n+static inline int git_has_dos_drive_prefix(const char *path UNUSED)\n {\n \treturn 0;\n }\n@@ -418,7 +426,7 @@ static inline int git_has_dos_drive_prefix(const char *path)\n #endif\n \n #ifndef skip_dos_drive_prefix\n-static inline int git_skip_dos_drive_prefix(char **path)\n+static inline int git_skip_dos_drive_prefix(char **path UNUSED)\n {\n \treturn 0;\n }\n@@ -490,11 +498,13 @@ static inline void extract_id_from_env(const char *env, uid_t *id)\n \t}\n }\n \n-static inline int is_path_owned_by_current_uid(const char *path, struct strbuf *report)\n+static inline int is_path_owned_by_current_uid(const char *path, struct strbuf *report UNUSED)\n {\n \tstruct stat st;\n \tuid_t euid;\n \n+\t//fprintf(stderr, \"%p\", (void*)report);\n+\n \tif (lstat(path, &st))\n \t\treturn 0;\n \ndiff --git a/object-store.h b/object-store.h\nindex 5222ee54600..218ffe73604 100644\n--- a/object-store.h\n+++ b/object-store.h\n@@ -141,7 +141,7 @@ struct packed_git {\n \n struct multi_pack_index;\n \n-static inline int pack_map_entry_cmp(const void *unused_cmp_data,\n+static inline int pack_map_entry_cmp(const void *unused_cmp_data UNUSED,\n \t\t\t\t     const struct hashmap_entry *entry,\n \t\t\t\t     const struct hashmap_entry *entry2,\n \t\t\t\t     const void *keydata)\n\n"},{"id":"461654","messageId":"YwCtkwjWdJVHHZV0@coredump.intra.peff.net","threadId":"58328","inReplyTo":"220819.868rnk54ju.gmgdl@evledraar.gmail.com","subject":"Re: [PATCH 0/11] annotating unused function parameters","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2022-08-20T09:46:59Z","receivedAt":"2022-08-20T09:47:05Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Aug 19, 2022 at 10:58:08PM +0200, Ævar Arnfjörð Bjarmason wrote:\n\n> Yes, I spoke too soon, sorry. We still need ((unused)). FWIW the below\n> on top of master and doing:\n\nRight. Using ((deprecated)) is really just a substitute for the variable\nrenaming part.\n\nAnd I agree it works as advertised, though I think I prefer the\nvariable-renaming version.\n\nOne, it feels like we're abusing the deprecated attribute here. The\nconfusion in the compiler output I'm OK with, because we get a chance to\nput our own message there (so I agree the output is actually better than\nwith my patch). But from time to time I've had to build with\n-Wno-deprecated-declarations to get around _actual_ deprecated warnings\n(e.g., compiling with OPENSSL_SHA1=Yes). And doing so would be cutting\nout half the protection of UNUSED() in that case.\n\nLikewise, one thing I like about the renaming is that it fails\ncompilation regardless of -Werror. So it will be caught in any compile,\nno matter what. And I do automatically compile without DEVELOPER=1 when\non a detached HEAD, because historical commits often trigger warnings.\nGo back far enough and OPENSSL_SHA1 was the default, which generates\nlots of warnings these days. :)\n\nAnd finally, I actually prefer the parentheses of:\n\n  static int register_ref(const char *refname, const struct object_id *oid,\n\t\t\t  int UNUSED(flags), void *UNUSED(cb_data))\n\nIt visually binds the attribute more tightly to the variable name, like\nhow we sometimes write unused_flags manually in existing code. When\nthere are a lot of variables to mark in a function (and some callbacks\nreally do have a lot), that makes it easier to see what's going on. To\nme, anyway. I recognize that it's a matter of taste.\n\nTechnically this last thing is orthogonal to using the deprecated\nattribute. It could still be used with the parenthesized form, but the\nerror messages gcc generates are horrendous then (it repeats the warning\nseveral times due to the macro).\n\nSo I dunno. These are all matters of opinion, and if it was just my\npatches, I'd say my taste wins. But all of us are going to have to write\nthese annotations at some time or another when we add callbacks, etc. So\nwe should at the very least pick a syntax the majority prefers. :)\n\n-Peff\n"},{"id":"461663","messageId":"xmqqzgfyhaq6.fsf@gitster.g","threadId":"58328","inReplyTo":"YwCtkwjWdJVHHZV0@coredump.intra.peff.net","subject":"Re: [PATCH 0/11] annotating unused function parameters","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-08-20T21:21:53Z","receivedAt":"2022-08-20T21:22:01Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> Likewise, one thing I like about the renaming is that it fails\n> compilation regardless of -Werror.\n\nYes, I like that aspect of the macro very much.\n\n> And finally, I actually prefer the parentheses of:\n>\n>   static int register_ref(const char *refname, const struct object_id *oid,\n> \t\t\t  int UNUSED(flags), void *UNUSED(cb_data))\n\nThat, too.\n\n> So I dunno. These are all matters of opinion, and if it was just my\n> patches, I'd say my taste wins. But all of us are going to have to write\n> these annotations at some time or another when we add callbacks, etc. So\n> we should at the very least pick a syntax the majority prefers. :)\n\nWell, we can teach others a good taste ;-)\n"},{"id":"461756","messageId":"5181bfe9-a4d0-76ed-26ee-1f4400105e9e@github.com","threadId":"58328","inReplyTo":"YwCtkwjWdJVHHZV0@coredump.intra.peff.net","subject":"Re: [PATCH 0/11] annotating unused function parameters","fromName":"Derrick Stolee","fromEmail":"derrickstolee@github.com","sentAt":"2022-08-22T14:14:00Z","receivedAt":"2022-08-22T14:14:11Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 8/20/2022 5:46 AM, Jeff King wrote:\n> On Fri, Aug 19, 2022 at 10:58:08PM +0200, Ævar Arnfjörð Bjarmason wrote:\n> \n>> Yes, I spoke too soon, sorry. We still need ((unused)). FWIW the below\n>> on top of master and doing:\n> \n> Right. Using ((deprecated)) is really just a substitute for the variable\n> renaming part.\n> \n> And I agree it works as advertised, though I think I prefer the\n> variable-renaming version.\n> \n> One, it feels like we're abusing the deprecated attribute here. The\n> confusion in the compiler output I'm OK with, because we get a chance to\n> put our own message there (so I agree the output is actually better than\n> with my patch). But from time to time I've had to build with\n> -Wno-deprecated-declarations to get around _actual_ deprecated warnings\n> (e.g., compiling with OPENSSL_SHA1=Yes). And doing so would be cutting\n> out half the protection of UNUSED() in that case.\n\nThe fact that we can't turn on -Wno-deprecated-declarations is enough\nto convince me that we need to use the variable renaming trick.\n\nThanks,\n-Stolee\n\n"},{"id":"461947","messageId":"220825.86edx44lzh.gmgdl@evledraar.gmail.com","threadId":"58328","inReplyTo":"YwCtkwjWdJVHHZV0@coredump.intra.peff.net","subject":"Re: [PATCH 0/11] annotating unused function parameters","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-08-25T11:00:19Z","receivedAt":"2022-08-25T11:10:49Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Sat, Aug 20 2022, Jeff King wrote:\n\n> On Fri, Aug 19, 2022 at 10:58:08PM +0200, Ævar Arnfjörð Bjarmason wrote:\n>\n>> Yes, I spoke too soon, sorry. We still need ((unused)). FWIW the below\n>> on top of master and doing:\n>\n> Right. Using ((deprecated)) is really just a substitute for the variable\n> renaming part.\n>\n> And I agree it works as advertised, though I think I prefer the\n> variable-renaming version.\n>\n> One, it feels like we're abusing the deprecated attribute here. The\n\nDefinitely, but structurally it seems like a better pick. I.e. isn't the\nonly problem with it the \"deprecated\" and its interaction with\n-Wno-deprecated.\n\nIf the exact same feature existed as a \"insert-custom-warning\", which\nwould work exactly \"deprecated\" without the default warning \"prefix\"\nwould you think this would fit perfectly?\n\n> ...\n> -Wno-deprecated-declarations to get around _actual_ deprecated warnings\n> (e.g., compiling with OPENSSL_SHA1=Yes). And doing so would be cutting\n> out half the protection of UNUSED() in that case.\n\nThis is mildly annoying, but I don't really think it's a practical\nissue. We're talking about running this without\n-Wno-deprecated-declarations in CI, and by default.\n\nFor unused parameters it's enough that we're catching them somewhere, or\nin common compilation settings, we don't need to catch them\n*everywhere*, do we?\n\nIOW is anyone writing patches where they're testing with\n-Wno-deprecated-declarations *and* adding unused parameters *and* won't\ntest without -Wno-deprecated-declarations before submitting them, *and*\nnobody else will catch it?\n\n> Likewise, one thing I like about the renaming is that it fails\n> compilation regardless of -Werror. So it will be caught in any compile,\n> no matter what. And I do automatically compile without DEVELOPER=1 when\n> on a detached HEAD, because historical commits often trigger warnings.\n> Go back far enough and OPENSSL_SHA1 was the default, which generates\n> lots of warnings these days. :)\n\n*nod*, I think this also goes the other way. It's nice to be able to use\nDEVOPTS=no-error to \"get past\" various minor issues. I consider an\nunused parameter as being a minor issue. E.g. when ad-hoc cherry-picking\nsomething to test on an older version it can be annoying to have to make\nlarger changes when a DEVOPTS=no-error would do.\n\n> And finally, I actually prefer the parentheses of:\n>\n>   static int register_ref(const char *refname, const struct object_id *oid,\n> \t\t\t  int UNUSED(flags), void *UNUSED(cb_data))\n\n...and now to the real reason for the follow-up. You/Junio were CC'd,\nbut this is breaking coccinelle, see:\nhttps://lore.kernel.org/git/220825.86ilmg4mil.gmgdl@evledraar.gmail.com/\n\nSo, bikeshedding-wise I don't care to argue the point. But between odd\nsyntax highlighting and now one analysis tool barfing on it it's a bit\nmore than a bikeshed :)\n"},{"id":"461978","messageId":"Ywhx6LLe6YcS/2xf@coredump.intra.peff.net","threadId":"58328","inReplyTo":"220825.86edx44lzh.gmgdl@evledraar.gmail.com","subject":"Re: [PATCH 0/11] annotating unused function parameters","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2022-08-26T07:10:32Z","receivedAt":"2022-08-26T07:10:45Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Aug 25, 2022 at 01:00:19PM +0200, Ævar Arnfjörð Bjarmason wrote:\n\n> > One, it feels like we're abusing the deprecated attribute here. The\n> \n> Definitely, but structurally it seems like a better pick. I.e. isn't the\n> only problem with it the \"deprecated\" and its interaction with\n> -Wno-deprecated.\n> \n> If the exact same feature existed as a \"insert-custom-warning\", which\n> would work exactly \"deprecated\" without the default warning \"prefix\"\n> would you think this would fit perfectly?\n\nYeah, I agree that would remove my complaint about overloading the\nmeaning. I don't think that exists, though.\n\n> This is mildly annoying, but I don't really think it's a practical\n> issue. We're talking about running this without\n> -Wno-deprecated-declarations in CI, and by default.\n> \n> For unused parameters it's enough that we're catching them somewhere, or\n> in common compilation settings, we don't need to catch them\n> *everywhere*, do we?\n\nNo, but the farther away you go from the edit-compile-run cycle, the\nmore painful warnings become. Catching them immediately and fully has\nreal value, as it means the cost of correcting them is lower. So all\nthings being equal, I think we should prefer universal solutions when\nthey're available (and for example compiler errors over say, coccinelle\nor other analysis tools).\n\n(And yes, I know all things sadly aren't equal; see below...)\n\n> IOW is anyone writing patches where they're testing with\n> -Wno-deprecated-declarations *and* adding unused parameters *and* won't\n> test without -Wno-deprecated-declarations before submitting them, *and*\n> nobody else will catch it?\n\nProbably not. I don't actually build with -Wno-deprecated-declarations\nroutinely. But my fear is that some platform may be stuck there for a\nwhile (because an overzealous libc marks something). But that's kind of\nhypothetical, so we may have to just accept it and cross that bridge if\nwe come to it.\n\n> > And finally, I actually prefer the parentheses of:\n> >\n> >   static int register_ref(const char *refname, const struct object_id *oid,\n> > \t\t\t  int UNUSED(flags), void *UNUSED(cb_data))\n> \n> ...and now to the real reason for the follow-up. You/Junio were CC'd,\n> but this is breaking coccinelle, see:\n> https://lore.kernel.org/git/220825.86ilmg4mil.gmgdl@evledraar.gmail.com/\n\nUgh. Yeah, that is really unfortunate. I much prefer the parenthesized\nsyntax, but if we can't find a way to unconfuse third-party parsing,\nthen switching is probably the least-bad solution.\n\n-Peff\n"},{"id":"461993","messageId":"CAPoeCOb8=6_7RCw6g-B8m_PsQkvYq6QDsk6Vu1WGiiZFG47K1w@mail.gmail.com","threadId":"58328","inReplyTo":"Ywhx6LLe6YcS/2xf@coredump.intra.peff.net","subject":"Re: [PATCH 0/11] annotating unused function parameters","fromName":"Phillip Wood","fromEmail":"phillip.wood123@gmail.com","sentAt":"2022-08-26T13:08:44Z","receivedAt":"2022-08-26T13:08:59Z","isPatch":true,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"Hi Peff\n\nOn Fri, 26 Aug 2022 at 08:33, Jeff King <peff@peff.net> wrote:\n>\n> On Thu, Aug 25, 2022 at 01:00:19PM +0200, Ævar Arnfjörð Bjarmason wrote:\n>\n> > > One, it feels like we're abusing the deprecated attribute here. The\n> >\n> > Definitely, but structurally it seems like a better pick. I.e. isn't the\n> > only problem with it the \"deprecated\" and its interaction with\n> > -Wno-deprecated.\n> > This is mildly annoying, but I don't really think it's a practical\n> > issue. We're talking about running this without\n> > -Wno-deprecated-declarations in CI, and by default.\n> >\n> > For unused parameters it's enough that we're catching them somewhere, or\n> > in common compilation settings, we don't need to catch them\n> > *everywhere*, do we?\n>\n> No, but the farther away you go from the edit-compile-run cycle, the\n> more painful warnings become. Catching them immediately and fully has\n> real value, as it means the cost of correcting them is lower. So all\n> things being equal, I think we should prefer universal solutions when\n> they're available (and for example compiler errors over say, coccinelle\n> or other analysis tools).\n\nThat's a good point, one of the nice things about your macro was that\nall compilers detected when UNUSED() parameters were in fact used. In\ncomparison abusing the deprecated attribute is uglier and less\npractical.\n\n> (And yes, I know all things sadly aren't equal; see below...)\n\nIt might be worth reporting this issue on the coccinelle mailing list\nto see if anyone is interested in fixing it. If it gets fixed we're\nleft with the problem of having  to build it for our ci but that\nshouldn't be insurmountable.\n\nBest Wishes\n\nPhillip\n\n> > IOW is anyone writing patches where they're testing with\n> > -Wno-deprecated-declarations *and* adding unused parameters *and* won't\n> > test without -Wno-deprecated-declarations before submitting them, *and*\n> > nobody else will catch it?\n>\n> Probably not. I don't actually build with -Wno-deprecated-declarations\n> routinely. But my fear is that some platform may be stuck there for a\n> while (because an overzealous libc marks something). But that's kind of\n> hypothetical, so we may have to just accept it and cross that bridge if\n> we come to it.\n>\n> > > And finally, I actually prefer the parentheses of:\n> > >\n> > >   static int register_ref(const char *refname, const struct object_id *oid,\n> > >                       int UNUSED(flags), void *UNUSED(cb_data))\n> >\n> > ...and now to the real reason for the follow-up. You/Junio were CC'd,\n> > but this is breaking coccinelle, see:\n> > https://lore.kernel.org/git/220825.86ilmg4mil.gmgdl@evledraar.gmail.com/\n>\n> Ugh. Yeah, that is really unfortunate. I much prefer the parenthesized\n> syntax, but if we can't find a way to unconfuse third-party parsing,\n> then switching is probably the least-bad solution.\n>\n> -Peff\n"},{"id":"462002","messageId":"xmqqpmgnyn9e.fsf@gitster.g","threadId":"58328","inReplyTo":"Ywhx6LLe6YcS/2xf@coredump.intra.peff.net","subject":"Re: [PATCH 0/11] annotating unused function parameters","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-08-26T16:37:17Z","receivedAt":"2022-08-26T16:37:21Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> No, but the farther away you go from the edit-compile-run cycle, the\n> more painful warnings become. Catching them immediately and fully has\n> real value, as it means the cost of correcting them is lower. So all\n> things being equal, I think we should prefer universal solutions when\n> they're available (and for example compiler errors over say, coccinelle\n> or other analysis tools).\n\nThanks for saying it so succinctly.  Making compiler errors less\nuseful only to please Coccinelle is putting our priority wrong.\n\n> Ugh. Yeah, that is really unfortunate. I much prefer the parenthesized\n> syntax, but if we can't find a way to unconfuse third-party parsing,\n> then switching is probably the least-bad solution.\n\nOr have third-party fix the parsing ;-)  Until then, perhaps we have\nto live with a suboptimal syntax.\n\nThanks.\n"}]}