]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t/helper: mark unused argv/argc arguments
authorJeff King <peff@peff.net>
Tue, 28 Mar 2023 20:57:25 +0000 (16:57 -0400)
committerJunio C Hamano <gitster@pobox.com>
Tue, 28 Mar 2023 21:11:24 +0000 (14:11 -0700)
Many test helper programs do not bother to look at argc or argv, because
they don't take any options. In a user-facing program, it's a good idea
to check for unexpected arguments and complain. But for a test helper,
it's not worth the trouble to enforce this.

But we do want to tell the compiler we're OK with ignoring them, to
silence -Wunused-parameter (and obviously we can't get rid of them,
since we have to conform to the usual cmd__foo() interface).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
27 files changed:
t/helper/test-ctype.c
t/helper/test-date.c
t/helper/test-drop-caches.c
t/helper/test-dump-cache-tree.c
t/helper/test-dump-fsmonitor.c
t/helper/test-dump-split-index.c
t/helper/test-dump-untracked-cache.c
t/helper/test-example-decorate.c
t/helper/test-fsmonitor-client.c
t/helper/test-hexdump.c
t/helper/test-index-version.c
t/helper/test-match-trees.c
t/helper/test-oid-array.c
t/helper/test-oidmap.c
t/helper/test-oidtree.c
t/helper/test-online-cpus.c
t/helper/test-parse-options.c
t/helper/test-prio-queue.c
t/helper/test-read-graph.c
t/helper/test-ref-store.c
t/helper/test-scrap-cache-tree.c
t/helper/test-sigchain.c
t/helper/test-strcmp-offset.c
t/helper/test-submodule-config.c
t/helper/test-submodule.c
t/helper/test-trace2.c
t/helper/test-xml-encode.c

index 534ca66441cd686f93b36f998bc4eb867d388f4b..71a1a5c9b04125933e368cb489f933f3fd8f6cab 100644 (file)
@@ -47,7 +47,7 @@ static int is_in(const char *s, int ch)
        "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" \
        "\x7f"
 
-int cmd__ctype(int argc, const char **argv)
+int cmd__ctype(int argc UNUSED, const char **argv UNUSED)
 {
        TEST_CLASS(isdigit, DIGIT);
        TEST_CLASS(isspace, " \n\r\t");
index 45951b1df87c7bf90a25cc1497344681ae42a161..cd6a6df7023269b195dc9da9d8ec28fc83603bf8 100644 (file)
@@ -104,7 +104,7 @@ static void getnanos(const char **argv)
        printf("%lf\n", seconds);
 }
 
