]> git.ipfire.org Git - thirdparty/git.git/commitdiff
submodule--helper: drop unused argc from module_list_compute()
authorJeff King <peff@peff.net>
Tue, 18 Oct 2022 01:02:02 +0000 (21:02 -0400)
committerJunio C Hamano <gitster@pobox.com>
Tue, 18 Oct 2022 04:24:03 +0000 (21:24 -0700)
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>
builtin/submodule--helper.c

index 0b4acb442b209305949a2715ead54d9de518e10f..1e29a3d7dc8d1c9db3a72704ec05ac7782c26335 100644 (file)
@@ -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++)