t/helper: mark unused argv/argc arguments
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>
Jeff King committed
Mar 28, 2023 at 16:57 UTC
126e3b3d2aa06c58994ed09e12cb0a0008897039
27 files changed
+33
-32
t/helper/test-ctype.c
+1
-1
@@ -47,7 +47,7 @@ static int is_in(const char *s, int ch)
47
"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" \
48
"\x7f"
49
50
-int cmd__ctype(int argc, const char **argv)
50
+int cmd__ctype(int argc UNUSED, const char **argv UNUSED)
51
{
52
TEST_CLASS(isdigit, DIGIT);
53
TEST_CLASS(isspace, " \n\r\t");
t/helper/test-date.c
+1
-1
@@ -104,7 +104,7 @@ static void getnanos(const char **argv)
104
printf("%lf\n", seconds);
105
}
106
107
-int cmd__date(int argc, const char **argv)
107
+int cmd__date(int argc UNUSED, const char **argv)
108
{
109
const char *x;
110
t/helper/test-drop-caches.c
+1
-1
@@ -155,7 +155,7 @@ static int cmd_dropcaches(void)
155
156
#endif
157
158
-int cmd__drop_caches(int argc, const char **argv)
158
+int cmd__drop_caches(int argc UNUSED, const char **argv UNUSED)
159
{
160
cmd_sync();
161
return cmd_dropcaches();
t/helper/test-dump-cache-tree.c
+1
-1
@@ -57,7 +57,7 @@ static int dump_cache_tree(struct cache_tree *it,
57
return errs;
58
}
59
60
-int cmd__dump_cache_tree(int ac, const char **av)
60
+int cmd__dump_cache_tree(int ac UNUSED, const char **av UNUSED)
61
{
62
struct index_state istate;
63
struct cache_tree *another = cache_tree();
t/helper/test-dump-fsmonitor.c
+1
-1
@@ -1,7 +1,7 @@
1
#include "test-tool.h"
2
#include "cache.h"
3
4
-int cmd__dump_fsmonitor(int ac, const char **av)
4
+int cmd__dump_fsmonitor(int ac UNUSED, const char **av UNUSED)
5
{
6
struct index_state *istate = the_repository->index;
7
int i;
t/helper/test-dump-split-index.c
+1
-1
@@ -10,7 +10,7 @@ static void show_bit(size_t pos, void *data)
10
printf(" %d", (int)pos);
11
}
12
13
-int cmd__dump_split_index(int ac, const char **av)
13
+int cmd__dump_split_index(int ac UNUSED, const char **av)
14
{
15
struct split_index *si;
16
int i;
t/helper/test-dump-untracked-cache.c
+1
-1
@@ -41,7 +41,7 @@ static void dump(struct untracked_cache_dir *ucd, struct strbuf *base)
41
strbuf_setlen(base, len);
42
}
43
44
-int cmd__dump_untracked_cache(int ac, const char **av)
44
+int cmd__dump_untracked_cache(int ac UNUSED, const char **av UNUSED)
45
{
46
struct untracked_cache *uc;
47
struct strbuf base = STRBUF_INIT;
t/helper/test-example-decorate.c
+1
-1
@@ -3,7 +3,7 @@
3
#include "object.h"
4
#include "decorate.h"
5
6
-int cmd__example_decorate(int argc, const char **argv)
6
+int cmd__example_decorate(int argc UNUSED, const char **argv UNUSED)
7
{
8
struct decoration n;
9
struct object_id one_oid = { {1} };
t/helper/test-fsmonitor-client.c
+1
-1
@@ -11,7 +11,7 @@
11
#include "trace2.h"
12
13
#ifndef HAVE_FSMONITOR_DAEMON_BACKEND
14
-int cmd__fsmonitor_client(int argc, const char **argv)
14
+int cmd__fsmonitor_client(int argc UNUSED, const char **argv UNUSED)
15
{
16
die("fsmonitor--daemon not available on this platform");
17
}
t/helper/test-hexdump.c
+1
-1
@@ -4,7 +4,7 @@
4
/*
5
* Read stdin and print a hexdump to stdout.
6
*/
7
-int cmd__hexdump(int argc, const char **argv)
7
+int cmd__hexdump(int argc UNUSED, const char **argv UNUSED)
8
{
9
char buf[1024];
10
ssize_t i, len;
t/helper/test-index-version.c
+1
-1
@@ -1,7 +1,7 @@
1
#include "test-tool.h"
2
#include "cache.h"
3
4
-int cmd__index_version(int argc, const char **argv)
4
+int cmd__index_version(int argc UNUSED, const char **argv UNUSED)
5
{
6
struct cache_header hdr;
7
int version;
t/helper/test-match-trees.c
+1
-1
@@ -3,7 +3,7 @@
3
#include "hex.h"
4
#include "tree.h"
5
6
-int cmd__match_trees(int ac, const char **av)
6
+int cmd__match_trees(int ac UNUSED, const char **av)
7
{
8
struct object_id hash1, hash2, shifted;
9
struct tree *one, *two;
t/helper/test-oid-array.c
+1
-1
@@ -9,7 +9,7 @@ static int print_oid(const struct object_id *oid, void *data)
9
return 0;
10
}
11
12
-int cmd__oid_array(int argc, const char **argv)
12
+int cmd__oid_array(int argc UNUSED, const char **argv UNUSED)
13
{
14
struct oid_array array = OID_ARRAY_INIT;
15
struct strbuf line = STRBUF_INIT;
t/helper/test-oidmap.c
+1
-1
@@ -22,7 +22,7 @@ struct test_entry {
22
* iterate -> oidkey1 namevalue1\noidkey2 namevalue2\n...
23
*
24
*/
25
-int cmd__oidmap(int argc, const char **argv)
25
+int cmd__oidmap(int argc UNUSED, const char **argv UNUSED)
26
{
27
struct strbuf line = STRBUF_INIT;
28
struct oidmap map = OIDMAP_INIT;
t/helper/test-oidtree.c
+2
-2
@@ -3,13 +3,13 @@
3
#include "hex.h"
4
#include "oidtree.h"
5
6
-static enum cb_next print_oid(const struct object_id *oid, void *data)
6
+static enum cb_next print_oid(const struct object_id *oid, void *data UNUSED)
7
{
8
puts(oid_to_hex(oid));
9
return CB_CONTINUE;
10
}
11
12
-int cmd__oidtree(int argc, const char **argv)
12
+int cmd__oidtree(int argc UNUSED, const char **argv UNUSED)
13
{
14
struct oidtree ot;
15
struct strbuf line = STRBUF_INIT;
t/helper/test-online-cpus.c
+1
-1
@@ -2,7 +2,7 @@
2
#include "git-compat-util.h"
3
#include "thread-utils.h"
4
5
-int cmd__online_cpus(int argc, const char **argv)
5
+int cmd__online_cpus(int argc UNUSED, const char **argv UNUSED)
6
{
7
printf("%d\n", online_cpus());
8
return 0;
t/helper/test-parse-options.c
+2
-2
@@ -263,14 +263,14 @@ int cmd__parse_options_flags(int argc, const char **argv)
263
return parse_options_flags__cmd(argc, argv, test_flags);
264
}
265
266
-static int subcmd_one(int argc, const char **argv, const char *prefix)
266
+static int subcmd_one(int argc, const char **argv, const char *prefix UNUSED)
267
{
268
printf("fn: subcmd_one\n");
269
print_args(argc, argv);
270
return 0;
271
}
272
273
-static int subcmd_two(int argc, const char **argv, const char *prefix)
273
+static int subcmd_two(int argc, const char **argv, const char *prefix UNUSED)
274
{
275
printf("fn: subcmd_two\n");
276
print_args(argc, argv);
t/helper/test-prio-queue.c
+1
-1
@@ -16,7 +16,7 @@ static void show(int *v)
16
free(v);
17
}
18
19
-int cmd__prio_queue(int argc, const char **argv)
19
+int cmd__prio_queue(int argc UNUSED, const char **argv)
20
{
21
struct prio_queue pq = { intcmp };
22
t/helper/test-read-graph.c
+1
-1
@@ -5,7 +5,7 @@
5
#include "object-store.h"
6
#include "bloom.h"
7
8
-int cmd__read_graph(int argc, const char **argv)
8
+int cmd__read_graph(int argc UNUSED, const char **argv UNUSED)
9
{
10
struct commit_graph *graph = NULL;
11
struct object_directory *odb;
t/helper/test-ref-store.c
+3
-2
@@ -201,7 +201,8 @@ static int cmd_verify_ref(struct ref_store *refs, const char **argv)
201
return ret;
202
}
203
204
-static int cmd_for_each_reflog(struct ref_store *refs, const char **argv)
204
+static int cmd_for_each_reflog(struct ref_store *refs,
205
+ const char **argv UNUSED)
206
{
207
return refs_for_each_reflog(refs, each_ref, NULL);
208
}
@@ -323,7 +324,7 @@ static struct command commands[] = {
324
{ NULL, NULL }
325
};
326
326
-int cmd__ref_store(int argc, const char **argv)
327
+int cmd__ref_store(int argc UNUSED, const char **argv)
328
{
329
struct ref_store *refs;
330
const char *func;
t/helper/test-scrap-cache-tree.c
+1
-1
@@ -5,7 +5,7 @@
5
#include "tree.h"
6
#include "cache-tree.h"
7
8
-int cmd__scrap_cache_tree(int ac, const char **av)
8
+int cmd__scrap_cache_tree(int ac UNUSED, const char **av UNUSED)
9
{
10
struct lock_file index_lock = LOCK_INIT;
11
t/helper/test-sigchain.c
+1
-1
@@ -13,7 +13,7 @@ X(two)
13
X(three)
14
#undef X
15
16
-int cmd__sigchain(int argc, const char **argv)
16
+int cmd__sigchain(int argc UNUSED, const char **argv UNUSED)
17
{
18
sigchain_push(SIGTERM, one);
19
sigchain_push(SIGTERM, two);
t/helper/test-strcmp-offset.c
+1
-1
@@ -1,7 +1,7 @@
1
#include "test-tool.h"
2
#include "cache.h"
3
4
-int cmd__strcmp_offset(int argc, const char **argv)
4
+int cmd__strcmp_offset(int argc UNUSED, const char **argv)
5
{
6
int result;
7
size_t offset;
t/helper/test-submodule-config.c
+1
-1
@@ -4,7 +4,7 @@
4
#include "submodule-config.h"
5
#include "submodule.h"
6
7
-static void die_usage(int argc, const char **argv, const char *msg)
7
+static void die_usage(int argc UNUSED, const char **argv, const char *msg)
8
{
9
fprintf(stderr, "%s\n", msg);
10
fprintf(stderr, "Usage: %s [<commit> <submodulepath>] ...\n", argv[0]);
t/helper/test-submodule.c
+1
-1
@@ -174,7 +174,7 @@ static int cmd__submodule_config_unset(int argc, const char **argv)
174
usage_with_options(usage, options);
175
}
176
177
-static int cmd__submodule_config_writeable(int argc, const char **argv)
177
+static int cmd__submodule_config_writeable(int argc, const char **argv UNUSED)
178
{
179
struct option options[] = {
180
OPT_END()
t/helper/test-trace2.c
+3
-3
@@ -208,7 +208,7 @@ static int ut_007BUG(int argc, const char **argv)
208
BUG("the bug message");
209
}
210
211
-static int ut_008bug(int argc, const char **argv)
211
+static int ut_008bug(int argc UNUSED, const char **argv UNUSED)
212
{
213
bug("a bug message");
214
bug("another bug message");
@@ -216,7 +216,7 @@ static int ut_008bug(int argc, const char **argv)
216
return 0;
217
}
218
219
-static int ut_009bug_BUG(int argc, const char **argv)
219
+static int ut_009bug_BUG(int argc UNUSED, const char **argv UNUSED)
220
{
221
bug("a bug message");
222
bug("another bug message");
@@ -224,7 +224,7 @@ static int ut_009bug_BUG(int argc, const char **argv)
224
return 0;
225
}
226
227
-static int ut_010bug_BUG(int argc, const char **argv)
227
+static int ut_010bug_BUG(int argc UNUSED, const char **argv UNUSED)
228
{
229
bug("a %s message", "bug");
230
BUG("a %s message", "BUG");
t/helper/test-xml-encode.c
+1
-1
@@ -6,7 +6,7 @@ static const char *utf8_replace_character = "�";
6
* Encodes (possibly incorrect) UTF-8 on <stdin> to <stdout>, to be embedded
7
* in an XML file.
8
*/
9
-int cmd__xml_encode(int argc, const char **argv)
9
+int cmd__xml_encode(int argc UNUSED, const char **argv UNUSED)
10
{
11
unsigned char buf[1024], tmp[4], *tmp2 = NULL;
12
ssize_t cur = 0, len = 1, remaining = 0;