-int cmd__date(int argc, const char **argv)
+int cmd__date(int argc UNUSED, const char **argv)
 {
        const char *x;
 
index e37396dd9c2c2fe01b9bf2acc8d6a2c6456869fc..73e551cfc222695c31bfc6897d12dc025c87b439 100644 (file)
@@ -155,7 +155,7 @@ static int cmd_dropcaches(void)
 
 #endif
 
-int cmd__drop_caches(int argc, const char **argv)
+int cmd__drop_caches(int argc UNUSED, const char **argv UNUSED)
 {
        cmd_sync();
        return cmd_dropcaches();
index 92dfc1aa8c4a9e37e4c26c419ea8fcf640399182..ba1c5ce71750e2244af13006331ad4b80d503873 100644 (file)
@@ -57,7 +57,7 @@ static int dump_cache_tree(struct cache_tree *it,
        return errs;
 }
 
-int cmd__dump_cache_tree(int ac, const char **av)
+int cmd__dump_cache_tree(int ac UNUSED, const char **av UNUSED)
 {
        struct index_state istate;
        struct cache_tree *another = cache_tree();
index 975f0ac8905125f01ce37be5b7bc862cf058fbcf..3d2fb92ade89c59b4bc1775b84f12014ef2e8a8a 100644 (file)
@@ -1,7 +1,7 @@
 #include "test-tool.h"
 #include "cache.h"
 
-int cmd__dump_fsmonitor(int ac, const char **av)
+int cmd__dump_fsmonitor(int ac UNUSED, const char **av UNUSED)
 {
        struct index_state *istate = the_repository->index;
        int i;
index 813d0a38fae206587438c609cf0282f9f3c6a6aa..4fabbdea4962252207c41007c21ffec242744d3e 100644 (file)
@@ -10,7 +10,7 @@ static void show_bit(size_t pos, void *data)
        printf(" %d", (int)pos);
 }
 
-int cmd__dump_split_index(int ac, const char **av)
+int cmd__dump_split_index(int ac UNUSED, const char **av)
 {
        struct split_index *si;
        int i;
index af953fabe871cc1bc0d4a3999942a9113a6f1f2a..bc1ef8d4dc0f3c331bd150ba51c001548cbf7c8e 100644 (file)
@@ -41,7 +41,7 @@ static void dump(struct untracked_cache_dir *ucd, struct strbuf *base)
        strbuf_setlen(base, len);
 }
 
-int cmd__dump_untracked_cache(int ac, const char **av)
+int cmd__dump_untracked_cache(int ac UNUSED, const char **av UNUSED)
 {
        struct untracked_cache *uc;
        struct strbuf base = STRBUF_INIT;
index 7c7fc8efc13d458df6745fb44804c8f92b4a9a9c..2cf302ffcb3be7d82be344ce276879dded42d81a 100644 (file)
@@ -3,7 +3,7 @@
 #include "object.h"
 #include "decorate.h"
 
-int cmd__example_decorate(int argc, const char **argv)
+int cmd__example_decorate(int argc UNUSED, const char **argv UNUSED)
 {
        struct decoration n;
        struct object_id one_oid = { {1} };
index 54a4856c48c55af0af4e3ffe7cc3a62dce993842..0a1e492e5bcfc163242600a5c196f69d65973692 100644 (file)
@@ -11,7 +11,7 @@
 #include "trace2.h"
 
 #ifndef HAVE_FSMONITOR_DAEMON_BACKEND
-int cmd__fsmonitor_client(int argc, const char **argv)
+int cmd__fsmonitor_client(int argc UNUSED, const char **argv UNUSED)
 {
        die("fsmonitor--daemon not available on this platform");
 }
index 811e89c1bcb0289e63588c2dbb801f34982cbc56..05f55eca21afb8792d60498fd9e1fc88d5499a72 100644 (file)
@@ -4,7 +4,7 @@
 /*
  * Read stdin and print a hexdump to stdout.
  */
-int cmd__hexdump(int argc, const char **argv)
+int cmd__hexdump(int argc UNUSED, const char **argv UNUSED)
 {
        char buf[1024];
        ssize_t i, len;
index fcd10968cc10bdab8db146b8ba65080431e5ed24..a06c45c1f8477724125fe612dffaa85816f4b02f 100644 (file)
@@ -1,7 +1,7 @@
 #include "test-tool.h"
 #include "cache.h"
 
-int cmd__index_version(int argc, const char **argv)
+int cmd__index_version(int argc UNUSED, const char **argv UNUSED)
 {
        struct cache_header hdr;
        int version;
index 04bc2563f3e5b96fcd12867f7b5743571046971e..184aa1a08700437b8b604f0387097d11c5020bd1 100644 (file)
@@ -3,7 +3,7 @@
 #include "hex.h"
 #include "tree.h"
 
-int cmd__match_trees(int ac, const char **av)
+int cmd__match_trees(int ac UNUSED, const char **av)
 {
        struct object_id hash1, hash2, shifted;
        struct tree *one, *two;
index 0906993ad59bfcd0a4f3e20f8c1a1a0bff737a59..c3a1a00466a5fa83b5ffbf1a541de40d4d210ece 100644 (file)
@@ -9,7 +9,7 @@ static int print_oid(const struct object_id *oid, void *data)
        return 0;
 }
 
-int cmd__oid_array(int argc, const char **argv)
+int cmd__oid_array(int argc UNUSED, const char **argv UNUSED)
 {
        struct oid_array array = OID_ARRAY_INIT;
        struct strbuf line = STRBUF_INIT;
index 883d40efd45edc16fe486d2ad5228590451b8071..ee92ae84949aff9f28a2306b1614d1b81234482e 100644 (file)
@@ -22,7 +22,7 @@ struct test_entry {
  * iterate -> oidkey1 namevalue1\noidkey2 namevalue2\n...
  *
  */
-int cmd__oidmap(int argc, const char **argv)
+int cmd__oidmap(int argc UNUSED, const char **argv UNUSED)
 {
        struct strbuf line = STRBUF_INIT;
        struct oidmap map = OIDMAP_INIT;
index 0b82431a70fe99cb59e1729fae49eacd4920878e..6a18e1bce807f2d854a6cfdf26a2c5cf4f7f021d 100644 (file)
@@ -3,13 +3,13 @@
 #include "hex.h"
 #include "oidtree.h"
 
-static enum cb_next print_oid(const struct object_id *oid, void *data)
+static enum cb_next print_oid(const struct object_id *oid, void *data UNUSED)
 {
        puts(oid_to_hex(oid));
        return CB_CONTINUE;
 }
 
-int cmd__oidtree(int argc, const char **argv)
+int cmd__oidtree(int argc UNUSED, const char **argv UNUSED)
 {
        struct oidtree ot;
        struct strbuf line = STRBUF_INIT;
index 8cb0d53840f3dc60d583fa1b72f95572d2148d11..47dc21171125cde0bd67877517b53a26e8a289eb 100644 (file)
@@ -2,7 +2,7 @@
 #include "git-compat-util.h"
 #include "thread-utils.h"
 
-int cmd__online_cpus(int argc, const char **argv)
+int cmd__online_cpus(int argc UNUSED, const char **argv UNUSED)
 {
        printf("%d\n", online_cpus());
        return 0;
index 506835521a463aebd1a06259cf96e05d71e3833b..b66039e57519980de76c0b204c74286a3bd600a7 100644 (file)
@@ -263,14 +263,14 @@ int cmd__parse_options_flags(int argc, const char **argv)
        return parse_options_flags__cmd(argc, argv, test_flags);
 }
 
-static int subcmd_one(int argc, const char **argv, const char *prefix)
+static int subcmd_one(int argc, const char **argv, const char *prefix UNUSED)
 {
        printf("fn: subcmd_one\n");
        print_args(argc, argv);
        return 0;
 }
 
-static int subcmd_two(int argc, const char **argv, const char *prefix)
+static int subcmd_two(int argc, const char **argv, const char *prefix UNUSED)
 {
        printf("fn: subcmd_two\n");
        print_args(argc, argv);
index 4915412e074691f6ddf3396d0ca45dd6b03588ad..f0bf255f5f0581d91b5f189dbf06f9b3cf910cc9 100644 (file)
@@ -16,7 +16,7 @@ static void show(int *v)
        free(v);
 }
 
-int cmd__prio_queue(int argc, const char **argv)
+int cmd__prio_queue(int argc UNUSED, const char **argv)
 {
        struct prio_queue pq = { intcmp };
 
index 98b73bb8f25aabea7384cde0fb639cff16cf631e..f92aea9d1fd7327efb754fcf190ff802c33960f2 100644 (file)
@@ -5,7 +5,7 @@
 #include "object-store.h"
 #include "bloom.h"
 
-int cmd__read_graph(int argc, const char **argv)
+int cmd__read_graph(int argc UNUSED, const char **argv UNUSED)
 {
        struct commit_graph *graph = NULL;
        struct object_directory *odb;
index 1745b088b7c2b924b006bf90e02ae4677b0cc30d..31c79a777a05c8889548d34f9f853383b1e64b9d 100644 (file)
@@ -201,7 +201,8 @@ static int cmd_verify_ref(struct ref_store *refs, const char **argv)
        return ret;
 }
 
-static int cmd_for_each_reflog(struct ref_store *refs, const char **argv)
+static int cmd_for_each_reflog(struct ref_store *refs,
+                              const char **argv UNUSED)
 {
        return refs_for_each_reflog(refs, each_ref, NULL);
 }
@@ -323,7 +324,7 @@ static struct command commands[] = {
        { NULL, NULL }
 };
 
-int cmd__ref_store(int argc, const char **argv)
+int cmd__ref_store(int argc UNUSED, const char **argv)
 {
        struct ref_store *refs;
        const char *func;
index a26107ed70ac023da79a573bf0d87cdad95016d0..8a42c475b3b8eabeb8026361e15bb26a75446108 100644 (file)
@@ -5,7 +5,7 @@
 #include "tree.h"
 #include "cache-tree.h"
 
-int cmd__scrap_cache_tree(int ac, const char **av)
+int cmd__scrap_cache_tree(int ac UNUSED, const char **av UNUSED)
 {
        struct lock_file index_lock = LOCK_INIT;
 
index d1cf7377b7c60e0259f747a334983563b6c86715..2d5ecf738317e7a8a3897bc5ff5a7cc0e51de2da 100644 (file)
@@ -13,7 +13,7 @@ X(two)
 X(three)
 #undef X
 
-int cmd__sigchain(int argc, const char **argv)
+int cmd__sigchain(int argc UNUSED, const char **argv UNUSED)
 {
        sigchain_push(SIGTERM, one);
        sigchain_push(SIGTERM, two);
index 44e4a6d143e24cbd05b5d94404a5f5d4e732c880..96b9a5b5291a637a7effff289ecf1d96860e6c24 100644 (file)
@@ -1,7 +1,7 @@
 #include "test-tool.h"
 #include "cache.h"
 
-int cmd__strcmp_offset(int argc, const char **argv)
+int cmd__strcmp_offset(int argc UNUSED, const char **argv)
 {
        int result;
        size_t offset;
index 22a41c409263c077843598e4cc51881a52b0ce30..edeee41abdd9df82443afe4cae359c082b671b7b 100644 (file)
@@ -4,7 +4,7 @@
 #include "submodule-config.h"
 #include "submodule.h"
 
-static void die_usage(int argc, const char **argv, const char *msg)
+static void die_usage(int argc UNUSED, const char **argv, const char *msg)
 {
        fprintf(stderr, "%s\n", msg);
        fprintf(stderr, "Usage: %s [<commit> <submodulepath>] ...\n", argv[0]);
index e060cc6226895d750ced2cab19cedb46f97843b9..3b75358723cc109f5fe7441d9bd115f09730516a 100644 (file)
@@ -174,7 +174,7 @@ static int cmd__submodule_config_unset(int argc, const char **argv)
        usage_with_options(usage, options);
 }
 
-static int cmd__submodule_config_writeable(int argc, const char **argv)
+static int cmd__submodule_config_writeable(int argc, const char **argv UNUSED)
 {
        struct option options[] = {
                OPT_END()
index f374c21ec32ecc049bace6821d5630e103b8937c..688c8d017db3d17551f1e9b8e2d8c79f0f653e1c 100644 (file)
@@ -208,7 +208,7 @@ static int ut_007BUG(int argc, const char **argv)
        BUG("the bug message");
 }
 
-static int ut_008bug(int argc, const char **argv)
+static int ut_008bug(int argc UNUSED, const char **argv UNUSED)
 {
        bug("a bug message");
        bug("another bug message");
@@ -216,7 +216,7 @@ static int ut_008bug(int argc, const char **argv)
        return 0;
 }
 
-static int ut_009bug_BUG(int argc, const char **argv)
+static int ut_009bug_BUG(int argc UNUSED, const char **argv UNUSED)
 {
        bug("a bug message");
        bug("another bug message");
@@ -224,7 +224,7 @@ static int ut_009bug_BUG(int argc, const char **argv)
        return 0;
 }
 
-static int ut_010bug_BUG(int argc, const char **argv)
+static int ut_010bug_BUG(int argc UNUSED, const char **argv UNUSED)
 {
        bug("a %s message", "bug");
        BUG("a %s message", "BUG");
index a648bbd961c2361ea8fa2385cb3f63a002e634c3..b2f330d1a44542065a8fc79e9eb6bf2b9f5ed8a9 100644 (file)
@@ -6,7 +6,7 @@ static const char *utf8_replace_character = "&#xfffd;";
  * Encodes (possibly incorrect) UTF-8 on <stdin> to <stdout>, to be embedded
  * in an XML file.
  */
-int cmd__xml_encode(int argc, const char **argv)
+int cmd__xml_encode(int argc UNUSED, const char **argv UNUSED)
 {
        unsigned char buf[1024], tmp[4], *tmp2 = NULL;
        ssize_t cur = 0, len = 1, remaining = 0;