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@xxxxxxxx> --- builtin/submodule--helper.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 0b4acb442b..1e29a3d7dc 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -181,7 +181,7 @@ static void module_list_release(struct module_list *ml) free(ml->entries); } -static int module_list_compute(int argc, const char **argv, +static int module_list_compute(const char **argv, const char *prefix, struct pathspec *pathspec, struct module_list *list) @@ -405,7 +405,7 @@ static int module_foreach(int argc, const char **argv, const char *prefix) argc = parse_options(argc, argv, prefix, module_foreach_options, git_submodule_helper_usage, 0); - if (module_list_compute(0, NULL, prefix, &pathspec, &list) < 0) + if (module_list_compute(NULL, prefix, &pathspec, &list) < 0) goto cleanup; info.argc = argc; @@ -545,7 +545,7 @@ static int module_init(int argc, const char **argv, const char *prefix) argc = parse_options(argc, argv, prefix, module_init_options, git_submodule_helper_usage, 0); - if (module_list_compute(argc, argv, prefix, &pathspec, &list) < 0) + if (module_list_compute(argv, prefix, &pathspec, &list) < 0) goto cleanup; /* @@ -732,7 +732,7 @@ static int module_status(int argc, const char **argv, const char *prefix) argc = parse_options(argc, argv, prefix, module_status_options, git_submodule_helper_usage, 0); - if (module_list_compute(argc, argv, prefix, &pathspec, &list) < 0) + if (module_list_compute(argv, prefix, &pathspec, &list) < 0) goto cleanup; info.prefix = prefix; @@ -1326,7 +1326,7 @@ static int module_sync(int argc, const char **argv, const char *prefix) argc = parse_options(argc, argv, prefix, module_sync_options, git_submodule_helper_usage, 0); - if (module_list_compute(argc, argv, prefix, &pathspec, &list) < 0) + if (module_list_compute(argv, prefix, &pathspec, &list) < 0) goto cleanup; info.prefix = prefix; @@ -1479,7 +1479,7 @@ static int module_deinit(int argc, const char **argv, const char *prefix) if (!argc && !all) die(_("Use '--all' if you really want to deinitialize all submodules")); - if (module_list_compute(argc, argv, prefix, &pathspec, &list) < 0) + if (module_list_compute(argv, prefix, &pathspec, &list) < 0) goto cleanup; info.prefix = prefix; @@ -2697,7 +2697,7 @@ static int module_update(int argc, const char **argv, const char *prefix) if (opt.update_default) opt.update_strategy.type = opt.update_default; - if (module_list_compute(argc, argv, prefix, &pathspec, &opt.list) < 0) { + if (module_list_compute(argv, prefix, &pathspec, &opt.list) < 0) { ret = 1; goto cleanup; } @@ -2709,7 +2709,7 @@ static int module_update(int argc, const char **argv, const char *prefix) struct module_list list = MODULE_LIST_INIT; struct init_cb info = INIT_CB_INIT; - if (module_list_compute(argc, argv, opt.prefix, + if (module_list_compute(argv, opt.prefix, &pathspec2, &list) < 0) { module_list_release(&list); ret = 1; @@ -2840,7 +2840,7 @@ static int absorb_git_dirs(int argc, const char **argv, const char *prefix) argc = parse_options(argc, argv, prefix, embed_gitdir_options, git_submodule_helper_usage, 0); - if (module_list_compute(argc, argv, prefix, &pathspec, &list) < 0) + if (module_list_compute(argv, prefix, &pathspec, &list) < 0) goto cleanup; for (i = 0; i < list.nr; i++) -- 2.38.0.371.g300879f34e