From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by dcvr.yhbt.net (Postfix) with ESMTP id 536151F403 for ; Tue, 18 Oct 2022 01:02:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230416AbiJRBCG (ORCPT ); Mon, 17 Oct 2022 21:02:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230311AbiJRBCF (ORCPT ); Mon, 17 Oct 2022 21:02:05 -0400 Received: from cloud.peff.net (cloud.peff.net [104.130.231.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0BEF79A66 for ; Mon, 17 Oct 2022 18:02:03 -0700 (PDT) Received: (qmail 28720 invoked by uid 109); 18 Oct 2022 01:02:02 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Tue, 18 Oct 2022 01:02:02 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 13373 invoked by uid 111); 18 Oct 2022 01:02:03 -0000 Received: from coredump.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.2) by peff.net (qpsmtpd/0.94) with (TLS_AES_256_GCM_SHA384 encrypted) ESMTPS; Mon, 17 Oct 2022 21:02:03 -0400 Authentication-Results: peff.net; auth=none Date: Mon, 17 Oct 2022 21:02:02 -0400 From: Jeff King To: git@vger.kernel.org Subject: [PATCH 02/12] submodule--helper: drop unused argc from module_list_compute() Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org 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 --- 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