From e885a84f1bc660adfc1dea5f6c25d0a92c7c9dbc Mon Sep 17 00:00:00 2001 From: Jeff King Date: Wed, 30 Sep 2020 08:28:18 -0400 Subject: drop unused argc parameters Many functions take an argv/argc pair, but never actually look at argc. This makes it useless at best (we use the NULL sentinel in argv to find the end of the array), and misleading at worst (what happens if the argc count does not match the argv NULL?). In each of these instances, the argv NULL does match the argc count, so there are no bugs here. But let's tighten the interfaces to make it harder to get wrong (and to reduce some -Wunused-parameter complaints). Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/helper/test-submodule-nested-repo-config.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 't/helper') diff --git a/t/helper/test-submodule-nested-repo-config.c b/t/helper/test-submodule-nested-repo-config.c index bc97929bbc..c5fd4527dc 100644 --- a/t/helper/test-submodule-nested-repo-config.c +++ b/t/helper/test-submodule-nested-repo-config.c @@ -1,7 +1,7 @@ #include "test-tool.h" #include "submodule-config.h" -static void die_usage(int argc, const char **argv, const char *msg) +static void die_usage(const char **argv, const char *msg) { fprintf(stderr, "%s\n", msg); fprintf(stderr, "Usage: %s \n", argv[0]); @@ -14,13 +14,13 @@ int cmd__submodule_nested_repo_config(int argc, const char **argv) const struct submodule *sub; if (argc < 3) - die_usage(argc, argv, "Wrong number of arguments."); + die_usage(argv, "Wrong number of arguments."); setup_git_directory(); sub = submodule_from_path(the_repository, &null_oid, argv[1]); if (repo_submodule_init(&subrepo, the_repository, sub)) { - die_usage(argc, argv, "Submodule not found."); + die_usage(argv, "Submodule not found."); } /* Read the config of _child_ submodules. */ -- cgit v1.2.3 From 26e28fe7bbdf8b22ed096dfd76a9311e86ffb200 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Wed, 30 Sep 2020 08:30:27 -0400 Subject: test-advise: check argument count with argc instead of argv We complain if "test-tool advise" is not given an argument, but we quietly ignore any additional arguments it receives. Let's instead check that we got the expected number. As a bonus, this silences -Wunused-parameter, which notes that we don't ever look at argc. While we're here, we can also fix the indentation in the conditional. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/helper/test-advise.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 't/helper') diff --git a/t/helper/test-advise.c b/t/helper/test-advise.c index 38cdc2884e..a7043df1d3 100644 --- a/t/helper/test-advise.c +++ b/t/helper/test-advise.c @@ -5,8 +5,8 @@ int cmd__advise_if_enabled(int argc, const char **argv) { - if (!argv[1]) - die("usage: %s ", argv[0]); + if (argc != 2) + die("usage: %s ", argv[0]); setup_git_directory(); git_config(git_default_config, NULL); -- cgit v1.2.3