From patchwork Fri Feb 24 06:34:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff King X-Patchwork-Id: 13150955 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B767C677F1 for ; Fri, 24 Feb 2023 06:34:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229756AbjBXGer (ORCPT ); Fri, 24 Feb 2023 01:34:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229750AbjBXGeq (ORCPT ); Fri, 24 Feb 2023 01:34:46 -0500 Received: from cloud.peff.net (cloud.peff.net [104.130.231.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78BE51589C for ; Thu, 23 Feb 2023 22:34:45 -0800 (PST) Received: (qmail 3649 invoked by uid 109); 24 Feb 2023 06:34:45 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Fri, 24 Feb 2023 06:34:45 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 31044 invoked by uid 111); 24 Feb 2023 06:34:44 -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; Fri, 24 Feb 2023 01:34:44 -0500 Authentication-Results: peff.net; auth=none Date: Fri, 24 Feb 2023 01:34:44 -0500 From: Jeff King To: git@vger.kernel.org Subject: [PATCH 01/21] ref-filter: drop unused atom parameter from get_worktree_path() Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The get_worktree_path() function is used to populate the %(worktreepath) value, but it has never used its "atom" parameter since it was added in 2582083fa1 (ref-filter: add worktreepath atom, 2019-04-28). Normally we'd use the atom struct to cache any work we do, but in this case there's a global hashmap that does that caching already. So we can just drop the unused parameter. Signed-off-by: Jeff King --- ref-filter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ref-filter.c b/ref-filter.c index f8203c6b05..434a28c830 100644 --- a/ref-filter.c +++ b/ref-filter.c @@ -1822,7 +1822,7 @@ static void lazy_init_worktree_map(void) populate_worktree_map(&(ref_to_worktree_map.map), ref_to_worktree_map.worktrees); } -static char *get_worktree_path(const struct used_atom *atom, const struct ref_array_item *ref) +static char *get_worktree_path(const struct ref_array_item *ref) { struct hashmap_entry entry, *e; struct ref_to_worktree_entry *lookup_result; @@ -1881,7 +1881,7 @@ static int populate_value(struct ref_array_item *ref, struct strbuf *err) refname = get_refname(atom, ref); else if (atom_type == ATOM_WORKTREEPATH) { if (ref->kind == FILTER_REFS_BRANCHES) - v->s = get_worktree_path(atom, ref); + v->s = get_worktree_path(ref); else v->s = xstrdup(""); continue; From patchwork Fri Feb 24 06:37:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff King X-Patchwork-Id: 13150956 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 018DFC677F1 for ; Fri, 24 Feb 2023 06:37:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229541AbjBXGh0 (ORCPT ); Fri, 24 Feb 2023 01:37:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229458AbjBXGhZ (ORCPT ); Fri, 24 Feb 2023 01:37:25 -0500 Received: from cloud.peff.net (cloud.peff.net [104.130.231.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B403511EB5 for ; Thu, 23 Feb 2023 22:37:23 -0800 (PST) Received: (qmail 3654 invoked by uid 109); 24 Feb 2023 06:37:23 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Fri, 24 Feb 2023 06:37:23 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 31077 invoked by uid 111); 24 Feb 2023 06:37:22 -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; Fri, 24 Feb 2023 01:37:22 -0500 Authentication-Results: peff.net; auth=none Date: Fri, 24 Feb 2023 01:37:22 -0500 From: Jeff King To: git@vger.kernel.org Subject: [PATCH 02/21] ls-refs: drop config caching Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The code for the v2 ls-refs command has an ensure_config_read() function that tries to read the lsrefs.unborn config only once and caches it in some static global variables. There's no real need for this caching. In any given process we'd only need the value twice (once to decide whether to advertise, and once if somebody runs the command). And since the config code already has its own cache, each access is only incurring a hash lookup and string comparison anyway. Since the values we set are going to be specific to the_repository, the globals we set are a mild anti-pattern. In practice it's not a bug (yet) since the server-side v2 code only handles a single repository anyway. But it doesn't hurt to take a small step in the right direction and model a good approach. Note that we currently set two booleans: advertise_unborn and allow_unborn. But we can get away with a single value, since "advertise" naturally implies "allow". That lets us just convert this to a function with a return value. Note that we still always read from the_repository; we'll deal with that in a follow-on patch. Signed-off-by: Jeff King --- Mostly done as prep for the next patch, but IMHO the simplification here is nice in its own right. ls-refs.c | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/ls-refs.c b/ls-refs.c index 697d4beb8d..4863813655 100644 --- a/ls-refs.c +++ b/ls-refs.c @@ -8,38 +8,32 @@ #include "config.h" #include "string-list.h" -static int config_read; -static int advertise_unborn; -static int allow_unborn; - -static void ensure_config_read(void) +static enum { + UNBORN_IGNORE = 0, + UNBORN_ALLOW, + UNBORN_ADVERTISE /* implies ALLOW */ +} unborn_config(void) { const char *str = NULL; - if (config_read) - return; - if (repo_config_get_string_tmp(the_repository, "lsrefs.unborn", &str)) { /* * If there is no such config, advertise and allow it by * default. */ - advertise_unborn = 1; - allow_unborn = 1; + return UNBORN_ADVERTISE; } else { if (!strcmp(str, "advertise")) { - advertise_unborn = 1; - allow_unborn = 1; + return UNBORN_ADVERTISE; } else if (!strcmp(str, "allow")) { - allow_unborn = 1; + return UNBORN_ALLOW; } else if (!strcmp(str, "ignore")) { - /* do nothing */ + return UNBORN_IGNORE; } else { die(_("invalid value for '%s': '%s'"), "lsrefs.unborn", str); } } - config_read = 1; } /* @@ -159,7 +153,6 @@ int ls_refs(struct repository *r, struct packet_reader *request) strbuf_init(&data.buf, 0); string_list_init_dup(&data.hidden_refs); - ensure_config_read(); git_config(ls_refs_config, &data); while (packet_reader_read(request) == PACKET_READ_NORMAL) { @@ -175,7 +168,7 @@ int ls_refs(struct repository *r, struct packet_reader *request) strvec_push(&data.prefixes, out); } else if (!strcmp("unborn", arg)) - data.unborn = allow_unborn; + data.unborn = !!unborn_config(); else die(_("unexpected line: '%s'"), arg); } @@ -206,11 +199,8 @@ int ls_refs(struct repository *r, struct packet_reader *request) int ls_refs_advertise(struct repository *r, struct strbuf *value) { - if (value) { - ensure_config_read(); - if (advertise_unborn) - strbuf_addstr(value, "unborn"); - } + if (value && unborn_config() == UNBORN_ADVERTISE) + strbuf_addstr(value, "unborn"); return 1; } From patchwork Fri Feb 24 06:38:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff King X-Patchwork-Id: 13150957 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D3EFC677F1 for ; Fri, 24 Feb 2023 06:38:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229533AbjBXGiO (ORCPT ); Fri, 24 Feb 2023 01:38:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229456AbjBXGiM (ORCPT ); Fri, 24 Feb 2023 01:38:12 -0500 Received: from cloud.peff.net (cloud.peff.net [104.130.231.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 807B32687 for ; Thu, 23 Feb 2023 22:38:11 -0800 (PST) Received: (qmail 3658 invoked by uid 109); 24 Feb 2023 06:38:11 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Fri, 24 Feb 2023 06:38:11 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 31084 invoked by uid 111); 24 Feb 2023 06:38:10 -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; Fri, 24 Feb 2023 01:38:10 -0500 Authentication-Results: peff.net; auth=none Date: Fri, 24 Feb 2023 01:38:10 -0500 From: Jeff King To: git@vger.kernel.org Subject: [PATCH 03/21] serve: use repository pointer to get config Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org A few of the v2 "serve" callbacks ignore their repository parameter and read config using the_repository (either directly or implicitly by calling wrapper functions). This isn't a bug since the server code only handles a single main repository anyway (and indeed, if you look at the callers, these repository parameters will always be the_repository). But in the long run we want to get rid of the_repository, so let's take a tiny step in that direction. As a bonus, this silences some -Wunused-parameter warnings. Signed-off-by: Jeff King --- bundle-uri.c | 2 +- ls-refs.c | 8 ++++---- serve.c | 2 +- upload-pack.c | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/bundle-uri.c b/bundle-uri.c index 8a3c39ce57..177c181040 100644 --- a/bundle-uri.c +++ b/bundle-uri.c @@ -884,7 +884,7 @@ int bundle_uri_command(struct repository *r, * Read all "bundle.*" config lines to the client as key=value * packet lines. */ - git_config(config_to_packet_line, &writer); + repo_config(r, config_to_packet_line, &writer); packet_writer_flush(&writer); diff --git a/ls-refs.c b/ls-refs.c index 4863813655..bd9ab2c348 100644 --- a/ls-refs.c +++ b/ls-refs.c @@ -12,11 +12,11 @@ static enum { UNBORN_IGNORE = 0, UNBORN_ALLOW, UNBORN_ADVERTISE /* implies ALLOW */ -} unborn_config(void) +} unborn_config(struct repository *r) { const char *str = NULL; - if (repo_config_get_string_tmp(the_repository, "lsrefs.unborn", &str)) { + if (repo_config_get_string_tmp(r, "lsrefs.unborn", &str)) { /* * If there is no such config, advertise and allow it by * default. @@ -168,7 +168,7 @@ int ls_refs(struct repository *r, struct packet_reader *request) strvec_push(&data.prefixes, out); } else if (!strcmp("unborn", arg)) - data.unborn = !!unborn_config(); + data.unborn = !!unborn_config(r); else die(_("unexpected line: '%s'"), arg); } @@ -199,7 +199,7 @@ int ls_refs(struct repository *r, struct packet_reader *request) int ls_refs_advertise(struct repository *r, struct strbuf *value) { - if (value && unborn_config() == UNBORN_ADVERTISE) + if (value && unborn_config(r) == UNBORN_ADVERTISE) strbuf_addstr(value, "unborn"); return 1; diff --git a/serve.c b/serve.c index cbf4a143cf..2ccc03c16b 100644 --- a/serve.c +++ b/serve.c @@ -48,7 +48,7 @@ static void object_format_receive(struct repository *r, static int session_id_advertise(struct repository *r, struct strbuf *value) { if (advertise_sid == -1 && - git_config_get_bool("transfer.advertisesid", &advertise_sid)) + repo_config_get_bool(r, "transfer.advertisesid", &advertise_sid)) advertise_sid = 0; if (!advertise_sid) return 0; diff --git a/upload-pack.c b/upload-pack.c index 551f22ffa5..bcb702a5ba 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -1775,26 +1775,26 @@ int upload_pack_advertise(struct repository *r, strbuf_addstr(value, "shallow wait-for-done"); - if (!repo_config_get_bool(the_repository, + if (!repo_config_get_bool(r, "uploadpack.allowfilter", &allow_filter_value) && allow_filter_value) strbuf_addstr(value, " filter"); - if (!repo_config_get_bool(the_repository, + if (!repo_config_get_bool(r, "uploadpack.allowrefinwant", &allow_ref_in_want) && allow_ref_in_want) strbuf_addstr(value, " ref-in-want"); if (git_env_bool("GIT_TEST_SIDEBAND_ALL", 0) || - (!repo_config_get_bool(the_repository, + (!repo_config_get_bool(r, "uploadpack.allowsidebandall", &allow_sideband_all_value) && allow_sideband_all_value)) strbuf_addstr(value, " sideband-all"); - if (!repo_config_get_string(the_repository, + if (!repo_config_get_string(r, "uploadpack.blobpackfileuri", &str) && str) { From patchwork Fri Feb 24 06:38:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff King X-Patchwork-Id: 13150958 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A32EC677F1 for ; Fri, 24 Feb 2023 06:38:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229576AbjBXGi0 (ORCPT ); Fri, 24 Feb 2023 01:38:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229456AbjBXGiZ (ORCPT ); Fri, 24 Feb 2023 01:38:25 -0500 Received: from cloud.peff.net (cloud.peff.net [104.130.231.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9BB01814B for ; Thu, 23 Feb 2023 22:38:24 -0800 (PST) Received: (qmail 3663 invoked by uid 109); 24 Feb 2023 06:38:24 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Fri, 24 Feb 2023 06:38:24 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 31087 invoked by uid 111); 24 Feb 2023 06:38:24 -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; Fri, 24 Feb 2023 01:38:24 -0500 Authentication-Results: peff.net; auth=none Date: Fri, 24 Feb 2023 01:38:23 -0500 From: Jeff King To: git@vger.kernel.org Subject: [PATCH 04/21] serve: mark unused parameters in virtual functions Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Each v2 "serve" action has a virtual function for advertising and implementing the command. A few of these are so trivial that they don't need to look at their parameters, especially the "repository" parameter. We can mark them so that -Wunused-parameter doesn't complain. Note that upload_pack_v2() probably _should_ be using its repository pointer. But teaching the functions it calls to do so is non-trivial. Even using it for something as simple as reading config is tricky, both because it shares code with the v1 upload pack, and because the git_protected_config() mechanism it uses does not have a repo-specific interface. So we'll just annotate it for now, and cleaning it up can be part of the larger work to drop references to the_repository. Signed-off-by: Jeff King --- serve.c | 10 +++++----- upload-pack.c | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/serve.c b/serve.c index 2ccc03c16b..e08a980083 100644 --- a/serve.c +++ b/serve.c @@ -12,13 +12,13 @@ static int advertise_sid = -1; static int client_hash_algo = GIT_HASH_SHA1; -static int always_advertise(struct repository *r, - struct strbuf *value) +static int always_advertise(struct repository *r UNUSED, + struct strbuf *value UNUSED) { return 1; } -static int agent_advertise(struct repository *r, +static int agent_advertise(struct repository *r UNUSED, struct strbuf *value) { if (value) @@ -34,7 +34,7 @@ static int object_format_advertise(struct repository *r, return 1; } -static void object_format_receive(struct repository *r, +static void object_format_receive(struct repository *r UNUSED, const char *algo_name) { if (!algo_name) @@ -57,7 +57,7 @@ static int session_id_advertise(struct repository *r, struct strbuf *value) return 1; } -static void session_id_receive(struct repository *r, +static void session_id_receive(struct repository *r UNUSED, const char *client_sid) { if (!client_sid) diff --git a/upload-pack.c b/upload-pack.c index bcb702a5ba..f6f4da0fef 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -1699,7 +1699,7 @@ enum fetch_state { FETCH_DONE, }; -int upload_pack_v2(struct repository *r, struct packet_reader *request) +int upload_pack_v2(struct repository *r UNUSED, struct packet_reader *request) { enum fetch_state state = FETCH_PROCESS_ARGS; struct upload_pack_data data; From patchwork Fri Feb 24 06:38:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff King X-Patchwork-Id: 13150959 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 265D9C677F1 for ; Fri, 24 Feb 2023 06:38:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229598AbjBXGie (ORCPT ); Fri, 24 Feb 2023 01:38:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229595AbjBXGid (ORCPT ); Fri, 24 Feb 2023 01:38:33 -0500 Received: from cloud.peff.net (cloud.peff.net [104.130.231.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C07BC1D92A for ; Thu, 23 Feb 2023 22:38:31 -0800 (PST) Received: (qmail 3666 invoked by uid 109); 24 Feb 2023 06:38:31 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Fri, 24 Feb 2023 06:38:31 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 31090 invoked by uid 111); 24 Feb 2023 06:38:30 -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; Fri, 24 Feb 2023 01:38:30 -0500 Authentication-Results: peff.net; auth=none Date: Fri, 24 Feb 2023 01:38:30 -0500 From: Jeff King To: git@vger.kernel.org Subject: [PATCH 05/21] object-name: mark unused parameters in disambiguate callbacks Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The object-name disambiguation code triggers a callback for each possible object id we find. This is really used for two purposes: - "hint" functions like disambiguate_commit_only report back on whether the value is usable - iterator functions like repo_for_each_abbrev() use it to collect and report matching names. Compiling with -Wunused-parameter generates several warnings, but they're distinct for each type. The "hint" functions never look at the void cb_data pointer; they only care whether the oid matches our hint. The iterator functions never look at the "struct repository" parameter; they're just reporting back the oids they see, and always return 0. So arguably these could be two separate interfaces: int (*hint)(struct repository *r, const struct object_id *oid); void (*iter)(const struct object_id *oid, void *cb_data); But doing so would complicate the disambiguation code, which now has to accept and call the two different types. Since we can easily squelch the compiler warnings by annotating the functions, let's just do that. Signed-off-by: Jeff King --- object-name.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/object-name.c b/object-name.c index 2dd1a0f56e..7d1986ad48 100644 --- a/object-name.c +++ b/object-name.c @@ -223,15 +223,15 @@ static int finish_object_disambiguation(struct disambiguate_state *ds, static int disambiguate_commit_only(struct repository *r, const struct object_id *oid, - void *cb_data_unused) + void *cb_data UNUSED) { int kind = oid_object_info(r, oid, NULL); return kind == OBJ_COMMIT; } static int disambiguate_committish_only(struct repository *r, const struct object_id *oid, - void *cb_data_unused) + void *cb_data UNUSED) { struct object *obj; int kind; @@ -251,15 +251,15 @@ static int disambiguate_committish_only(struct repository *r, static int disambiguate_tree_only(struct repository *r, const struct object_id *oid, - void *cb_data_unused) + void *cb_data UNUSED) { int kind = oid_object_info(r, oid, NULL); return kind == OBJ_TREE; } static int disambiguate_treeish_only(struct repository *r, const struct object_id *oid, - void *cb_data_unused) + void *cb_data UNUSED) { struct object *obj; int kind; @@ -279,7 +279,7 @@ static int disambiguate_treeish_only(struct repository *r, static int disambiguate_blob_only(struct repository *r, const struct object_id *oid, - void *cb_data_unused) + void *cb_data UNUSED) { int kind = oid_object_info(r, oid, NULL); return kind == OBJ_BLOB; @@ -473,7 +473,7 @@ static int collect_ambiguous(const struct object_id *oid, void *data) return 0; } -static int repo_collect_ambiguous(struct repository *r, +static int repo_collect_ambiguous(struct repository *r UNUSED, const struct object_id *oid, void *data) { @@ -665,7 +665,7 @@ static int extend_abbrev_len(const struct object_id *oid, void *cb_data) return 0; } -static int repo_extend_abbrev_len(struct repository *r, +static int repo_extend_abbrev_len(struct repository *r UNUSED, const struct object_id *oid, void *cb_data) { From patchwork Fri Feb 24 06:38:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff King X-Patchwork-Id: 13150960 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C99D9C61DA3 for ; Fri, 24 Feb 2023 06:38:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229657AbjBXGik (ORCPT ); Fri, 24 Feb 2023 01:38:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229724AbjBXGii (ORCPT ); Fri, 24 Feb 2023 01:38:38 -0500 Received: from cloud.peff.net (cloud.peff.net [104.130.231.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF11860D6B for ; Thu, 23 Feb 2023 22:38:36 -0800 (PST) Received: (qmail 3669 invoked by uid 109); 24 Feb 2023 06:38:36 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Fri, 24 Feb 2023 06:38:36 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 31093 invoked by uid 111); 24 Feb 2023 06:38:35 -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; Fri, 24 Feb 2023 01:38:35 -0500 Authentication-Results: peff.net; auth=none Date: Fri, 24 Feb 2023 01:38:35 -0500 From: Jeff King To: git@vger.kernel.org Subject: [PATCH 06/21] http-backend: mark argc/argv unused Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org We can't drop them because it's cmd_main(), which has a set prototype, but the CGI interface does not do anything with such arguments. Arguably we could detect them and complain. It's possible this could detect misconfigurations or other mistakes, but: - as far as I can tell common webservers like apache do not have any mechanism to pass arguments to a CGI at all, so this isn't a mistake one could even make - it's possible that some obscure webserver might pass arguments, and we'd break that case. I have no idea if such a webserver exists; the CGI standard says only "The script is invoked in a system-defined manner". So probably it would not hurt to detect them, but it also is unlikely to help anyone. Let's just mark them as unused, which retains the current behavior but silences -Wunused-parameter. Signed-off-by: Jeff King --- http-backend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/http-backend.c b/http-backend.c index 8ab58e55f8..fc3ab97c0f 100644 --- a/http-backend.c +++ b/http-backend.c @@ -736,7 +736,7 @@ static int bad_request(struct strbuf *hdr, const struct service_cmd *c) return 0; } -int cmd_main(int argc, const char **argv) +int cmd_main(int argc UNUSED, const char **argv UNUSED) { char *method = getenv("REQUEST_METHOD"); const char *proto_header; From patchwork Fri Feb 24 06:38:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff King X-Patchwork-Id: 13150961 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A407BC677F1 for ; Fri, 24 Feb 2023 06:38:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229716AbjBXGir (ORCPT ); Fri, 24 Feb 2023 01:38:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229720AbjBXGip (ORCPT ); Fri, 24 Feb 2023 01:38:45 -0500 Received: from cloud.peff.net (cloud.peff.net [104.130.231.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A889752DF8 for ; Thu, 23 Feb 2023 22:38:44 -0800 (PST) Received: (qmail 3672 invoked by uid 109); 24 Feb 2023 06:38:44 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Fri, 24 Feb 2023 06:38:44 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 31098 invoked by uid 111); 24 Feb 2023 06:38:43 -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; Fri, 24 Feb 2023 01:38:43 -0500 Authentication-Results: peff.net; auth=none Date: Fri, 24 Feb 2023 01:38:43 -0500 From: Jeff King To: git@vger.kernel.org Subject: [PATCH 07/21] http-backend: mark unused parameters in virtual functions Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The http-backend dispatches requests via a table of virtual functions. Some of the functions ignore their "arg" parameter, because it's implicit in the function (e.g., get_info_refs knows that it is dispatched only for a request to "/info/refs"). Mark these unused parameters to silence -Wunused-parameter. Signed-off-by: Jeff King --- http-backend.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/http-backend.c b/http-backend.c index fc3ab97c0f..db963e64d7 100644 --- a/http-backend.c +++ b/http-backend.c @@ -524,7 +524,7 @@ static int show_text_ref(const char *name, const struct object_id *oid, return 0; } -static void get_info_refs(struct strbuf *hdr, char *arg) +static void get_info_refs(struct strbuf *hdr, char *arg UNUSED) { const char *service_name = get_parameter("service"); struct strbuf buf = STRBUF_INIT; @@ -578,7 +578,7 @@ static int show_head_ref(const char *refname, const struct object_id *oid, return 0; } -static void get_head(struct strbuf *hdr, char *arg) +static void get_head(struct strbuf *hdr, char *arg UNUSED) { struct strbuf buf = STRBUF_INIT; @@ -588,7 +588,7 @@ static void get_head(struct strbuf *hdr, char *arg) strbuf_release(&buf); } -static void get_info_packs(struct strbuf *hdr, char *arg) +static void get_info_packs(struct strbuf *hdr, char *arg UNUSED) { size_t objdirlen = strlen(get_object_directory()); struct strbuf buf = STRBUF_INIT; From patchwork Fri Feb 24 06:39:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff King X-Patchwork-Id: 13150963 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9F240C6FA99 for ; Fri, 24 Feb 2023 06:39:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229706AbjBXGjL (ORCPT ); Fri, 24 Feb 2023 01:39:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229510AbjBXGjJ (ORCPT ); Fri, 24 Feb 2023 01:39:09 -0500 Received: from cloud.peff.net (cloud.peff.net [104.130.231.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B320460D7D for ; Thu, 23 Feb 2023 22:39:07 -0800 (PST) Received: (qmail 3675 invoked by uid 109); 24 Feb 2023 06:39:07 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Fri, 24 Feb 2023 06:39:07 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 31101 invoked by uid 111); 24 Feb 2023 06:39:06 -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; Fri, 24 Feb 2023 01:39:06 -0500 Authentication-Results: peff.net; auth=none Date: Fri, 24 Feb 2023 01:39:06 -0500 From: Jeff King To: git@vger.kernel.org Subject: [PATCH 08/21] ref-filter: mark unused callback parameters Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The ref-filter code uses virtual functions to handle specific atoms, but many of the functions ignore some parameters: - most atom parsers do not need the ref_format itself, unless they are looking at centralized options like use_color, quote_style, etc. - meta-atom handlers like append_atom(), align_atom_handler(), etc, can't generate errors, so ignore their "err" parameter - likewise, the handlers for then/else/end do not even need to look at their atom_value, as the "if" handler put everything they need into the ref_formatting_state stack Since these functions all have to conform to virtual function interfaces, we can't just drop the unused parameters, but must mark them as UNUSED (to appease -Wunused-parameter). Signed-off-by: Jeff King --- ref-filter.c | 62 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 40 insertions(+), 22 deletions(-) diff --git a/ref-filter.c b/ref-filter.c index 434a28c830..acdee7fe3d 100644 --- a/ref-filter.c +++ b/ref-filter.c @@ -282,7 +282,8 @@ static int refname_atom_parser_internal(struct refname_atom *atom, const char *a return 0; } -static int remote_ref_atom_parser(struct ref_format *format, struct used_atom *atom, +static int remote_ref_atom_parser(struct ref_format *format UNUSED, + struct used_atom *atom, const char *arg, struct strbuf *err) { struct string_list params = STRING_LIST_INIT_DUP; @@ -329,7 +330,8 @@ static int remote_ref_atom_parser(struct ref_format *format, struct used_atom *a return 0; } -static int objecttype_atom_parser(struct ref_format *format, struct used_atom *atom, +static int objecttype_atom_parser(struct ref_format *format UNUSED, + struct used_atom *atom, const char *arg, struct strbuf *err) { if (arg) @@ -341,7 +343,8 @@ static int objecttype_atom_parser(struct ref_format *format, struct used_atom *a return 0; } -static int objectsize_atom_parser(struct ref_format *format, struct used_atom *atom, +static int objectsize_atom_parser(struct ref_format *format UNUSED, + struct used_atom *atom, const char *arg, struct strbuf *err) { if (!arg) { @@ -361,7 +364,8 @@ static int objectsize_atom_parser(struct ref_format *format, struct used_atom *a return 0; } -static int deltabase_atom_parser(struct ref_format *format, struct used_atom *atom, +static int deltabase_atom_parser(struct ref_format *format UNUSED, + struct used_atom *atom, const char *arg, struct strbuf *err) { if (arg) @@ -373,7 +377,8 @@ static int deltabase_atom_parser(struct ref_format *format, struct used_atom *at return 0; } -static int body_atom_parser(struct ref_format *format, struct used_atom *atom, +static int body_atom_parser(struct ref_format *format UNUSED, + struct used_atom *atom, const char *arg, struct strbuf *err) { if (arg) @@ -382,7 +387,8 @@ static int body_atom_parser(struct ref_format *format, struct used_atom *atom, return 0; } -static int subject_atom_parser(struct ref_format *format, struct used_atom *atom, +static int subject_atom_parser(struct ref_format *format UNUSED, + struct used_atom *atom, const char *arg, struct strbuf *err) { if (!arg) @@ -394,7 +400,8 @@ static int subject_atom_parser(struct ref_format *format, struct used_atom *atom return 0; } -static int trailers_atom_parser(struct ref_format *format, struct used_atom *atom, +static int trailers_atom_parser(struct ref_format *format UNUSED, + struct used_atom *atom, const char *arg, struct strbuf *err) { atom->u.contents.trailer_opts.no_divider = 1; @@ -448,8 +455,9 @@ static int contents_atom_parser(struct ref_format *format, struct used_atom *ato return 0; } -static int raw_atom_parser(struct ref_format *format, struct used_atom *atom, - const char *arg, struct strbuf *err) +static int raw_atom_parser(struct ref_format *format UNUSED, + struct used_atom *atom, + const char *arg, struct strbuf *err) { if (!arg) atom->u.raw_data.option = RAW_BARE; @@ -460,7 +468,8 @@ static int raw_atom_parser(struct ref_format *format, struct used_atom *atom, return 0; } -static int oid_atom_parser(struct ref_format *format, struct used_atom *atom, +static int oid_atom_parser(struct ref_format *format UNUSED, + struct used_atom *atom, const char *arg, struct strbuf *err) { if (!arg) @@ -479,7 +488,8 @@ static int oid_atom_parser(struct ref_format *format, struct used_atom *atom, return 0; } -static int person_email_atom_parser(struct ref_format *format, struct used_atom *atom, +static int person_email_atom_parser(struct ref_format *format UNUSED, + struct used_atom *atom, const char *arg, struct strbuf *err) { if (!arg) @@ -493,7 +503,8 @@ static int person_email_atom_parser(struct ref_format *format, struct used_atom return 0; } -static int refname_atom_parser(struct ref_format *format, struct used_atom *atom, +static int refname_atom_parser(struct ref_format *format UNUSED, + struct used_atom *atom, const char *arg, struct strbuf *err) { return refname_atom_parser_internal(&atom->u.refname, arg, atom->name, err); @@ -510,7 +521,8 @@ static align_type parse_align_position(const char *s) return -1; } -static int align_atom_parser(struct ref_format *format, struct used_atom *atom, +static int align_atom_parser(struct ref_format *format UNUSED, + struct used_atom *atom, const char *arg, struct strbuf *err) { struct align *align = &atom->u.align; @@ -562,7 +574,8 @@ static int align_atom_parser(struct ref_format *format, struct used_atom *atom, return 0; } -static int if_atom_parser(struct ref_format *format, struct used_atom *atom, +static int if_atom_parser(struct ref_format *format UNUSED, + struct used_atom *atom, const char *arg, struct strbuf *err) { if (!arg) { @@ -577,7 +590,8 @@ static int if_atom_parser(struct ref_format *format, struct used_atom *atom, return 0; } -static int rest_atom_parser(struct ref_format *format, struct used_atom *atom, +static int rest_atom_parser(struct ref_format *format, + struct used_atom *atom UNUSED, const char *arg, struct strbuf *err) { if (arg) @@ -586,7 +600,8 @@ static int rest_atom_parser(struct ref_format *format, struct used_atom *atom, return 0; } -static int head_atom_parser(struct ref_format *format, struct used_atom *atom, +static int head_atom_parser(struct ref_format *format UNUSED, + struct used_atom *atom, const char *arg, struct strbuf *err) { if (arg) @@ -791,7 +806,7 @@ static void quote_formatting(struct strbuf *s, const char *str, ssize_t len, int } static int append_atom(struct atom_value *v, struct ref_formatting_state *state, - struct strbuf *unused_err) + struct strbuf *err UNUSED) { /* * Quote formatting is only done when the stack has a single @@ -841,7 +856,7 @@ static void end_align_handler(struct ref_formatting_stack **stack) } static int align_atom_handler(struct atom_value *atomv, struct ref_formatting_state *state, - struct strbuf *unused_err) + struct strbuf *err UNUSED) { struct ref_formatting_stack *new_stack; @@ -888,7 +903,7 @@ static void if_then_else_handler(struct ref_formatting_stack **stack) } static int if_atom_handler(struct atom_value *atomv, struct ref_formatting_state *state, - struct strbuf *unused_err) + struct strbuf *err UNUSED) { struct ref_formatting_stack *new_stack; struct if_then_else *if_then_else = xcalloc(1, @@ -915,7 +930,8 @@ static int is_empty(struct strbuf *buf) return cur == end; } -static int then_atom_handler(struct atom_value *atomv, struct ref_formatting_state *state, +static int then_atom_handler(struct atom_value *atomv UNUSED, + struct ref_formatting_state *state, struct strbuf *err) { struct ref_formatting_stack *cur = state->stack; @@ -952,7 +968,8 @@ static int then_atom_handler(struct atom_value *atomv, struct ref_formatting_sta return 0; } -static int else_atom_handler(struct atom_value *atomv, struct ref_formatting_state *state, +static int else_atom_handler(struct atom_value *atomv UNUSED, + struct ref_formatting_state *state, struct strbuf *err) { struct ref_formatting_stack *prev = state->stack; @@ -973,7 +990,8 @@ static int else_atom_handler(struct atom_value *atomv, struct ref_formatting_sta return 0; } -static int end_atom_handler(struct atom_value *atomv, struct ref_formatting_state *state, +static int end_atom_handler(struct atom_value *atomv UNUSED, + struct ref_formatting_state *state, struct strbuf *err) { struct ref_formatting_stack *current = state->stack; From patchwork Fri Feb 24 06:39:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff King X-Patchwork-Id: 13150964 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A9494C677F1 for ; Fri, 24 Feb 2023 06:39:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229766AbjBXGjZ (ORCPT ); Fri, 24 Feb 2023 01:39:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229657AbjBXGjU (ORCPT ); Fri, 24 Feb 2023 01:39:20 -0500 Received: from cloud.peff.net (cloud.peff.net [104.130.231.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 119F2521F8 for ; Thu, 23 Feb 2023 22:39:16 -0800 (PST) Received: (qmail 3678 invoked by uid 109); 24 Feb 2023 06:39:16 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Fri, 24 Feb 2023 06:39:16 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 31104 invoked by uid 111); 24 Feb 2023 06:39:16 -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; Fri, 24 Feb 2023 01:39:16 -0500 Authentication-Results: peff.net; auth=none Date: Fri, 24 Feb 2023 01:39:15 -0500 From: Jeff King To: git@vger.kernel.org Subject: [PATCH 09/21] mark "pointless" data pointers in callbacks Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Both the object_array_filter() and trie_find() functions use callback functions that let the caller specify which elements match. These callbacks take a void pointer in case the caller wants to pass in extra data. But in each case, the single user of these functions just passes NULL, and the callback ignores the extra pointer. We could just remove these unused parameters from the callback interface entirely. But it's good practice to provide such a pointer, as it guides future callers of the function in the right direction (rather than tempting them to access global data). Plus it's consistent with other generic callback interfaces. So let's instead annotate the unused parameters, in order to silence the compiler's -Wunused-parameter warning. Signed-off-by: Jeff King --- path.c | 3 ++- revision.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/path.c b/path.c index 492e17ad12..0b641233e3 100644 --- a/path.c +++ b/path.c @@ -347,7 +347,8 @@ static void init_common_trie(void) * Helper function for update_common_dir: returns 1 if the dir * prefix is common. */ -static int check_common(const char *unmatched, void *value, void *baton) +static int check_common(const char *unmatched, void *value, + void *baton UNUSED) { struct common_dir *dir = value; diff --git a/revision.c b/revision.c index 21f5f572c2..4a24fc3fcd 100644 --- a/revision.c +++ b/revision.c @@ -4159,7 +4159,7 @@ static struct commit *get_revision_1(struct rev_info *revs) * Return true for entries that have not yet been shown. (This is an * object_array_each_func_t.) */ -static int entry_unshown(struct object_array_entry *entry, void *cb_data_unused) +static int entry_unshown(struct object_array_entry *entry, void *cb_data UNUSED) { return !(entry->item->flags & SHOWN); } From patchwork Fri Feb 24 06:39:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff King X-Patchwork-Id: 13150965 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 53463C677F1 for ; Fri, 24 Feb 2023 06:39:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229477AbjBXGjc (ORCPT ); Fri, 24 Feb 2023 01:39:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229755AbjBXGjZ (ORCPT ); Fri, 24 Feb 2023 01:39:25 -0500 Received: from cloud.peff.net (cloud.peff.net [104.130.231.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C92DE61F32 for ; Thu, 23 Feb 2023 22:39:19 -0800 (PST) Received: (qmail 3681 invoked by uid 109); 24 Feb 2023 06:39:19 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Fri, 24 Feb 2023 06:39:19 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 31107 invoked by uid 111); 24 Feb 2023 06:39:18 -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; Fri, 24 Feb 2023 01:39:18 -0500 Authentication-Results: peff.net; auth=none Date: Fri, 24 Feb 2023 01:39:18 -0500 From: Jeff King To: git@vger.kernel.org Subject: [PATCH 10/21] run-command: mark error routine parameters as unused Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org After forking but before exec-ing a command, we install special error/warn/die handlers in the child. These ignore the error messages they get, since the idea is that they shouldn't be called in the first place. Arguably they could pass along that error message _in addition_ to saying "error() should not be called in a child", but since the whole point is to avoid any conflicts on stdio/malloc locks, etc, we're better to just keep these simple. Seeing them trigger is effectively a bug, and the developer is probably better off grabbing a stack trace. But we do want to mark the functions so that -Wunused-parameter doesn't complain. Signed-off-by: Jeff King --- run-command.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/run-command.c b/run-command.c index 6bd16acb06..ba617655b2 100644 --- a/run-command.c +++ b/run-command.c @@ -341,19 +341,19 @@ static void child_close_pair(int fd[2]) child_close(fd[1]); } -static void child_error_fn(const char *err, va_list params) +static void child_error_fn(const char *err UNUSED, va_list params UNUSED) { const char msg[] = "error() should not be called in child\n"; xwrite(2, msg, sizeof(msg) - 1); } -static void child_warn_fn(const char *err, va_list params) +static void child_warn_fn(const char *err UNUSED, va_list params UNUSED) { const char msg[] = "warn() should not be called in child\n"; xwrite(2, msg, sizeof(msg) - 1); } -static void NORETURN child_die_fn(const char *err, va_list params) +static void NORETURN child_die_fn(const char *err UNUSED, va_list params UNUSED) { const char msg[] = "die() should not be called in child\n"; xwrite(2, msg, sizeof(msg) - 1); From patchwork Fri Feb 24 06:39:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff King X-Patchwork-Id: 13150966 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 671A3C61DA3 for ; Fri, 24 Feb 2023 06:39:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229769AbjBXGjh (ORCPT ); Fri, 24 Feb 2023 01:39:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229756AbjBXGjb (ORCPT ); Fri, 24 Feb 2023 01:39:31 -0500 Received: from cloud.peff.net (cloud.peff.net [104.130.231.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FCA761F03 for ; Thu, 23 Feb 2023 22:39:21 -0800 (PST) Received: (qmail 3684 invoked by uid 109); 24 Feb 2023 06:39:21 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Fri, 24 Feb 2023 06:39:21 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 31110 invoked by uid 111); 24 Feb 2023 06:39:20 -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; Fri, 24 Feb 2023 01:39:20 -0500 Authentication-Results: peff.net; auth=none Date: Fri, 24 Feb 2023 01:39:20 -0500 From: Jeff King To: git@vger.kernel.org Subject: [PATCH 11/21] mark unused parameters in signal handlers Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signal handlers receive their signal number as a parameter, but many don't care what it is (because they only handle one signal, or because their action is the same regardless of the signal). Mark such parameters to silence -Wunused-parameter. Signed-off-by: Jeff King --- builtin/fast-import.c | 2 +- builtin/log.c | 2 +- daemon.c | 2 +- progress.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/builtin/fast-import.c b/builtin/fast-import.c index 7134683ab9..4a8c835062 100644 --- a/builtin/fast-import.c +++ b/builtin/fast-import.c @@ -436,7 +436,7 @@ static void set_checkpoint_signal(void) #else -static void checkpoint_signal(int signo) +static void checkpoint_signal(int signo UNUSED) { checkpoint_requested = 1; } diff --git a/builtin/log.c b/builtin/log.c index 04412dd9c9..813b768e24 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -436,7 +436,7 @@ static void log_show_early(struct rev_info *revs, struct commit_list *list) setitimer(ITIMER_REAL, &early_output_timer, NULL); } -static void early_output(int signal) +static void early_output(int signal UNUSED) { show_early_output = log_show_early; } diff --git a/daemon.c b/daemon.c index 0ae7d12b5c..06d5bc6931 100644 --- a/daemon.c +++ b/daemon.c @@ -928,7 +928,7 @@ static void handle(int incoming, struct sockaddr *addr, socklen_t addrlen) add_child(&cld, addr, addrlen); } -static void child_handler(int signo) +static void child_handler(int signo UNUSED) { /* * Otherwise empty handler because systemcalls will get interrupted diff --git a/progress.c b/progress.c index 0cdd875d37..9b33a2df32 100644 --- a/progress.c +++ b/progress.c @@ -59,7 +59,7 @@ void progress_test_force_update(void) } -static void progress_interval(int signum) +static void progress_interval(int signum UNUSED) { progress_update = 1; } From patchwork Fri Feb 24 06:39:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff King X-Patchwork-Id: 13150967 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF9CDC677F1 for ; Fri, 24 Feb 2023 06:39:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229533AbjBXGjo (ORCPT ); Fri, 24 Feb 2023 01:39:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229758AbjBXGjf (ORCPT ); Fri, 24 Feb 2023 01:39:35 -0500 Received: from cloud.peff.net (cloud.peff.net [104.130.231.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD83F61EF0 for ; Thu, 23 Feb 2023 22:39:23 -0800 (PST) Received: (qmail 3687 invoked by uid 109); 24 Feb 2023 06:39:23 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Fri, 24 Feb 2023 06:39:23 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 31113 invoked by uid 111); 24 Feb 2023 06:39:22 -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; Fri, 24 Feb 2023 01:39:22 -0500 Authentication-Results: peff.net; auth=none Date: Fri, 24 Feb 2023 01:39:22 -0500 From: Jeff King To: git@vger.kernel.org Subject: [PATCH 12/21] list-objects: mark unused callback parameters Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Our graph-traversal functions take callbacks for showing commits and objects, but not all callbacks need each parameter. Likewise for the similar traverse_bitmap_commit_list(), which has a different interface but serves the same purpose. And the include_check mechanism, which passes along a void pointer which is not always used. Mark the unused ones to to make -Wunused-parameter happy. Signed-off-by: Jeff King --- builtin/pack-objects.c | 11 ++++++----- builtin/rev-list.c | 10 +++++----- pack-bitmap.c | 6 ++++-- reachable.c | 12 +++++++----- 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 74a167a180..fb92a9686b 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -1590,7 +1590,7 @@ static int add_object_entry(const struct object_id *oid, enum object_type type, static int add_object_entry_from_bitmap(const struct object_id *oid, enum object_type type, - int flags, uint32_t name_hash, + int flags UNUSED, uint32_t name_hash, struct packed_git *pack, off_t offset) { display_progress(progress_state, ++nr_seen); @@ -3464,7 +3464,7 @@ static void add_cruft_object_entry(const struct object_id *oid, enum object_type return; } -static void show_cruft_object(struct object *obj, const char *name, void *data) +static void show_cruft_object(struct object *obj, const char *name, void *data UNUSED) { /* * if we did not record it earlier, it's at least as old as our @@ -3484,7 +3484,7 @@ static void show_cruft_commit(struct commit *commit, void *data) show_cruft_object((struct object*)commit, NULL, data); } -static int cruft_include_check_obj(struct object *obj, void *data) +static int cruft_include_check_obj(struct object *obj, void *data UNUSED) { return !has_object_kept_pack(&obj->oid, IN_CORE_KEEP_PACKS); } @@ -3663,7 +3663,7 @@ static void read_object_list_from_stdin(void) } } -static void show_commit(struct commit *commit, void *data) +static void show_commit(struct commit *commit, void *data UNUSED) { add_object_entry(&commit->object.oid, OBJ_COMMIT, NULL, 0); @@ -3674,7 +3674,8 @@ static void show_commit(struct commit *commit, void *data) propagate_island_marks(commit); } -static void show_object(struct object *obj, const char *name, void *data) +static void show_object(struct object *obj, const char *name, + void *data UNUSED) { add_preferred_base_object(name); add_object_entry(&obj->oid, obj->type, name, 0); diff --git a/builtin/rev-list.c b/builtin/rev-list.c index d42db0b0cc..cceb5de975 100644 --- a/builtin/rev-list.c +++ b/builtin/rev-list.c @@ -362,11 +362,11 @@ static int show_bisect_vars(struct rev_list_info *info, int reaches, int all) static int show_object_fast( const struct object_id *oid, - enum object_type type, - int exclude, - uint32_t name_hash, - struct packed_git *found_pack, - off_t found_offset) + enum object_type type UNUSED, + int exclude UNUSED, + uint32_t name_hash UNUSED, + struct packed_git *found_pack UNUSED, + off_t found_offset UNUSED) { fprintf(stdout, "%s\n", oid_to_hex(oid)); return 1; diff --git a/pack-bitmap.c b/pack-bitmap.c index d2a42abf28..c8994a0f00 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -951,7 +951,8 @@ static void show_object(struct object *object, const char *name, void *data_) bitmap_set(data->base, bitmap_pos); } -static void show_commit(struct commit *commit, void *data) +static void show_commit(struct commit *commit UNUSED, + void *data UNUSED) { } @@ -1940,7 +1941,8 @@ static void test_bitmap_type(struct bitmap_test_data *tdata, type_name(bitmap_type)); } -static void test_show_object(struct object *object, const char *name, +static void test_show_object(struct object *object, + const char *name UNUSED, void *data) { struct bitmap_test_data *tdata = data; diff --git a/reachable.c b/reachable.c index aba63ebeb3..08f290c2be 100644 --- a/reachable.c +++ b/reachable.c @@ -48,7 +48,9 @@ static int add_one_ref(const char *path, const struct object_id *oid, * The traversal will have already marked us as SEEN, so we * only need to handle any progress reporting here. */ -static void mark_object(struct object *obj, const char *name, void *data) +static void mark_object(struct object *obj UNUSED, + const char *name UNUSED, + void *data) { update_progress(data); } @@ -202,10 +204,10 @@ int add_unseen_recent_objects_to_traversal(struct rev_info *revs, static int mark_object_seen(const struct object_id *oid, enum object_type type, - int exclude, - uint32_t name_hash, - struct packed_git *found_pack, - off_t found_offset) + int exclude UNUSED, + uint32_t name_hash UNUSED, + struct packed_git *found_pack UNUSED, + off_t found_offset UNUSED) { struct object *obj = lookup_object_by_type(the_repository, oid, type); if (!obj) From patchwork Fri Feb 24 06:39:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff King X-Patchwork-Id: 13150968 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EAFB9C677F1 for ; Fri, 24 Feb 2023 06:39:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229770AbjBXGjv (ORCPT ); Fri, 24 Feb 2023 01:39:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229768AbjBXGjh (ORCPT ); Fri, 24 Feb 2023 01:39:37 -0500 Received: from cloud.peff.net (cloud.peff.net [104.130.231.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AAC861EF3 for ; Thu, 23 Feb 2023 22:39:26 -0800 (PST) Received: (qmail 3690 invoked by uid 109); 24 Feb 2023 06:39:25 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Fri, 24 Feb 2023 06:39:25 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 31116 invoked by uid 111); 24 Feb 2023 06:39:25 -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; Fri, 24 Feb 2023 01:39:25 -0500 Authentication-Results: peff.net; auth=none Date: Fri, 24 Feb 2023 01:39:24 -0500 From: Jeff King To: git@vger.kernel.org Subject: [PATCH 13/21] for_each_object: mark unused callback parameters Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The for_each_{loose,packed}_object interface uses callback functions, but not every callback needs all of the parameters. Mark the unused ones to satisfy -Wunused-parameter. Signed-off-by: Jeff King --- builtin/cat-file.c | 8 ++++---- builtin/count-objects.c | 6 ++++-- builtin/fsck.c | 25 +++++++++++++------------ builtin/gc.c | 14 +++++++------- builtin/pack-objects.c | 15 ++++++++------- builtin/prune.c | 6 ++++-- builtin/repack.c | 5 +++-- builtin/rev-list.c | 3 ++- diagnose.c | 3 ++- midx.c | 2 +- object-file.c | 3 ++- packfile.c | 4 ++-- reachable.c | 3 ++- revision.c | 4 ++-- 14 files changed, 56 insertions(+), 45 deletions(-) diff --git a/builtin/cat-file.c b/builtin/cat-file.c index cc17635e76..0dec21c107 100644 --- a/builtin/cat-file.c +++ b/builtin/cat-file.c @@ -559,16 +559,16 @@ static int batch_object_cb(const struct object_id *oid, void *vdata) } static int collect_loose_object(const struct object_id *oid, - const char *path, + const char *path UNUSED, void *data) { oid_array_append(data, oid); return 0; } static int collect_packed_object(const struct object_id *oid, - struct packed_git *pack, - uint32_t pos, + struct packed_git *pack UNUSED, + uint32_t pos UNUSED, void *data) { oid_array_append(data, oid); @@ -591,7 +591,7 @@ static int batch_unordered_object(const struct object_id *oid, } static int batch_unordered_loose(const struct object_id *oid, - const char *path, + const char *path UNUSED, void *data) { return batch_unordered_object(oid, NULL, 0, data); diff --git a/builtin/count-objects.c b/builtin/count-objects.c index 07b9419596..bb21bc43e4 100644 --- a/builtin/count-objects.c +++ b/builtin/count-objects.c @@ -57,7 +57,8 @@ static void loose_garbage(const char *path) report_garbage(PACKDIR_FILE_GARBAGE, path); } -static int count_loose(const struct object_id *oid, const char *path, void *data) +static int count_loose(const struct object_id *oid, const char *path, + void *data UNUSED) { struct stat st; @@ -72,7 +73,8 @@ static int count_loose(const struct object_id *oid, const char *path, void *data return 0; } -static int count_cruft(const char *basename, const char *path, void *data) +static int count_cruft(const char *basename UNUSED, const char *path, + void *data UNUSED) { loose_garbage(path); return 0; diff --git a/builtin/fsck.c b/builtin/fsck.c index d207bd909b..56aba054ed 100644 --- a/builtin/fsck.c +++ b/builtin/fsck.c @@ -233,17 +233,17 @@ static void mark_unreachable_referents(const struct object_id *oid) } static int mark_loose_unreachable_referents(const struct object_id *oid, - const char *path, - void *data) + const char *path UNUSED, + void *data UNUSED) { mark_unreachable_referents(oid); return 0; } static int mark_packed_unreachable_referents(const struct object_id *oid, - struct packed_git *pack, - uint32_t pos, - void *data) + struct packed_git *pack UNUSED, + uint32_t pos UNUSED, + void *data UNUSED) { mark_unreachable_referents(oid); return 0; @@ -661,14 +661,15 @@ static int fsck_loose(const struct object_id *oid, const char *path, void *data) return 0; /* keep checking other objects, even if we saw an error */ } -static int fsck_cruft(const char *basename, const char *path, void *data) +static int fsck_cruft(const char *basename, const char *path, + void *data UNUSED) { if (!starts_with(basename, "tmp_obj_")) fprintf_ln(stderr, _("bad sha1 file: %s"), path); return 0; } -static int fsck_subdir(unsigned int nr, const char *path, void *data) +static int fsck_subdir(unsigned int nr, const char *path UNUSED, void *data) { struct for_each_loose_cb *cb_data = data; struct progress *progress = cb_data->progress; @@ -803,17 +804,17 @@ static void mark_object_for_connectivity(const struct object_id *oid) } static int mark_loose_for_connectivity(const struct object_id *oid, - const char *path, - void *data) + const char *path UNUSED, + void *data UNUSED) { mark_object_for_connectivity(oid); return 0; } static int mark_packed_for_connectivity(const struct object_id *oid, - struct packed_git *pack, - uint32_t pos, - void *data) + struct packed_git *pack UNUSED, + uint32_t pos UNUSED, + void *data UNUSED) { mark_object_for_connectivity(oid); return 0; diff --git a/builtin/gc.c b/builtin/gc.c index 02455fdcd7..4486438624 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -976,9 +976,9 @@ struct write_loose_object_data { static int loose_object_auto_limit = 100; -static int loose_object_count(const struct object_id *oid, - const char *path, - void *data) +static int loose_object_count(const struct object_id *oid UNUSED, + const char *path UNUSED, + void *data) { int *count = (int*)data; if (++(*count) >= loose_object_auto_limit) @@ -1003,15 +1003,15 @@ static int loose_object_auto_condition(void) NULL, NULL, &count); } -static int bail_on_loose(const struct object_id *oid, - const char *path, - void *data) +static int bail_on_loose(const struct object_id *oid UNUSED, + const char *path UNUSED, + void *data UNUSED) { return 1; } static int write_loose_object_to_stdin(const struct object_id *oid, - const char *path, + const char *path UNUSED, void *data) { struct write_loose_object_data *d = (struct write_loose_object_data *)data; diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index fb92a9686b..d7eebeb6eb 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -3260,13 +3260,14 @@ static int add_object_entry_from_pack(const struct object_id *oid, return 0; } -static void show_commit_pack_hint(struct commit *commit, void *_data) +static void show_commit_pack_hint(struct commit *commit UNUSED, + void *data UNUSED) { /* nothing to do; commits don't have a namehash */ } static void show_object_pack_hint(struct object *object, const char *name, - void *_data) + void *data UNUSED) { struct object_entry *oe = packlist_find(&to_pack, &object->oid); if (!oe) @@ -3762,7 +3763,7 @@ static void show_edge(struct commit *commit) static int add_object_in_unpacked_pack(const struct object_id *oid, struct packed_git *pack, uint32_t pos, - void *_data) + void *data UNUSED) { if (cruft) { off_t offset; @@ -3796,7 +3797,7 @@ static void add_objects_in_unpacked_packs(void) } static int add_loose_object(const struct object_id *oid, const char *path, - void *data) + void *data UNUSED) { enum object_type type = oid_object_info(the_repository, oid, NULL); @@ -3947,13 +3948,13 @@ static int get_object_list_from_bitmap(struct rev_info *revs) } static void record_recent_object(struct object *obj, - const char *name, - void *data) + const char *name UNUSED, + void *data UNUSED) { oid_array_append(&recent_objects, &obj->oid); } -static void record_recent_commit(struct commit *commit, void *data) +static void record_recent_commit(struct commit *commit, void *data UNUSED) { oid_array_append(&recent_objects, &commit->object.oid); } diff --git a/builtin/prune.c b/builtin/prune.c index 2719220108..4580890393 100644 --- a/builtin/prune.c +++ b/builtin/prune.c @@ -98,7 +98,8 @@ static int prune_object(const struct object_id *oid, const char *fullpath, return 0; } -static int prune_cruft(const char *basename, const char *path, void *data) +static int prune_cruft(const char *basename, const char *path, + void *data UNUSED) { if (starts_with(basename, "tmp_obj_")) prune_tmp_file(path); @@ -107,7 +108,8 @@ static int prune_cruft(const char *basename, const char *path, void *data) return 0; } -static int prune_subdir(unsigned int nr, const char *path, void *data) +static int prune_subdir(unsigned int nr UNUSED, const char *path, + void *data UNUSED) { if (!show_only) rmdir(path); diff --git a/builtin/repack.c b/builtin/repack.c index f649379531..36b511c564 100644 --- a/builtin/repack.c +++ b/builtin/repack.c @@ -182,8 +182,9 @@ static void prepare_pack_objects(struct child_process *cmd, * Write oid to the given struct child_process's stdin, starting it first if * necessary. */ -static int write_oid(const struct object_id *oid, struct packed_git *pack, - uint32_t pos, void *data) +static int write_oid(const struct object_id *oid, + struct packed_git *pack UNUSED, + uint32_t pos UNUSED, void *data) { struct child_process *cmd = data; diff --git a/builtin/rev-list.c b/builtin/rev-list.c index cceb5de975..888ad6b5c0 100644 --- a/builtin/rev-list.c +++ b/builtin/rev-list.c @@ -257,7 +257,8 @@ static inline void finish_object__ma(struct object *obj) } } -static int finish_object(struct object *obj, const char *name, void *cb_data) +static int finish_object(struct object *obj, const char *name UNUSED, + void *cb_data) { struct rev_list_info *info = cb_data; if (oid_object_info_extended(the_repository, &obj->oid, NULL, 0) < 0) { diff --git a/diagnose.c b/diagnose.c index 8f26569896..e7c42b3a71 100644 --- a/diagnose.c +++ b/diagnose.c @@ -43,7 +43,8 @@ int option_parse_diagnose(const struct option *opt, const char *arg, int unset) return error(_("invalid --%s value '%s'"), opt->long_name, arg); } -static void dir_file_stats_objects(const char *full_path, size_t full_path_len, +static void dir_file_stats_objects(const char *full_path, + size_t full_path_len UNUSED, const char *file_name, void *data) { struct strbuf *buf = data; diff --git a/midx.c b/midx.c index 7cfad04a24..d761cc50bd 100644 --- a/midx.c +++ b/midx.c @@ -1607,7 +1607,7 @@ struct clear_midx_data { const char *ext; }; -static void clear_midx_file_ext(const char *full_path, size_t full_path_len, +static void clear_midx_file_ext(const char *full_path, size_t full_path_len UNUSED, const char *file_name, void *_data) { struct clear_midx_data *data = _data; diff --git a/object-file.c b/object-file.c index 939865c1ae..389d452e48 100644 --- a/object-file.c +++ b/object-file.c @@ -2644,7 +2644,8 @@ int for_each_loose_object(each_loose_object_fn cb, void *data, return 0; } -static int append_loose_object(const struct object_id *oid, const char *path, +static int append_loose_object(const struct object_id *oid, + const char *path UNUSED, void *data) { oidtree_insert(data, oid); diff --git a/packfile.c b/packfile.c index 79e21ab18e..4dc0e15aa5 100644 --- a/packfile.c +++ b/packfile.c @@ -2204,8 +2204,8 @@ int for_each_packed_object(each_packed_object_fn cb, void *data, } static int add_promisor_object(const struct object_id *oid, - struct packed_git *pack, - uint32_t pos, + struct packed_git *pack UNUSED, + uint32_t pos UNUSED, void *set_) { struct oidset *set = set_; diff --git a/reachable.c b/reachable.c index 08f290c2be..0afe80c203 100644 --- a/reachable.c +++ b/reachable.c @@ -154,7 +154,8 @@ static int add_recent_loose(const struct object_id *oid, } static int add_recent_packed(const struct object_id *oid, - struct packed_git *p, uint32_t pos, + struct packed_git *p, + uint32_t pos, void *data) { struct object *obj; diff --git a/revision.c b/revision.c index 4a24fc3fcd..65fca1ed6c 100644 --- a/revision.c +++ b/revision.c @@ -3440,8 +3440,8 @@ void reset_revision_walk(void) } static int mark_uninteresting(const struct object_id *oid, - struct packed_git *pack, - uint32_t pos, + struct packed_git *pack UNUSED, + uint32_t pos UNUSED, void *cb) { struct rev_info *revs = cb; From patchwork Fri Feb 24 06:39:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff King X-Patchwork-Id: 13150969 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3617DC61DA3 for ; Fri, 24 Feb 2023 06:39:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229796AbjBXGjx (ORCPT ); Fri, 24 Feb 2023 01:39:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229706AbjBXGji (ORCPT ); Fri, 24 Feb 2023 01:39:38 -0500 Received: from cloud.peff.net (cloud.peff.net [104.130.231.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51DBF6355B for ; Thu, 23 Feb 2023 22:39:28 -0800 (PST) Received: (qmail 3693 invoked by uid 109); 24 Feb 2023 06:39:28 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Fri, 24 Feb 2023 06:39:28 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 31119 invoked by uid 111); 24 Feb 2023 06:39:27 -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; Fri, 24 Feb 2023 01:39:27 -0500 Authentication-Results: peff.net; auth=none Date: Fri, 24 Feb 2023 01:39:27 -0500 From: Jeff King To: git@vger.kernel.org Subject: [PATCH 14/21] prio-queue: mark unused parameters in comparison functions Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The prio_queue_compare_fn interface has a void pointer to allow callers to pass arbitrary data, but most comparison functions don't need it. Mark those cases to make -Wunused-parameter happy. Signed-off-by: Jeff King --- commit.c | 6 ++++-- negotiator/skipping.c | 2 +- t/helper/test-prio-queue.c | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/commit.c b/commit.c index e433c33bb0..0606d16e3a 100644 --- a/commit.c +++ b/commit.c @@ -801,7 +801,8 @@ int compare_commits_by_author_date(const void *a_, const void *b_, return 0; } -int compare_commits_by_gen_then_commit_date(const void *a_, const void *b_, void *unused) +int compare_commits_by_gen_then_commit_date(const void *a_, const void *b_, + void *unused UNUSED) { const struct commit *a = a_, *b = b_; const timestamp_t generation_a = commit_graph_generation(a), @@ -821,7 +822,8 @@ int compare_commits_by_gen_then_commit_date(const void *a_, const void *b_, void return 0; } -int compare_commits_by_commit_date(const void *a_, const void *b_, void *unused) +int compare_commits_by_commit_date(const void *a_, const void *b_, + void *unused UNUSED) { const struct commit *a = a_, *b = b_; /* newer commits with larger date first */ diff --git a/negotiator/skipping.c b/negotiator/skipping.c index 0f5ac48e87..4867efc5f5 100644 --- a/negotiator/skipping.c +++ b/negotiator/skipping.c @@ -50,7 +50,7 @@ struct data { int non_common_revs; }; -static int compare(const void *a_, const void *b_, void *unused) +static int compare(const void *a_, const void *b_, void *data UNUSED) { const struct entry *a = a_; const struct entry *b = b_; diff --git a/t/helper/test-prio-queue.c b/t/helper/test-prio-queue.c index 133b5e6f4a..496c7be07d 100644 --- a/t/helper/test-prio-queue.c +++ b/t/helper/test-prio-queue.c @@ -2,7 +2,7 @@ #include "cache.h" #include "prio-queue.h" -static int intcmp(const void *va, const void *vb, void *data) +static int intcmp(const void *va, const void *vb, void *data UNUSED) { const int *a = va, *b = vb; return *a - *b; From patchwork Fri Feb 24 06:39:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff King X-Patchwork-Id: 13150970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4CDCAC677F1 for ; Fri, 24 Feb 2023 06:40:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229815AbjBXGkC (ORCPT ); Fri, 24 Feb 2023 01:40:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229758AbjBXGjo (ORCPT ); Fri, 24 Feb 2023 01:39:44 -0500 Received: from cloud.peff.net (cloud.peff.net [104.130.231.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BCDD61F19 for ; Thu, 23 Feb 2023 22:39:32 -0800 (PST) Received: (qmail 3696 invoked by uid 109); 24 Feb 2023 06:39:32 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Fri, 24 Feb 2023 06:39:32 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 31122 invoked by uid 111); 24 Feb 2023 06:39:31 -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; Fri, 24 Feb 2023 01:39:31 -0500 Authentication-Results: peff.net; auth=none Date: Fri, 24 Feb 2023 01:39:31 -0500 From: Jeff King To: git@vger.kernel.org Subject: [PATCH 15/21] notes: mark unused callback parameters Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org for_each_note() requires a callback, but not all callbacks need all of the parameters. Likewise, init_notes() takes a callback to implement the "combine" strategy, but the "ignore" variant obviously doesn't look at its arguments at all. Mark unused parameters as appropriate to silence compiler warnings. Signed-off-by: Jeff King --- builtin/notes.c | 5 +++-- notes.c | 11 ++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/builtin/notes.c b/builtin/notes.c index 80d9dfd25c..d5713a9fac 100644 --- a/builtin/notes.c +++ b/builtin/notes.c @@ -113,8 +113,9 @@ static void free_note_data(struct note_data *d) } static int list_each_note(const struct object_id *object_oid, - const struct object_id *note_oid, char *note_path, - void *cb_data) + const struct object_id *note_oid, + char *note_path UNUSED, + void *cb_data UNUSED) { printf("%s %s\n", oid_to_hex(note_oid), oid_to_hex(object_oid)); return 0; diff --git a/notes.c b/notes.c index f2805d51bb..20af123d91 100644 --- a/notes.c +++ b/notes.c @@ -752,7 +752,7 @@ static int write_each_non_note_until(const char *note_path, return 0; } -static int write_each_note(const struct object_id *object_oid, +static int write_each_note(const struct object_id *object_oid UNUSED, const struct object_id *note_oid, char *note_path, void *cb_data) { @@ -780,8 +780,9 @@ struct note_delete_list { }; static int prune_notes_helper(const struct object_id *object_oid, - const struct object_id *note_oid, char *note_path, - void *cb_data) + const struct object_id *note_oid UNUSED, + char *note_path UNUSED, + void *cb_data) { struct note_delete_list **l = (struct note_delete_list **) cb_data; struct note_delete_list *n; @@ -848,8 +849,8 @@ int combine_notes_overwrite(struct object_id *cur_oid, return 0; } -int combine_notes_ignore(struct object_id *cur_oid, - const struct object_id *new_oid) +int combine_notes_ignore(struct object_id *cur_oid UNUSED, + const struct object_id *new_oid UNUSED) { return 0; } From patchwork Fri Feb 24 06:39:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff King X-Patchwork-Id: 13150971 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF537C61DA3 for ; Fri, 24 Feb 2023 06:40:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229827AbjBXGkJ (ORCPT ); Fri, 24 Feb 2023 01:40:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229781AbjBXGjr (ORCPT ); Fri, 24 Feb 2023 01:39:47 -0500 Received: from cloud.peff.net (cloud.peff.net [104.130.231.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88E9D61F1C for ; Thu, 23 Feb 2023 22:39:36 -0800 (PST) Received: (qmail 3699 invoked by uid 109); 24 Feb 2023 06:39:36 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Fri, 24 Feb 2023 06:39:36 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 31125 invoked by uid 111); 24 Feb 2023 06:39:35 -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; Fri, 24 Feb 2023 01:39:35 -0500 Authentication-Results: peff.net; auth=none Date: Fri, 24 Feb 2023 01:39:35 -0500 From: Jeff King To: git@vger.kernel.org Subject: [PATCH 16/21] fetch-pack: mark unused parameter in callback function Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The for_each_cached_alternate() interface requires a callback that takes a negotiator parameter, but not all implementations need it. Mark the unused one as such to appease -Wunused-parameter. Signed-off-by: Jeff King --- fetch-pack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fetch-pack.c b/fetch-pack.c index 04016d1e32..67a7786865 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -722,7 +722,7 @@ static void filter_refs(struct fetch_pack_args *args, *refs = newlist; } -static void mark_alternate_complete(struct fetch_negotiator *unused, +static void mark_alternate_complete(struct fetch_negotiator *negotiator UNUSED, struct object *obj) { mark_complete(&obj->oid); From patchwork Fri Feb 24 06:39:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff King X-Patchwork-Id: 13150972 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F019C678D5 for ; Fri, 24 Feb 2023 06:40:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229837AbjBXGkK (ORCPT ); Fri, 24 Feb 2023 01:40:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229762AbjBXGju (ORCPT ); Fri, 24 Feb 2023 01:39:50 -0500 Received: from cloud.peff.net (cloud.peff.net [104.130.231.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37EA563568 for ; Thu, 23 Feb 2023 22:39:38 -0800 (PST) Received: (qmail 3702 invoked by uid 109); 24 Feb 2023 06:39:39 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Fri, 24 Feb 2023 06:39:39 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 31128 invoked by uid 111); 24 Feb 2023 06:39:38 -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; Fri, 24 Feb 2023 01:39:38 -0500 Authentication-Results: peff.net; auth=none Date: Fri, 24 Feb 2023 01:39:37 -0500 From: Jeff King To: git@vger.kernel.org Subject: [PATCH 17/21] rewrite_parents(): mark unused callback parameter Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The rewrite_parents() function takes a callback, but not every callback needs the "rev" parameter. Mark the unused one so -Wunused-parameter will be happy. Signed-off-by: Jeff King --- line-log.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/line-log.c b/line-log.c index a7f3e7f6ce..1ab2d75f29 100644 --- a/line-log.c +++ b/line-log.c @@ -1281,7 +1281,8 @@ int line_log_process_ranges_arbitrary_commit(struct rev_info *rev, struct commit return changed; } -static enum rewrite_result line_log_rewrite_one(struct rev_info *rev, struct commit **pp) +static enum rewrite_result line_log_rewrite_one(struct rev_info *rev UNUSED, + struct commit **pp) { for (;;) { struct commit *p = *pp; From patchwork Fri Feb 24 06:39:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff King X-Patchwork-Id: 13150973 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04143C677F1 for ; Fri, 24 Feb 2023 06:40:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229699AbjBXGkQ (ORCPT ); Fri, 24 Feb 2023 01:40:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229692AbjBXGj6 (ORCPT ); Fri, 24 Feb 2023 01:39:58 -0500 Received: from cloud.peff.net (cloud.peff.net [104.130.231.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4513961ED1 for ; Thu, 23 Feb 2023 22:39:42 -0800 (PST) Received: (qmail 3707 invoked by uid 109); 24 Feb 2023 06:39:42 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Fri, 24 Feb 2023 06:39:42 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 31131 invoked by uid 111); 24 Feb 2023 06:39:41 -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; Fri, 24 Feb 2023 01:39:41 -0500 Authentication-Results: peff.net; auth=none Date: Fri, 24 Feb 2023 01:39:40 -0500 From: Jeff King To: git@vger.kernel.org Subject: [PATCH 18/21] for_each_commit_graft(): mark unused callback parameter Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The for_each_commit_graft() functions takes a callback, but not every callback uses the void data parameter. Mark the unused one to appease the -Wunused-parameter warning. Signed-off-by: Jeff King --- log-tree.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/log-tree.c b/log-tree.c index 1dd5fcbf7b..0f08864ae8 100644 --- a/log-tree.c +++ b/log-tree.c @@ -196,7 +196,8 @@ static int add_ref_decoration(const char *refname, const struct object_id *oid, return 0; } -static int add_graft_decoration(const struct commit_graft *graft, void *cb_data) +static int add_graft_decoration(const struct commit_graft *graft, + void *cb_data UNUSED) { struct commit *commit = lookup_commit(the_repository, &graft->oid); if (!commit) From patchwork Fri Feb 24 06:39:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff King X-Patchwork-Id: 13150974 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3911CC61DA3 for ; Fri, 24 Feb 2023 06:40:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229800AbjBXGkV (ORCPT ); Fri, 24 Feb 2023 01:40:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229610AbjBXGj7 (ORCPT ); Fri, 24 Feb 2023 01:39:59 -0500 Received: from cloud.peff.net (cloud.peff.net [104.130.231.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 350B161EF4 for ; Thu, 23 Feb 2023 22:39:45 -0800 (PST) Received: (qmail 3710 invoked by uid 109); 24 Feb 2023 06:39:45 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Fri, 24 Feb 2023 06:39:45 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 31134 invoked by uid 111); 24 Feb 2023 06:39:44 -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; Fri, 24 Feb 2023 01:39:44 -0500 Authentication-Results: peff.net; auth=none Date: Fri, 24 Feb 2023 01:39:43 -0500 From: Jeff King To: git@vger.kernel.org Subject: [PATCH 19/21] userformat_want_item(): mark unused parameter Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org This function is used as a callback to strbuf_expand(), so it must conform to the correct interface. But naturally it doesn't need to touch its "sb" parameter, since it is only examining the placeholder string, and not actually writing any output. So mark the unused parameter to silence -Wunused-parameter. Signed-off-by: Jeff King --- pretty.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pretty.c b/pretty.c index 1e1e21878c..2e47292407 100644 --- a/pretty.c +++ b/pretty.c @@ -1857,7 +1857,8 @@ static size_t format_commit_item(struct strbuf *sb, /* in UTF-8 */ return consumed + 1; } -static size_t userformat_want_item(struct strbuf *sb, const char *placeholder, +static size_t userformat_want_item(struct strbuf *sb UNUSED, + const char *placeholder, void *context) { struct userformat_want *w = context; From patchwork Fri Feb 24 06:39:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff King X-Patchwork-Id: 13150975 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 187CFC61DA3 for ; Fri, 24 Feb 2023 06:40:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229839AbjBXGk1 (ORCPT ); Fri, 24 Feb 2023 01:40:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229806AbjBXGkA (ORCPT ); Fri, 24 Feb 2023 01:40:00 -0500 Received: from cloud.peff.net (cloud.peff.net [104.130.231.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A065D63540 for ; Thu, 23 Feb 2023 22:39:47 -0800 (PST) Received: (qmail 3713 invoked by uid 109); 24 Feb 2023 06:39:47 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Fri, 24 Feb 2023 06:39:47 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 31137 invoked by uid 111); 24 Feb 2023 06:39:46 -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; Fri, 24 Feb 2023 01:39:46 -0500 Authentication-Results: peff.net; auth=none Date: Fri, 24 Feb 2023 01:39:46 -0500 From: Jeff King To: git@vger.kernel.org Subject: [PATCH 20/21] run_processes_parallel: mark unused callback parameters Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Our parallel process API takes several callbacks via function pointers in the run_process_paralell_opts struct. Not every callback needs every parameter; let's mark the unused ones to make -Wunused-parameter happy. Signed-off-by: Jeff King --- builtin/fetch.c | 6 ++++-- builtin/submodule--helper.c | 4 ++-- hook.c | 12 ++++++------ submodule.c | 4 ++-- t/helper/test-run-command.c | 14 +++++++------- 5 files changed, 21 insertions(+), 19 deletions(-) diff --git a/builtin/fetch.c b/builtin/fetch.c index a21ce89312..c6b1845429 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -1890,7 +1890,8 @@ struct parallel_fetch_state { int next, result; }; -static int fetch_next_remote(struct child_process *cp, struct strbuf *out, +static int fetch_next_remote(struct child_process *cp, + struct strbuf *out UNUSED, void *cb, void **task_cb) { struct parallel_fetch_state *state = cb; @@ -1912,7 +1913,8 @@ static int fetch_next_remote(struct child_process *cp, struct strbuf *out, return 1; } -static int fetch_failed_to_start(struct strbuf *out, void *cb, void *task_cb) +static int fetch_failed_to_start(struct strbuf *out UNUSED, + void *cb, void *task_cb) { struct parallel_fetch_state *state = cb; const char *remote = task_cb; diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 4c173d8b37..ad272a0d93 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -2132,9 +2132,9 @@ static int update_clone_get_next_task(struct child_process *child, return 0; } -static int update_clone_start_failure(struct strbuf *err, +static int update_clone_start_failure(struct strbuf *err UNUSED, void *suc_cb, - void *idx_task_cb) + void *idx_task_cb UNUSED) { struct submodule_update_clone *suc = suc_cb; diff --git a/hook.c b/hook.c index 1a84831863..866ef0408b 100644 --- a/hook.c +++ b/hook.c @@ -43,9 +43,9 @@ int hook_exists(const char *name) } static int pick_next_hook(struct child_process *cp, - struct strbuf *out, + struct strbuf *out UNUSED, void *pp_cb, - void **pp_task_cb) + void **pp_task_cb UNUSED) { struct hook_cb_data *hook_cb = pp_cb; const char *hook_path = hook_cb->hook_path; @@ -77,9 +77,9 @@ static int pick_next_hook(struct child_process *cp, return 1; } -static int notify_start_failure(struct strbuf *out, +static int notify_start_failure(struct strbuf *out UNUSED, void *pp_cb, - void *pp_task_cp) + void *pp_task_cp UNUSED) { struct hook_cb_data *hook_cb = pp_cb; @@ -89,9 +89,9 @@ static int notify_start_failure(struct strbuf *out, } static int notify_hook_finished(int result, - struct strbuf *out, + struct strbuf *out UNUSED, void *pp_cb, - void *pp_task_cb) + void *pp_task_cb UNUSED) { struct hook_cb_data *hook_cb = pp_cb; struct run_hooks_opt *opt = hook_cb->options; diff --git a/submodule.c b/submodule.c index 3a0dfc417c..a24269db71 100644 --- a/submodule.c +++ b/submodule.c @@ -1739,7 +1739,7 @@ static int get_next_submodule(struct child_process *cp, struct strbuf *err, return 0; } -static int fetch_start_failure(struct strbuf *err, +static int fetch_start_failure(struct strbuf *err UNUSED, void *cb, void *task_cb) { struct submodule_parallel_fetch *spf = cb; @@ -1760,7 +1760,7 @@ static int commit_missing_in_sub(const struct object_id *oid, void *data) return type != OBJ_COMMIT; } -static int fetch_finish(int retvalue, struct strbuf *err, +static int fetch_finish(int retvalue, struct strbuf *err UNUSED, void *cb, void *task_cb) { struct submodule_parallel_fetch *spf = cb; diff --git a/t/helper/test-run-command.c b/t/helper/test-run-command.c index 3ecb830f4a..98fa224640 100644 --- a/t/helper/test-run-command.c +++ b/t/helper/test-run-command.c @@ -24,7 +24,7 @@ static int number_callbacks; static int parallel_next(struct child_process *cp, struct strbuf *err, void *cb, - void **task_cb) + void **task_cb UNUSED) { struct child_process *d = cb; if (number_callbacks >= 4) @@ -40,10 +40,10 @@ static int parallel_next(struct child_process *cp, return 1; } -static int no_job(struct child_process *cp, +static int no_job(struct child_process *cp UNUSED, struct strbuf *err, - void *cb, - void **task_cb) + void *cb UNUSED, + void **task_cb UNUSED) { if (err) strbuf_addstr(err, "no further jobs available\n"); @@ -52,10 +52,10 @@ static int no_job(struct child_process *cp, return 0; } -static int task_finished(int result, +static int task_finished(int result UNUSED, struct strbuf *err, - void *pp_cb, - void *pp_task_cb) + void *pp_cb UNUSED, + void *pp_task_cb UNUSED) { if (err) strbuf_addstr(err, "asking for a quick stop\n"); From patchwork Fri Feb 24 06:39:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff King X-Patchwork-Id: 13150976 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A897AC678D5 for ; Fri, 24 Feb 2023 06:40:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229843AbjBXGk2 (ORCPT ); Fri, 24 Feb 2023 01:40:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229618AbjBXGkB (ORCPT ); Fri, 24 Feb 2023 01:40:01 -0500 Received: from cloud.peff.net (cloud.peff.net [104.130.231.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07D0460D7E for ; Thu, 23 Feb 2023 22:39:49 -0800 (PST) Received: (qmail 3716 invoked by uid 109); 24 Feb 2023 06:39:49 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Fri, 24 Feb 2023 06:39:49 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 31140 invoked by uid 111); 24 Feb 2023 06:39:49 -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; Fri, 24 Feb 2023 01:39:49 -0500 Authentication-Results: peff.net; auth=none Date: Fri, 24 Feb 2023 01:39:48 -0500 From: Jeff King To: git@vger.kernel.org Subject: [PATCH 21/21] help: mark unused parameter in git_unknown_cmd_config() Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The extra callback parameter became unused in 0918d08887 (help.c: fix autocorrect in work tree for bare repository, 2022-10-29), but we can't get rid of it because we must conform to the config callback interface. Signed-off-by: Jeff King --- help.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/help.c b/help.c index 812af4cdea..8393c25586 100644 --- a/help.c +++ b/help.c @@ -540,7 +540,8 @@ static struct cmdnames aliases; #define AUTOCORRECT_NEVER (-2) #define AUTOCORRECT_IMMEDIATELY (-1) -static int git_unknown_cmd_config(const char *var, const char *value, void *cb) +static int git_unknown_cmd_config(const char *var, const char *value, + void *cb UNUSED) { const char *p;