{"thread":{"id":"61967","subject":"[PATCH 0/15] marking some more unused parameters","startedAt":"2024-08-17T08:21:02Z","lastAt":"2024-08-17T17:18:38Z","messageCount":18,"participants":["Jeff King","Ghanshyam Thakkar"],"isPatch":true,"patchVersion":1,"patchTotal":15},"messages":[{"id":"501188","messageId":"20240817082101.GA6761@coredump.intra.peff.net","threadId":"61967","inReplyTo":null,"subject":"[PATCH 0/15] marking some more unused parameters","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2024-08-17T08:21:01Z","receivedAt":"2024-08-17T08:21:02Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"These are from my pile of -Wunused-parameter fixes. I built this on top\nof the \"dropping\" series I just posted at:\n\n  https://lore.kernel.org/git/20240817072621.GA1535666@coredump.intra.peff.net/\n\nbut it should also be fine to apply it in parallel. This should\nhopefully be pretty quick to review, as it's only marking things UNUSED,\nand never removing them or changing code.\n\n  [01/15]: imap-send: mark unused parameter in ssl_socket_connect() fallback\n  [02/15]: update-ref: mark more unused parameters in parser callbacks\n  [03/15]: refs: mark unused parameters in ref_store fsck callbacks\n  [04/15]: refs: mark unused parameters in do_for_each_reflog_helper()\n  [05/15]: oss-fuzz: mark unused argv/argc argument\n  [06/15]: t/helper: mark more unused argv/argc arguments\n  [07/15]: unit-tests: ignore unused argc/argv\n  [08/15]: reftable: ignore unused argc/argv in test functions\n  [09/15]: reftable: drop obsolete test function declarations\n  [10/15]: reftable: mark unused parameters in virtual functions\n  [11/15]: t-hashmap: mark unused parameters in callback function\n  [12/15]: test-mergesort: mark unused parameters in trivial callback\n  [13/15]: setup: mark unused parameter in config callback\n  [14/15]: daemon: mark unused parameters in non-posix fallbacks\n  [15/15]: scalar: mark unused parmaeters in dummy function\n\n builtin/update-ref.c             |  8 ++++----\n daemon.c                         |  6 +++---\n imap-send.c                      |  2 +-\n oss-fuzz/dummy-cmd-main.c        |  2 +-\n refs.c                           |  5 +++--\n refs/packed-backend.c            |  4 ++--\n refs/reftable-backend.c          | 18 +++++++++---------\n reftable/block_test.c            |  2 +-\n reftable/blocksource.c           |  8 ++++----\n reftable/generic.c               |  8 +++++---\n reftable/iter.c                  |  3 ++-\n reftable/readwrite_test.c        |  2 +-\n reftable/record.c                | 31 ++++++++++++++++++-------------\n reftable/reftable-tests.h        |  2 --\n reftable/stack_test.c            |  6 +++---\n reftable/test_framework.c        |  2 +-\n reftable/writer.c                |  2 +-\n scalar.c                         |  3 ++-\n setup.c                          |  2 +-\n t/helper/test-example-tap.c      |  2 +-\n t/helper/test-hashmap.c          |  2 +-\n t/helper/test-mergesort.c        |  2 +-\n t/unit-tests/t-ctype.c           |  2 +-\n t/unit-tests/t-hash.c            |  2 +-\n t/unit-tests/t-hashmap.c         |  3 ++-\n t/unit-tests/t-mem-pool.c        |  2 +-\n t/unit-tests/t-prio-queue.c      |  2 +-\n t/unit-tests/t-reftable-basics.c |  2 +-\n t/unit-tests/t-reftable-merged.c |  4 ++--\n t/unit-tests/t-reftable-pq.c     |  2 +-\n t/unit-tests/t-reftable-record.c |  2 +-\n t/unit-tests/t-reftable-tree.c   |  2 +-\n t/unit-tests/t-strbuf.c          |  2 +-\n t/unit-tests/t-strcmp-offset.c   |  2 +-\n t/unit-tests/t-strvec.c          |  2 +-\n t/unit-tests/t-trailer.c         |  2 +-\n 36 files changed, 81 insertions(+), 72 deletions(-)\n\n-Peff\n"},{"id":"501189","messageId":"20240817082127.GA10287@coredump.intra.peff.net","threadId":"61967","inReplyTo":"20240817082101.GA6761@coredump.intra.peff.net","subject":"[PATCH 01/15] imap-send: mark unused parameter in ssl_socket_connect() fallback","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2024-08-17T08:21:27Z","receivedAt":"2024-08-17T08:21:29Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"Commit cea1ff7f1f (imap-send: drop global `imap_server_conf` variable,\n2024-06-07) added an imap_server_conf parameter to several functions.\nBut when compiled with NO_OPENSSL, the ssl_socket_connect() fallback\njust returns immediately, so its parameters all need to be annotated to\navoid triggering -Wunused-parameter.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n imap-send.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/imap-send.c b/imap-send.c\nindex 01404e5047..3551908de6 100644\n--- a/imap-send.c\n+++ b/imap-send.c\n@@ -190,7 +190,7 @@ static void socket_perror(const char *func, struct imap_socket *sock, int ret)\n \n #ifdef NO_OPENSSL\n static int ssl_socket_connect(struct imap_socket *sock UNUSED,\n-\t\t\t      const struct imap_server_conf *cfg,\n+\t\t\t      const struct imap_server_conf *cfg UNUSED,\n \t\t\t      int use_tls_only UNUSED)\n {\n \tfprintf(stderr, \"SSL requested but SSL support not compiled in\\n\");\n-- \n2.46.0.585.gd6679c16d8\n\n"},{"id":"501190","messageId":"20240817082157.GB10287@coredump.intra.peff.net","threadId":"61967","inReplyTo":"20240817082101.GA6761@coredump.intra.peff.net","subject":"[PATCH 02/15] update-ref: mark more unused parameters in parser callbacks","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2024-08-17T08:21:57Z","receivedAt":"2024-08-17T08:21:59Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"This is a continuation of 44ad082968 (update-ref: mark unused parameter\nin parser callbacks, 2023-08-29), as we've grown a few more virtual\nfunctions since then.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n builtin/update-ref.c | 8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/update-ref.c b/builtin/update-ref.c\nindex 6a6a2ff55d..8f31da9a4b 100644\n--- a/builtin/update-ref.c\n+++ b/builtin/update-ref.c\n@@ -274,7 +274,7 @@ static void parse_cmd_update(struct ref_transaction *transaction,\n }\n \n static void parse_cmd_symref_update(struct ref_transaction *transaction,\n-\t\t\t\t    const char *next, const char *end)\n+\t\t\t\t    const char *next, const char *end UNUSED)\n {\n \tchar *refname, *new_target, *old_arg;\n \tchar *old_target = NULL;\n@@ -360,7 +360,7 @@ static void parse_cmd_create(struct ref_transaction *transaction,\n \n \n static void parse_cmd_symref_create(struct ref_transaction *transaction,\n-\t\t\t\t    const char *next, const char *end)\n+\t\t\t\t    const char *next, const char *end UNUSED)\n {\n \tstruct strbuf err = STRBUF_INIT;\n \tchar *refname, *new_target;\n@@ -423,7 +423,7 @@ static void parse_cmd_delete(struct ref_transaction *transaction,\n \n \n static void parse_cmd_symref_delete(struct ref_transaction *transaction,\n-\t\t\t\t    const char *next, const char *end)\n+\t\t\t\t    const char *next, const char *end UNUSED)\n {\n \tstruct strbuf err = STRBUF_INIT;\n \tchar *refname, *old_target;\n@@ -479,7 +479,7 @@ static void parse_cmd_verify(struct ref_transaction *transaction,\n }\n \n static void parse_cmd_symref_verify(struct ref_transaction *transaction,\n-\t\t\t\t    const char *next, const char *end)\n+\t\t\t\t    const char *next, const char *end UNUSED)\n {\n \tstruct strbuf err = STRBUF_INIT;\n \tstruct object_id old_oid;\n-- \n2.46.0.585.gd6679c16d8\n\n"},{"id":"501191","messageId":"20240817082205.GC10287@coredump.intra.peff.net","threadId":"61967","inReplyTo":"20240817082101.GA6761@coredump.intra.peff.net","subject":"[PATCH 03/15] refs: mark unused parameters in ref_store fsck callbacks","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2024-08-17T08:22:05Z","receivedAt":"2024-08-17T08:22:07Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"Commit ab6f79d8df (refs: set up ref consistency check infrastructure,\n2024-08-08) added virtual functions to the ref store for doing fsck\nchecks. But the packed and reftable backends do not yet do anything.\n\nLet's annotate them to silence -Wunused-parameter.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n refs/packed-backend.c   | 4 ++--\n refs/reftable-backend.c | 4 ++--\n 2 files changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/refs/packed-backend.c b/refs/packed-backend.c\nindex f00106df14..afd292ec6a 100644\n--- a/refs/packed-backend.c\n+++ b/refs/packed-backend.c\n@@ -1733,8 +1733,8 @@ static struct ref_iterator *packed_reflog_iterator_begin(struct ref_store *ref_s\n \treturn empty_ref_iterator_begin();\n }\n \n-static int packed_fsck(struct ref_store *ref_store,\n-\t\t       struct fsck_options *o)\n+static int packed_fsck(struct ref_store *ref_store UNUSED,\n+\t\t       struct fsck_options *o UNUSED)\n {\n \treturn 0;\n }\ndiff --git a/refs/reftable-backend.c b/refs/reftable-backend.c\nindex 8b7ffbf66f..7337d4422d 100644\n--- a/refs/reftable-backend.c\n+++ b/refs/reftable-backend.c\n@@ -2309,8 +2309,8 @@ static int reftable_be_reflog_expire(struct ref_store *ref_store,\n \treturn ret;\n }\n \n-static int reftable_be_fsck(struct ref_store *ref_store,\n-\t\t\t    struct fsck_options *o)\n+static int reftable_be_fsck(struct ref_store *ref_store UNUSED,\n+\t\t\t    struct fsck_options *o UNUSED)\n {\n \treturn 0;\n }\n-- \n2.46.0.585.gd6679c16d8\n\n"},{"id":"501192","messageId":"20240817082222.GD10287@coredump.intra.peff.net","threadId":"61967","inReplyTo":"20240817082101.GA6761@coredump.intra.peff.net","subject":"[PATCH 04/15] refs: mark unused parameters in do_for_each_reflog_helper()","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2024-08-17T08:22:22Z","receivedAt":"2024-08-17T08:22:24Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"This is an each_ref_fn callback, so it has to match that interface. We\nmarked most of these in 63e14ee2d6 (refs: mark unused each_ref_fn\nparameters, 2022-08-19), but in this case:\n\n  - this function was created in 31f898397b (refs: drop unused params\n    from the reflog iterator callback, 2024-02-21), and most of the\n    arguments were correctly mark as UNUSED, but \"flags\" was missed.\n\n  - commit e8207717f1 (refs: add referent to each_ref_fn, 2024-08-09)\n    added a new argument to the each_ref_fn callback. In most callbacks\n    it added an UNUSED annotation, but it missed one case.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n refs.c | 5 +++--\n 1 file changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/refs.c b/refs.c\nindex 74de3d3009..584674520e 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -2390,9 +2390,10 @@ struct do_for_each_reflog_help {\n \tvoid *cb_data;\n };\n \n-static int do_for_each_reflog_helper(const char *refname, const char *referent,\n+static int do_for_each_reflog_helper(const char *refname,\n+\t\t\t\t     const char *referent UNUSED,\n \t\t\t\t     const struct object_id *oid UNUSED,\n-\t\t\t\t     int flags,\n+\t\t\t\t     int flags UNUSED,\n \t\t\t\t     void *cb_data)\n {\n \tstruct do_for_each_reflog_help *hp = cb_data;\n-- \n2.46.0.585.gd6679c16d8\n\n"},{"id":"501193","messageId":"20240817082238.GE10287@coredump.intra.peff.net","threadId":"61967","inReplyTo":"20240817082101.GA6761@coredump.intra.peff.net","subject":"[PATCH 05/15] oss-fuzz: mark unused argv/argc argument","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2024-08-17T08:22:38Z","receivedAt":"2024-08-17T08:22:40Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"The dummy fuzz cmd_main() does not look at its argc/argv parameters\n(since it should never even be run), but has to match the usual\ncmd_main() declaration.\n\nMark them to silence -Wunused-parameter.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n oss-fuzz/dummy-cmd-main.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/oss-fuzz/dummy-cmd-main.c b/oss-fuzz/dummy-cmd-main.c\nindex 071cb231ba..8ef776d06f 100644\n--- a/oss-fuzz/dummy-cmd-main.c\n+++ b/oss-fuzz/dummy-cmd-main.c\n@@ -8,7 +8,7 @@\n  * executed.\n  */\n \n-int cmd_main(int argc, const char **argv) {\n+int cmd_main(int argc UNUSED, const char **argv UNUSED) {\n \tBUG(\"We should not execute cmd_main() from a fuzz target\");\n \treturn 1;\n }\n-- \n2.46.0.585.gd6679c16d8\n\n"},{"id":"501194","messageId":"20240817082252.GF10287@coredump.intra.peff.net","threadId":"61967","inReplyTo":"20240817082101.GA6761@coredump.intra.peff.net","subject":"[PATCH 06/15] t/helper: mark more unused argv/argc arguments","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2024-08-17T08:22:52Z","receivedAt":"2024-08-17T08:22:53Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"This is a continuation of 126e3b3d2a (t/helper: mark unused argv/argc\narguments, 2023-03-28) to cover a few new cases:\n\n - test-example-tap was added since that commit\n\n - test-hashmap used to accept the \"ignorecase\" argument on the command\n   line. But since most of its logic was moved to a unit-test in\n   3469a23659 (t: port helper/test-hashmap.c to unit-tests/t-hashmap.c,\n   2024-08-03), it now ignores its argv entirely.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n t/helper/test-example-tap.c | 2 +-\n t/helper/test-hashmap.c     | 2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/t/helper/test-example-tap.c b/t/helper/test-example-tap.c\nindex d072ad559f..f35667bd29 100644\n--- a/t/helper/test-example-tap.c\n+++ b/t/helper/test-example-tap.c\n@@ -70,7 +70,7 @@ static void t_empty(void)\n \t; /* empty */\n }\n \n-int cmd__example_tap(int argc, const char **argv)\n+int cmd__example_tap(int argc UNUSED, const char **argv UNUSED)\n {\n \ttest_res = TEST(check_res = check_int(1, ==, 1), \"passing test\");\n \tTEST(t_res(1), \"passing test and assertion return 1\");\ndiff --git a/t/helper/test-hashmap.c b/t/helper/test-hashmap.c\nindex 195e6278be..7782ae585e 100644\n--- a/t/helper/test-hashmap.c\n+++ b/t/helper/test-hashmap.c\n@@ -138,7 +138,7 @@ static void perf_hashmap(unsigned int method, unsigned int rounds)\n  *\n  * perfhashmap method rounds -> test hashmap.[ch] performance\n  */\n-int cmd__hashmap(int argc, const char **argv)\n+int cmd__hashmap(int argc UNUSED, const char **argv UNUSED)\n {\n \tstruct string_list parts = STRING_LIST_INIT_NODUP;\n \tstruct strbuf line = STRBUF_INIT;\n-- \n2.46.0.585.gd6679c16d8\n\n"},{"id":"501195","messageId":"20240817082309.GG10287@coredump.intra.peff.net","threadId":"61967","inReplyTo":"20240817082101.GA6761@coredump.intra.peff.net","subject":"[PATCH 07/15] unit-tests: ignore unused argc/argv","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2024-08-17T08:23:09Z","receivedAt":"2024-08-17T08:23:11Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"All of the unit test programs have their own cmd_main() function, but\nnone of them actually look at the argc/argv that is passed in.\n\nIn the long run we may want them to handle options for the test harness.\nBut we'd probably do that with a shared harness cmd_main(), dispatching\nto the individual tests. In the meantime, let's annotate the unused\nparameters to avoid triggering -Wunused-parameter.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n t/unit-tests/t-ctype.c           | 2 +-\n t/unit-tests/t-hash.c            | 2 +-\n t/unit-tests/t-mem-pool.c        | 2 +-\n t/unit-tests/t-prio-queue.c      | 2 +-\n t/unit-tests/t-reftable-basics.c | 2 +-\n t/unit-tests/t-reftable-merged.c | 2 +-\n t/unit-tests/t-reftable-pq.c     | 2 +-\n t/unit-tests/t-reftable-record.c | 2 +-\n t/unit-tests/t-reftable-tree.c   | 2 +-\n t/unit-tests/t-strbuf.c          | 2 +-\n t/unit-tests/t-strcmp-offset.c   | 2 +-\n t/unit-tests/t-strvec.c          | 2 +-\n t/unit-tests/t-trailer.c         | 2 +-\n 13 files changed, 13 insertions(+), 13 deletions(-)\n\ndiff --git a/t/unit-tests/t-ctype.c b/t/unit-tests/t-ctype.c\nindex d6ac1fe678..24cc566cfe 100644\n--- a/t/unit-tests/t-ctype.c\n+++ b/t/unit-tests/t-ctype.c\n@@ -33,7 +33,7 @@\n \t\"\\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17\\x18\\x19\\x1a\\x1b\\x1c\\x1d\\x1e\\x1f\" \\\n \t\"\\x7f\"\n \n-int cmd_main(int argc, const char **argv) {\n+int cmd_main(int argc UNUSED, const char **argv UNUSED) {\n \tTEST_CHAR_CLASS(isspace, \" \\n\\r\\t\");\n \tTEST_CHAR_CLASS(isdigit, DIGIT);\n \tTEST_CHAR_CLASS(isalpha, LOWER UPPER);\ndiff --git a/t/unit-tests/t-hash.c b/t/unit-tests/t-hash.c\nindex e9a78bf2c0..e62647019b 100644\n--- a/t/unit-tests/t-hash.c\n+++ b/t/unit-tests/t-hash.c\n@@ -38,7 +38,7 @@ static void check_hash_data(const void *data, size_t data_length,\n \t\t     \"SHA1 and SHA256 (%s) works\", #literal); \\\n \t} while (0)\n \n-int cmd_main(int argc, const char **argv)\n+int cmd_main(int argc UNUSED, const char **argv UNUSED)\n {\n \tstruct strbuf aaaaaaaaaa_100000 = STRBUF_INIT;\n \tstruct strbuf alphabet_100000 = STRBUF_INIT;\ndiff --git a/t/unit-tests/t-mem-pool.c b/t/unit-tests/t-mem-pool.c\nindex a0d57df761..fe500c704b 100644\n--- a/t/unit-tests/t-mem-pool.c\n+++ b/t/unit-tests/t-mem-pool.c\n@@ -20,7 +20,7 @@ static void t_calloc_100(struct mem_pool *pool)\n \tcheck(pool->mp_block->end != NULL);\n }\n \n-int cmd_main(int argc, const char **argv)\n+int cmd_main(int argc UNUSED, const char **argv UNUSED)\n {\n \tTEST(setup_static(t_calloc_100, 1024 * 1024),\n \t     \"mem_pool_calloc returns 100 zeroed bytes with big block\");\ndiff --git a/t/unit-tests/t-prio-queue.c b/t/unit-tests/t-prio-queue.c\nindex 7a4e5780e1..fe6ae37935 100644\n--- a/t/unit-tests/t-prio-queue.c\n+++ b/t/unit-tests/t-prio-queue.c\n@@ -69,7 +69,7 @@ static void test_prio_queue(int *input, size_t input_size,\n #define TEST_INPUT(input, result) \\\n \ttest_prio_queue(input, ARRAY_SIZE(input), result, ARRAY_SIZE(result))\n \n-int cmd_main(int argc, const char **argv)\n+int cmd_main(int argc UNUSED, const char **argv UNUSED)\n {\n \tTEST(TEST_INPUT(((int []){ 2, 6, 3, 10, 9, 5, 7, 4, 5, 8, 1, DUMP }),\n \t\t\t((int []){ 1, 2, 3, 4, 5, 5, 6, 7, 8, 9, 10 })),\ndiff --git a/t/unit-tests/t-reftable-basics.c b/t/unit-tests/t-reftable-basics.c\nindex 4e80bdf16d..7ffee74dca 100644\n--- a/t/unit-tests/t-reftable-basics.c\n+++ b/t/unit-tests/t-reftable-basics.c\n@@ -145,7 +145,7 @@ static void test_u16_roundtrip(void)\n \tcheck_int(in, ==, out);\n }\n \n-int cmd_main(int argc, const char *argv[])\n+int cmd_main(int argc UNUSED, const char *argv[] UNUSED)\n {\n \tTEST(test_common_prefix(), \"common_prefix_size works\");\n \tTEST(test_parse_names_normal(), \"parse_names works for basic input\");\ndiff --git a/t/unit-tests/t-reftable-merged.c b/t/unit-tests/t-reftable-merged.c\nindex b6263ee8b5..2d65d5c3cb 100644\n--- a/t/unit-tests/t-reftable-merged.c\n+++ b/t/unit-tests/t-reftable-merged.c\n@@ -452,7 +452,7 @@ static void t_default_write_opts(void)\n }\n \n \n-int cmd_main(int argc, const char *argv[])\n+int cmd_main(int argc UNUSED, const char *argv[] UNUSED)\n {\n \tTEST(t_default_write_opts(), \"merged table with default write opts\");\n \tTEST(t_merged_logs(), \"merged table with multiple log updates for same ref\");\ndiff --git a/t/unit-tests/t-reftable-pq.c b/t/unit-tests/t-reftable-pq.c\nindex 039bd0f1f9..ada4c19f18 100644\n--- a/t/unit-tests/t-reftable-pq.c\n+++ b/t/unit-tests/t-reftable-pq.c\n@@ -142,7 +142,7 @@ static void t_merged_iter_pqueue_top(void)\n \tmerged_iter_pqueue_release(&pq);\n }\n \n-int cmd_main(int argc, const char *argv[])\n+int cmd_main(int argc UNUSED, const char *argv[] UNUSED)\n {\n \tTEST(t_pq_record(), \"pq works with record-based comparison\");\n \tTEST(t_pq_index(), \"pq works with index-based comparison\");\ndiff --git a/t/unit-tests/t-reftable-record.c b/t/unit-tests/t-reftable-record.c\nindex cb649ee419..a7f67d4d9f 100644\n--- a/t/unit-tests/t-reftable-record.c\n+++ b/t/unit-tests/t-reftable-record.c\n@@ -532,7 +532,7 @@ static void t_reftable_index_record_roundtrip(void)\n \tstrbuf_release(&in.u.idx.last_key);\n }\n \n-int cmd_main(int argc, const char *argv[])\n+int cmd_main(int argc UNUSED, const char *argv[] UNUSED)\n {\n \tTEST(t_reftable_ref_record_comparison(), \"comparison operations work on ref record\");\n \tTEST(t_reftable_log_record_comparison(), \"comparison operations work on log record\");\ndiff --git a/t/unit-tests/t-reftable-tree.c b/t/unit-tests/t-reftable-tree.c\nindex e7d774d774..700479d34b 100644\n--- a/t/unit-tests/t-reftable-tree.c\n+++ b/t/unit-tests/t-reftable-tree.c\n@@ -75,7 +75,7 @@ static void t_infix_walk(void)\n \ttree_free(root);\n }\n \n-int cmd_main(int argc, const char *argv[])\n+int cmd_main(int argc UNUSED, const char *argv[] UNUSED)\n {\n \tTEST(t_tree_search(), \"tree_search works\");\n \tTEST(t_infix_walk(), \"infix_walk works\");\ndiff --git a/t/unit-tests/t-strbuf.c b/t/unit-tests/t-strbuf.c\nindex 6027dafef7..3f4044d697 100644\n--- a/t/unit-tests/t-strbuf.c\n+++ b/t/unit-tests/t-strbuf.c\n@@ -105,7 +105,7 @@ static void t_addstr(struct strbuf *buf, const void *data)\n \tcheck_str(buf->buf + orig_len, text);\n }\n \n-int cmd_main(int argc, const char **argv)\n+int cmd_main(int argc UNUSED, const char **argv UNUSED)\n {\n \tif (!TEST(t_static_init(), \"static initialization works\"))\n \t\ttest_skip_all(\"STRBUF_INIT is broken\");\ndiff --git a/t/unit-tests/t-strcmp-offset.c b/t/unit-tests/t-strcmp-offset.c\nindex fe4c2706b1..6880f21161 100644\n--- a/t/unit-tests/t-strcmp-offset.c\n+++ b/t/unit-tests/t-strcmp-offset.c\n@@ -24,7 +24,7 @@ static void check_strcmp_offset(const char *string1, const char *string2,\n \t\t\t\t expect_offset),                           \\\n \t     \"strcmp_offset(%s, %s) works\", #string1, #string2)\n \n-int cmd_main(int argc, const char **argv)\n+int cmd_main(int argc UNUSED, const char **argv UNUSED)\n {\n \tTEST_STRCMP_OFFSET(\"abc\", \"abc\", 0, 3);\n \tTEST_STRCMP_OFFSET(\"abc\", \"def\", -1, 0);\ndiff --git a/t/unit-tests/t-strvec.c b/t/unit-tests/t-strvec.c\nindex fa1a041469..c3b610dda7 100644\n--- a/t/unit-tests/t-strvec.c\n+++ b/t/unit-tests/t-strvec.c\n@@ -227,7 +227,7 @@ static void t_detach(void)\n \tfree(detached);\n }\n \n-int cmd_main(int argc, const char **argv)\n+int cmd_main(int argc UNUSED, const char **argv UNUSED)\n {\n \tTEST(t_static_init(), \"static initialization\");\n \tTEST(t_dynamic_init(), \"dynamic initialization\");\ndiff --git a/t/unit-tests/t-trailer.c b/t/unit-tests/t-trailer.c\nindex 2ecca359d9..e1c6ad7461 100644\n--- a/t/unit-tests/t-trailer.c\n+++ b/t/unit-tests/t-trailer.c\n@@ -308,7 +308,7 @@ static void run_t_trailer_iterator(void)\n \t}\n }\n \n-int cmd_main(int argc, const char **argv)\n+int cmd_main(int argc UNUSED, const char **argv UNUSED)\n {\n \trun_t_trailer_iterator();\n \treturn test_done();\n-- \n2.46.0.585.gd6679c16d8\n\n"},{"id":"501196","messageId":"20240817082329.GH10287@coredump.intra.peff.net","threadId":"61967","inReplyTo":"20240817082101.GA6761@coredump.intra.peff.net","subject":"[PATCH 08/15] reftable: ignore unused argc/argv in test functions","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2024-08-17T08:23:29Z","receivedAt":"2024-08-17T08:23:30Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"There are several reftable test \"main\" functions that don't look at\ntheir argc/argv. They don't technically need to take these parameters,\nas they are called individually by cmd__reftable(). But it probably\nmakes sense to keep them all consistent for now. In the long run these\nwill probably all get converted to the unit-test framework anyway.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n reftable/block_test.c     | 2 +-\n reftable/readwrite_test.c | 2 +-\n reftable/stack_test.c     | 2 +-\n 3 files changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/reftable/block_test.c b/reftable/block_test.c\nindex 90aecd5a7c..f8e31d2d3c 100644\n--- a/reftable/block_test.c\n+++ b/reftable/block_test.c\n@@ -116,7 +116,7 @@ static void test_block_read_write(void)\n \t}\n }\n \n-int block_test_main(int argc, const char *argv[])\n+int block_test_main(int argc UNUSED, const char *argv[] UNUSED)\n {\n \tRUN_TEST(test_block_read_write);\n \treturn 0;\ndiff --git a/reftable/readwrite_test.c b/reftable/readwrite_test.c\nindex f411abfe9c..15a113b78a 100644\n--- a/reftable/readwrite_test.c\n+++ b/reftable/readwrite_test.c\n@@ -951,7 +951,7 @@ static void test_corrupt_table(void)\n \tstrbuf_release(&buf);\n }\n \n-int readwrite_test_main(int argc, const char *argv[])\n+int readwrite_test_main(int argc UNUSED, const char *argv[] UNUSED)\n {\n \tRUN_TEST(test_log_zlib_corruption);\n \tRUN_TEST(test_corrupt_table);\ndiff --git a/reftable/stack_test.c b/reftable/stack_test.c\nindex 8c36590ff0..f84b92f312 100644\n--- a/reftable/stack_test.c\n+++ b/reftable/stack_test.c\n@@ -1084,7 +1084,7 @@ static void test_reftable_stack_compaction_concurrent_clean(void)\n \tclear_dir(dir);\n }\n \n-int stack_test_main(int argc, const char *argv[])\n+int stack_test_main(int argc UNUSED, const char *argv[] UNUSED)\n {\n \tRUN_TEST(test_empty_add);\n \tRUN_TEST(test_read_file);\n-- \n2.46.0.585.gd6679c16d8\n\n"},{"id":"501197","messageId":"20240817082406.GI10287@coredump.intra.peff.net","threadId":"61967","inReplyTo":"20240817082101.GA6761@coredump.intra.peff.net","subject":"[PATCH 09/15] reftable: drop obsolete test function declarations","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2024-08-17T08:24:06Z","receivedAt":"2024-08-17T08:24:08Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"These functions were moved to the unit test framework in ba9661b457 (t:\nmove reftable/record_test.c to the unit testing framework, 2024-07-02)\nand b34116a30c (t: move reftable/basics_test.c to the unit testing\nframework, 2024-05-29). The declarations in reftable-tests.h are\nleftover cruft.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\nOK, I lied in the cover letter, this one isn't just adding UNUSED. But\nhopefully it is also obviously correct. ;)\n\n reftable/reftable-tests.h | 2 --\n 1 file changed, 2 deletions(-)\n\ndiff --git a/reftable/reftable-tests.h b/reftable/reftable-tests.h\nindex 4b666810af..941e5dd011 100644\n--- a/reftable/reftable-tests.h\n+++ b/reftable/reftable-tests.h\n@@ -9,9 +9,7 @@ license that can be found in the LICENSE file or at\n #ifndef REFTABLE_TESTS_H\n #define REFTABLE_TESTS_H\n \n-int basics_test_main(int argc, const char **argv);\n int block_test_main(int argc, const char **argv);\n-int record_test_main(int argc, const char **argv);\n int readwrite_test_main(int argc, const char **argv);\n int stack_test_main(int argc, const char **argv);\n int reftable_dump_main(int argc, char *const *argv);\n-- \n2.46.0.585.gd6679c16d8\n\n"},{"id":"501198","messageId":"20240817082436.GJ10287@coredump.intra.peff.net","threadId":"61967","inReplyTo":"20240817082101.GA6761@coredump.intra.peff.net","subject":"[PATCH 10/15] reftable: mark unused parameters in virtual functions","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2024-08-17T08:24:36Z","receivedAt":"2024-08-17T08:24:38Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"The reftable code uses a lot of virtual function pointers, but many of\nthe concrete implementations do not need all of the parameters.\n\nFor the most part these are obviously fine to just mark as UNUSED (e.g.,\nthe empty_iterator functions unsurprisingly do not do anything). Here\nare a few cases where I dug a little deeper (but still ended up just\nmarking them UNUSED):\n\n  - the iterator exclude_patterns is best-effort and optional (though it\n    would be nice to support in the long run as an optimization)\n\n  - ignoring the ref_store in many transaction functions is unexpected,\n    but works because the ref_transaction itself carries enough\n    information to do what we need.\n\n  - ignoring \"err\" for in some cases (e.g., transaction abort) is OK\n    because we do not return any errors. It is a little odd for\n    reftable_be_create_reflog(), though, since we do return errors\n    there. We should perhaps be creating string error messages at this\n    layer, but I've punted on that for now.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n refs/reftable-backend.c          | 14 +++++++-------\n reftable/blocksource.c           |  8 ++++----\n reftable/generic.c               |  8 +++++---\n reftable/iter.c                  |  3 ++-\n reftable/record.c                | 31 ++++++++++++++++++-------------\n reftable/stack_test.c            |  4 ++--\n reftable/test_framework.c        |  2 +-\n reftable/writer.c                |  2 +-\n t/unit-tests/t-reftable-merged.c |  2 +-\n 9 files changed, 41 insertions(+), 33 deletions(-)\n\ndiff --git a/refs/reftable-backend.c b/refs/reftable-backend.c\nindex 7337d4422d..a2de39f2ca 100644\n--- a/refs/reftable-backend.c\n+++ b/refs/reftable-backend.c\n@@ -614,7 +614,7 @@ static struct reftable_ref_iterator *ref_iterator_for_stack(struct reftable_ref_\n \n static struct ref_iterator *reftable_be_iterator_begin(struct ref_store *ref_store,\n \t\t\t\t\t\t       const char *prefix,\n-\t\t\t\t\t\t       const char **exclude_patterns,\n+\t\t\t\t\t\t       const char **exclude_patterns UNUSED,\n \t\t\t\t\t\t       unsigned int flags)\n {\n \tstruct reftable_ref_iterator *main_iter, *worktree_iter;\n@@ -1123,9 +1123,9 @@ static int reftable_be_transaction_prepare(struct ref_store *ref_store,\n \treturn ret;\n }\n \n-static int reftable_be_transaction_abort(struct ref_store *ref_store,\n+static int reftable_be_transaction_abort(struct ref_store *ref_store UNUSED,\n \t\t\t\t\t struct ref_transaction *transaction,\n-\t\t\t\t\t struct strbuf *err)\n+\t\t\t\t\t struct strbuf *err UNUSED)\n {\n \tstruct reftable_transaction_data *tx_data = transaction->backend_data;\n \tfree_transaction_data(tx_data);\n@@ -1315,7 +1315,7 @@ static int write_transaction_table(struct reftable_writer *writer, void *cb_data\n \treturn ret;\n }\n \n-static int reftable_be_transaction_finish(struct ref_store *ref_store,\n+static int reftable_be_transaction_finish(struct ref_store *ref_store UNUSED,\n \t\t\t\t\t  struct ref_transaction *transaction,\n \t\t\t\t\t  struct strbuf *err)\n {\n@@ -1726,8 +1726,8 @@ static int reftable_reflog_iterator_advance(struct ref_iterator *ref_iterator)\n \treturn ITER_OK;\n }\n \n-static int reftable_reflog_iterator_peel(struct ref_iterator *ref_iterator,\n-\t\t\t\t\t\t struct object_id *peeled)\n+static int reftable_reflog_iterator_peel(struct ref_iterator *ref_iterator UNUSED,\n+\t\t\t\t\t struct object_id *peeled UNUSED)\n {\n \tBUG(\"reftable reflog iterator cannot be peeled\");\n \treturn -1;\n@@ -1988,7 +1988,7 @@ static int write_reflog_existence_table(struct reftable_writer *writer,\n \n static int reftable_be_create_reflog(struct ref_store *ref_store,\n \t\t\t\t     const char *refname,\n-\t\t\t\t     struct strbuf *errmsg)\n+\t\t\t\t     struct strbuf *errmsg UNUSED)\n {\n \tstruct reftable_ref_store *refs =\n \t\treftable_be_downcast(ref_store, REF_STORE_WRITE, \"create_reflog\");\ndiff --git a/reftable/blocksource.c b/reftable/blocksource.c\nindex eeed254ba9..abce4bb2e1 100644\n--- a/reftable/blocksource.c\n+++ b/reftable/blocksource.c\n@@ -13,14 +13,14 @@ license that can be found in the LICENSE file or at\n #include \"reftable-blocksource.h\"\n #include \"reftable-error.h\"\n \n-static void strbuf_return_block(void *b, struct reftable_block *dest)\n+static void strbuf_return_block(void *b UNUSED, struct reftable_block *dest)\n {\n \tif (dest->len)\n \t\tmemset(dest->data, 0xff, dest->len);\n \treftable_free(dest->data);\n }\n \n-static void strbuf_close(void *b)\n+static void strbuf_close(void *b UNUSED)\n {\n }\n \n@@ -55,7 +55,7 @@ void block_source_from_strbuf(struct reftable_block_source *bs,\n \tbs->arg = buf;\n }\n \n-static void malloc_return_block(void *b, struct reftable_block *dest)\n+static void malloc_return_block(void *b UNUSED, struct reftable_block *dest)\n {\n \tif (dest->len)\n \t\tmemset(dest->data, 0xff, dest->len);\n@@ -85,7 +85,7 @@ static uint64_t file_size(void *b)\n \treturn ((struct file_block_source *)b)->size;\n }\n \n-static void file_return_block(void *b, struct reftable_block *dest)\n+static void file_return_block(void *b UNUSED, struct reftable_block *dest UNUSED)\n {\n }\n \ndiff --git a/reftable/generic.c b/reftable/generic.c\nindex 28ae26145e..a00725d9c4 100644\n--- a/reftable/generic.c\n+++ b/reftable/generic.c\n@@ -201,17 +201,19 @@ int iterator_next(struct reftable_iterator *it, struct reftable_record *rec)\n \treturn it->ops->next(it->iter_arg, rec);\n }\n \n-static int empty_iterator_seek(void *arg, struct reftable_record *want)\n+static int empty_iterator_seek(void *arg UNUSED,\n+\t\t\t       struct reftable_record *want UNUSED)\n {\n \treturn 0;\n }\n \n-static int empty_iterator_next(void *arg, struct reftable_record *rec)\n+static int empty_iterator_next(void *arg UNUSED,\n+\t\t\t       struct reftable_record *rec UNUSED)\n {\n \treturn 1;\n }\n \n-static void empty_iterator_close(void *arg)\n+static void empty_iterator_close(void *arg UNUSED)\n {\n }\n \ndiff --git a/reftable/iter.c b/reftable/iter.c\nindex fddea31e51..9e8b2952fd 100644\n--- a/reftable/iter.c\n+++ b/reftable/iter.c\n@@ -127,7 +127,8 @@ static int indexed_table_ref_iter_next_block(struct indexed_table_ref_iter *it)\n \treturn 0;\n }\n \n-static int indexed_table_ref_iter_seek(void *p, struct reftable_record *want)\n+static int indexed_table_ref_iter_seek(void *p UNUSED,\n+\t\t\t\t       struct reftable_record *want UNUSED)\n {\n \tBUG(\"seeking indexed table is not supported\");\n \treturn -1;\ndiff --git a/reftable/record.c b/reftable/record.c\nindex a2cba5ef74..2ec0c6d346 100644\n--- a/reftable/record.c\n+++ b/reftable/record.c\n@@ -516,7 +516,7 @@ static void reftable_obj_record_release(void *rec)\n \tmemset(obj, 0, sizeof(struct reftable_obj_record));\n }\n \n-static void reftable_obj_record_print(const void *rec, int hash_size)\n+static void reftable_obj_record_print(const void *rec, int hash_size UNUSED)\n {\n \tconst struct reftable_obj_record *obj = rec;\n \tchar hex[GIT_MAX_HEXSZ + 1] = { 0 };\n@@ -532,7 +532,7 @@ static void reftable_obj_record_print(const void *rec, int hash_size)\n }\n \n static void reftable_obj_record_copy_from(void *rec, const void *src_rec,\n-\t\t\t\t\t  int hash_size)\n+\t\t\t\t\t  int hash_size UNUSED)\n {\n \tstruct reftable_obj_record *obj = rec;\n \tconst struct reftable_obj_record *src =\n@@ -559,7 +559,7 @@ static uint8_t reftable_obj_record_val_type(const void *rec)\n }\n \n static int reftable_obj_record_encode(const void *rec, struct string_view s,\n-\t\t\t\t      int hash_size)\n+\t\t\t\t      int hash_size UNUSED)\n {\n \tconst struct reftable_obj_record *r = rec;\n \tstruct string_view start = s;\n@@ -594,7 +594,8 @@ static int reftable_obj_record_encode(const void *rec, struct string_view s,\n \n static int reftable_obj_record_decode(void *rec, struct strbuf key,\n \t\t\t\t      uint8_t val_type, struct string_view in,\n-\t\t\t\t      int hash_size, struct strbuf *scratch UNUSED)\n+\t\t\t\t      int hash_size UNUSED,\n+\t\t\t\t      struct strbuf *scratch UNUSED)\n {\n \tstruct string_view start = in;\n \tstruct reftable_obj_record *r = rec;\n@@ -647,12 +648,13 @@ static int reftable_obj_record_decode(void *rec, struct strbuf key,\n \treturn start.len - in.len;\n }\n \n-static int not_a_deletion(const void *p)\n+static int not_a_deletion(const void *p UNUSED)\n {\n \treturn 0;\n }\n \n-static int reftable_obj_record_equal_void(const void *a, const void *b, int hash_size)\n+static int reftable_obj_record_equal_void(const void *a, const void *b,\n+\t\t\t\t\t  int hash_size UNUSED)\n {\n \tstruct reftable_obj_record *ra = (struct reftable_obj_record *) a;\n \tstruct reftable_obj_record *rb = (struct reftable_obj_record *) b;\n@@ -1066,7 +1068,7 @@ static void reftable_index_record_key(const void *r, struct strbuf *dest)\n }\n \n static void reftable_index_record_copy_from(void *rec, const void *src_rec,\n-\t\t\t\t\t    int hash_size)\n+\t\t\t\t\t    int hash_size UNUSED)\n {\n \tstruct reftable_index_record *dst = rec;\n \tconst struct reftable_index_record *src = src_rec;\n@@ -1082,13 +1084,13 @@ static void reftable_index_record_release(void *rec)\n \tstrbuf_release(&idx->last_key);\n }\n \n-static uint8_t reftable_index_record_val_type(const void *rec)\n+static uint8_t reftable_index_record_val_type(const void *rec UNUSED)\n {\n \treturn 0;\n }\n \n static int reftable_index_record_encode(const void *rec, struct string_view out,\n-\t\t\t\t\tint hash_size)\n+\t\t\t\t\tint hash_size UNUSED)\n {\n \tconst struct reftable_index_record *r =\n \t\t(const struct reftable_index_record *)rec;\n@@ -1104,8 +1106,10 @@ static int reftable_index_record_encode(const void *rec, struct string_view out,\n }\n \n static int reftable_index_record_decode(void *rec, struct strbuf key,\n-\t\t\t\t\tuint8_t val_type, struct string_view in,\n-\t\t\t\t\tint hash_size, struct strbuf *scratch UNUSED)\n+\t\t\t\t\tuint8_t val_type UNUSED,\n+\t\t\t\t\tstruct string_view in,\n+\t\t\t\t\tint hash_size UNUSED,\n+\t\t\t\t\tstruct strbuf *scratch UNUSED)\n {\n \tstruct string_view start = in;\n \tstruct reftable_index_record *r = rec;\n@@ -1122,7 +1126,8 @@ static int reftable_index_record_decode(void *rec, struct strbuf key,\n \treturn start.len - in.len;\n }\n \n-static int reftable_index_record_equal(const void *a, const void *b, int hash_size)\n+static int reftable_index_record_equal(const void *a, const void *b,\n+\t\t\t\t       int hash_size UNUSED)\n {\n \tstruct reftable_index_record *ia = (struct reftable_index_record *) a;\n \tstruct reftable_index_record *ib = (struct reftable_index_record *) b;\n@@ -1137,7 +1142,7 @@ static int reftable_index_record_cmp(const void *_a, const void *_b)\n \treturn strbuf_cmp(&a->last_key, &b->last_key);\n }\n \n-static void reftable_index_record_print(const void *rec, int hash_size)\n+static void reftable_index_record_print(const void *rec, int hash_size UNUSED)\n {\n \tconst struct reftable_index_record *idx = rec;\n \t/* TODO: escape null chars? */\ndiff --git a/reftable/stack_test.c b/reftable/stack_test.c\nindex f84b92f312..1a638cd2e0 100644\n--- a/reftable/stack_test.c\n+++ b/reftable/stack_test.c\n@@ -399,7 +399,7 @@ static void test_reftable_stack_auto_compaction_fails_gracefully(void)\n \tclear_dir(dir);\n }\n \n-static int write_error(struct reftable_writer *wr, void *arg)\n+static int write_error(struct reftable_writer *wr UNUSED, void *arg)\n {\n \treturn *((int *)arg);\n }\n@@ -816,7 +816,7 @@ static void test_reflog_expire(void)\n \treftable_log_record_release(&log);\n }\n \n-static int write_nothing(struct reftable_writer *wr, void *arg)\n+static int write_nothing(struct reftable_writer *wr, void *arg UNUSED)\n {\n \treftable_writer_set_limits(wr, 1, 1);\n \treturn 0;\ndiff --git a/reftable/test_framework.c b/reftable/test_framework.c\nindex 4066924eee..a07fec5d84 100644\n--- a/reftable/test_framework.c\n+++ b/reftable/test_framework.c\n@@ -21,7 +21,7 @@ ssize_t strbuf_add_void(void *b, const void *data, size_t sz)\n \treturn sz;\n }\n \n-int noop_flush(void *arg)\n+int noop_flush(void *arg UNUSED)\n {\n \treturn 0;\n }\ndiff --git a/reftable/writer.c b/reftable/writer.c\nindex 45b3e9ce1f..9d5e6072bc 100644\n--- a/reftable/writer.c\n+++ b/reftable/writer.c\n@@ -544,7 +544,7 @@ static void write_object_record(void *void_arg, void *key)\n done:;\n }\n \n-static void object_record_free(void *void_arg, void *key)\n+static void object_record_free(void *void_arg UNUSED, void *key)\n {\n \tstruct obj_index_tree_node *entry = key;\n \ndiff --git a/t/unit-tests/t-reftable-merged.c b/t/unit-tests/t-reftable-merged.c\nindex 2d65d5c3cb..99f8fcadfe 100644\n--- a/t/unit-tests/t-reftable-merged.c\n+++ b/t/unit-tests/t-reftable-merged.c\n@@ -22,7 +22,7 @@ static ssize_t strbuf_add_void(void *b, const void *data, const size_t sz)\n \treturn sz;\n }\n \n-static int noop_flush(void *arg)\n+static int noop_flush(void *arg UNUSED)\n {\n \treturn 0;\n }\n-- \n2.46.0.585.gd6679c16d8\n\n"},{"id":"501199","messageId":"20240817082447.GK10287@coredump.intra.peff.net","threadId":"61967","inReplyTo":"20240817082101.GA6761@coredump.intra.peff.net","subject":"[PATCH 11/15] t-hashmap: mark unused parameters in callback function","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2024-08-17T08:24:47Z","receivedAt":"2024-08-17T08:24:49Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"The t_intern() setup function doesn't operate on a hashmap, so it\nignores its parameters. But we can't drop them since it is passed as a\npointer to setup(), so we have to match the other setup functions. Mark\nthem to silence -Wunused-parameter.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n t/unit-tests/t-hashmap.c | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/t/unit-tests/t-hashmap.c b/t/unit-tests/t-hashmap.c\nindex 09a48c2c4e..da102eb541 100644\n--- a/t/unit-tests/t-hashmap.c\n+++ b/t/unit-tests/t-hashmap.c\n@@ -322,7 +322,8 @@ static void t_alloc(struct hashmap *map, unsigned int ignore_case)\n \tfree(removed);\n }\n \n-static void t_intern(struct hashmap *map, unsigned int ignore_case)\n+static void t_intern(struct hashmap *map UNUSED,\n+\t\t     unsigned int ignore_case UNUSED)\n {\n \tconst char *values[] = { \"value1\", \"Value1\", \"value2\", \"value2\" };\n \n-- \n2.46.0.585.gd6679c16d8\n\n"},{"id":"501200","messageId":"20240817082503.GL10287@coredump.intra.peff.net","threadId":"61967","inReplyTo":"20240817082101.GA6761@coredump.intra.peff.net","subject":"[PATCH 12/15] test-mergesort: mark unused parameters in trivial callback","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2024-08-17T08:25:03Z","receivedAt":"2024-08-17T08:25:04Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"The mode_copy() function does nothing, but since it's used as a function\npointer within \"struct mode\", it has to conform to the interface. Mark\nit to quiet -Wunused-parameter.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n t/helper/test-mergesort.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/t/helper/test-mergesort.c b/t/helper/test-mergesort.c\nindex 42ccc87051..328bfe2977 100644\n--- a/t/helper/test-mergesort.c\n+++ b/t/helper/test-mergesort.c\n@@ -122,7 +122,7 @@ static const struct dist *get_dist_by_name(const char *name)\n \treturn NULL;\n }\n \n-static void mode_copy(int *arr, int n)\n+static void mode_copy(int *arr UNUSED, int n UNUSED)\n {\n \t/* nothing */\n }\n-- \n2.46.0.585.gd6679c16d8\n\n"},{"id":"501201","messageId":"20240817082516.GM10287@coredump.intra.peff.net","threadId":"61967","inReplyTo":"20240817082101.GA6761@coredump.intra.peff.net","subject":"[PATCH 13/15] setup: mark unused parameter in config callback","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2024-08-17T08:25:16Z","receivedAt":"2024-08-17T08:25:17Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"This is logically a continuation of 783a86c142 (config: mark unused\ncallback parameters, 2022-08-19), but this case was introduced much\nlater in 4412a04fe6 (init.templateDir: consider this config setting\nprotected, 2024-03-29).\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n setup.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/setup.c b/setup.c\nindex 5f81d9fac0..bd44ca21cc 100644\n--- a/setup.c\n+++ b/setup.c\n@@ -1907,7 +1907,7 @@ struct template_dir_cb_data {\n };\n \n static int template_dir_cb(const char *key, const char *value,\n-\t\t\t   const struct config_context *ctx, void *d)\n+\t\t\t   const struct config_context *ctx UNUSED, void *d)\n {\n \tstruct template_dir_cb_data *data = d;\n \n-- \n2.46.0.585.gd6679c16d8\n\n"},{"id":"501202","messageId":"20240817082532.GN10287@coredump.intra.peff.net","threadId":"61967","inReplyTo":"20240817082101.GA6761@coredump.intra.peff.net","subject":"[PATCH 14/15] daemon: mark unused parameters in non-posix fallbacks","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2024-08-17T08:25:32Z","receivedAt":"2024-08-17T08:25:34Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"If NO_POSIX_GOODIES is set, we compile fallback versions of a few\nfunctions. These don't do anything, so their parameters are unused, but\nwe must keep them to match the ones on the other side of the #ifdef.\nMark them to quiet -Wunused-parameter.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n daemon.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/daemon.c b/daemon.c\nindex 17d331b2f3..428a445559 100644\n--- a/daemon.c\n+++ b/daemon.c\n@@ -1175,13 +1175,13 @@ static int service_loop(struct socketlist *socklist)\n \n struct credentials;\n \n-static void drop_privileges(struct credentials *cred)\n+static void drop_privileges(struct credentials *cred UNUSED)\n {\n \t/* nothing */\n }\n \n-static struct credentials *prepare_credentials(const char *user_name,\n-    const char *group_name)\n+static struct credentials *prepare_credentials(const char *user_name UNUSED,\n+\t\t\t\t\t       const char *group_name UNUSED)\n {\n \tdie(\"--user not supported on this platform\");\n }\n-- \n2.46.0.585.gd6679c16d8\n\n"},{"id":"501203","messageId":"20240817082542.GO10287@coredump.intra.peff.net","threadId":"61967","inReplyTo":"20240817082101.GA6761@coredump.intra.peff.net","subject":"[PATCH 15/15] scalar: mark unused parameters in dummy function","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2024-08-17T08:25:42Z","receivedAt":"2024-08-17T08:25:43Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"We have a dummy load_builtin_commands() function to satisfy the linker,\nbut which we never expect to be called. Mark its parameters to avoid\ncomplaints from -Wunused-parameter.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n scalar.c | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/scalar.c b/scalar.c\nindex 1fe8a93e65..6166a8dd4c 100644\n--- a/scalar.c\n+++ b/scalar.c\n@@ -400,7 +400,8 @@ static int delete_enlistment(struct strbuf *enlistment)\n  * Dummy implementation; Using `get_version_info()` would cause a link error\n  * without this.\n  */\n-void load_builtin_commands(const char *prefix, struct cmdnames *cmds)\n+void load_builtin_commands(const char *prefix UNUSED,\n+\t\t\t   struct cmdnames *cmds UNUSED)\n {\n \tdie(\"not implemented\");\n }\n-- \n2.46.0.585.gd6679c16d8\n"},{"id":"501223","messageId":"D3I9DJRMAQD4.UIBX5HG0XYL2@gmail.com","threadId":"61967","inReplyTo":"20240817082447.GK10287@coredump.intra.peff.net","subject":"Re: [PATCH 11/15] t-hashmap: mark unused parameters in callback function","fromName":"Ghanshyam Thakkar","fromEmail":"shyamthakkar001@gmail.com","sentAt":"2024-08-17T14:32:36Z","receivedAt":"2024-08-17T14:32:41Z","isPatch":true,"sender":{"key":"shyamthakkar001@gmail.com","avatar":"https://avatars.githubusercontent.com/u/72698233?v=4"},"body":"Jeff King <peff@peff.net> wrote:\n> The t_intern() setup function doesn't operate on a hashmap, so it\n> ignores its parameters. But we can't drop them since it is passed as a\n> pointer to setup(), so we have to match the other setup functions. Mark\n> them to silence -Wunused-parameter.\n\nSorry, but I didn't understand why we can't drop them and just call\nt_intern() instead of setup(t_intern) (I should've done that, when\nwriting this). By 'other setup functions', do you mean other test\nfunctions which use setup()? I don't think it is necessary to have\nuniformity in function signatures of all the test functions.\n\ndiff --git a/t/unit-tests/t-hashmap.c b/t/unit-tests/t-hashmap.c\nindex 09a48c2c4e..83b79dff39 100644\n--- a/t/unit-tests/t-hashmap.c\n+++ b/t/unit-tests/t-hashmap.c\n@@ -322,7 +322,7 @@ static void t_alloc(struct hashmap *map, unsigned int ignore_case)\n \tfree(removed);\n }\n \n-static void t_intern(struct hashmap *map, unsigned int ignore_case)\n+static void t_intern(void)\n {\n \tconst char *values[] = { \"value1\", \"Value1\", \"value2\", \"value2\" };\n \n@@ -356,6 +356,6 @@ int cmd_main(int argc UNUSED, const char **argv UNUSED)\n \tTEST(setup(t_iterate, 0), \"iterate works\");\n \tTEST(setup(t_iterate, 1), \"iterate (case insensitive) works\");\n \tTEST(setup(t_alloc, 0), \"grow / shrink works\");\n-\tTEST(setup(t_intern, 0), \"string interning works\");\n+\tTEST(t_intern(), \"string interning works\");\n \treturn test_done();\n }\n\nThanks.\n"},{"id":"501228","messageId":"20240817171835.GA2869474@coredump.intra.peff.net","threadId":"61967","inReplyTo":"D3I9DJRMAQD4.UIBX5HG0XYL2@gmail.com","subject":"Re: [PATCH 11/15] t-hashmap: mark unused parameters in callback function","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2024-08-17T17:18:35Z","receivedAt":"2024-08-17T17:18:38Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sat, Aug 17, 2024 at 08:02:36PM +0530, Ghanshyam Thakkar wrote:\n\n> Jeff King <peff@peff.net> wrote:\n> > The t_intern() setup function doesn't operate on a hashmap, so it\n> > ignores its parameters. But we can't drop them since it is passed as a\n> > pointer to setup(), so we have to match the other setup functions. Mark\n> > them to silence -Wunused-parameter.\n> \n> Sorry, but I didn't understand why we can't drop them and just call\n> t_intern() instead of setup(t_intern) (I should've done that, when\n> writing this). By 'other setup functions', do you mean other test\n> functions which use setup()? I don't think it is necessary to have\n> uniformity in function signatures of all the test functions.\n\nI just assumed that setup() was something that should be called for each\ntest. But yeah, looking at it, it is really only creating and cleaning\nup the hashmap. Since t_intern() doesn't need any of that, then it\nshould be OK to just skip setup() entirely.\n\n> -static void t_intern(struct hashmap *map, unsigned int ignore_case)\n> +static void t_intern(void)\n>  {\n>  \tconst char *values[] = { \"value1\", \"Value1\", \"value2\", \"value2\" };\n>  \n> @@ -356,6 +356,6 @@ int cmd_main(int argc UNUSED, const char **argv UNUSED)\n>  \tTEST(setup(t_iterate, 0), \"iterate works\");\n>  \tTEST(setup(t_iterate, 1), \"iterate (case insensitive) works\");\n>  \tTEST(setup(t_alloc, 0), \"grow / shrink works\");\n> -\tTEST(setup(t_intern, 0), \"string interning works\");\n> +\tTEST(t_intern(), \"string interning works\");\n>  \treturn test_done();\n>  }\n\nYeah, that makes sense. I'll update the patch accordingly. Thanks.\n\n-Peff\n"}]}