submodule--helper: drop unused argc from module_list_compute()
The module_list_compute() function takes an argc/argv pair, but never looks at argc. This is OK, as the NULL terminator in argv is sufficient for our purposes (we feed it to parse_pathspec(), which takes only the array, not a count). Note that one of the callers _looks_ like it would be buggy, but isn't: we pass 0/NULL for argc/argv from module_foreach(), so finding the terminating NULL in that argv naively would segfault. However, parse_pathspec() is smart enough to interpret a bare NULL as an empty argv. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Oct 17, 2022 at 21:02 UTC
70aa1d7576830c5efa93953ccded77deb0d7eb25
1 file changed
+9
-9
builtin/submodule--helper.c
+9
-9
@@ -181,7 +181,7 @@ static void module_list_release(struct module_list *ml)
181
free(ml->entries);
182
}
183
184
-static int module_list_compute(int argc, const char **argv,
184
+static int module_list_compute(const char **argv,
185
const char *prefix,
186
struct pathspec *pathspec,
187
struct module_list *list)
@@ -405,7 +405,7 @@ static int module_foreach(int argc, const char **argv, const char *prefix)
405
argc = parse_options(argc, argv, prefix, module_foreach_options,
406
git_submodule_helper_usage, 0);
407
408
- if (module_list_compute(0, NULL, prefix, &pathspec, &list) < 0)
408
+ if (module_list_compute(NULL, prefix, &pathspec, &list) < 0)
409
goto cleanup;
410
411
info.argc = argc;
@@ -545,7 +545,7 @@ static int module_init(int argc, const char **argv, const char *prefix)
545
argc = parse_options(argc, argv, prefix, module_init_options,
546
git_submodule_helper_usage, 0);
547
548
- if (module_list_compute(argc, argv, prefix, &pathspec, &list) < 0)
548
+ if (module_list_compute(argv, prefix, &pathspec, &list) < 0)
549
goto cleanup;
550
551
/*
@@ -732,7 +732,7 @@ static int module_status(int argc, const char **argv, const char *prefix)
732
argc = parse_options(argc, argv, prefix, module_status_options,
733
git_submodule_helper_usage, 0);
734
735
- if (module_list_compute(argc, argv, prefix, &pathspec, &list) < 0)
735
+ if (module_list_compute(argv, prefix, &pathspec, &list) < 0)
736
goto cleanup;
737
738
info.prefix = prefix;
@@ -1326,7 +1326,7 @@ static int module_sync(int argc, const char **argv, const char *prefix)
1326
argc = parse_options(argc, argv, prefix, module_sync_options,
1327
git_submodule_helper_usage, 0);
1328
1329
- if (module_list_compute(argc, argv, prefix, &pathspec, &list) < 0)
1329
+ if (module_list_compute(argv, prefix, &pathspec, &list) < 0)
1330
goto cleanup;
1331
1332
info.prefix = prefix;
@@ -1479,7 +1479,7 @@ static int module_deinit(int argc, const char **argv, const char *prefix)
1479
if (!argc && !all)
1480
die(_("Use '--all' if you really want to deinitialize all submodules"));
1481
1482
- if (module_list_compute(argc, argv, prefix, &pathspec, &list) < 0)
1482
+ if (module_list_compute(argv, prefix, &pathspec, &list) < 0)
1483
goto cleanup;
1484
1485
info.prefix = prefix;
@@ -2697,7 +2697,7 @@ static int module_update(int argc, const char **argv, const char *prefix)
2697
if (opt.update_default)
2698
opt.update_strategy.type = opt.update_default;
2699
2700
- if (module_list_compute(argc, argv, prefix, &pathspec, &opt.list) < 0) {
2700
+ if (module_list_compute(argv, prefix, &pathspec, &opt.list) < 0) {
2701
ret = 1;
2702
goto cleanup;
2703
}
@@ -2709,7 +2709,7 @@ static int module_update(int argc, const char **argv, const char *prefix)
2709
struct module_list list = MODULE_LIST_INIT;
2710
struct init_cb info = INIT_CB_INIT;
2711
2712
- if (module_list_compute(argc, argv, opt.prefix,
2712
+ if (module_list_compute(argv, opt.prefix,
2713
&pathspec2, &list) < 0) {
2714
module_list_release(&list);
2715
ret = 1;
@@ -2840,7 +2840,7 @@ static int absorb_git_dirs(int argc, const char **argv, const char *prefix)
2840
argc = parse_options(argc, argv, prefix, embed_gitdir_options,
2841
git_submodule_helper_usage, 0);
2842
2843
- if (module_list_compute(argc, argv, prefix, &pathspec, &list) < 0)
2843
+ if (module_list_compute(argv, prefix, &pathspec, &list) < 0)
2844
goto cleanup;
2845
2846
for (i = 0; i < list.nr; i++)