git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 4/4] transport: mark unused parameters in fetch_refs_from_bundle()

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 17, 2023, 20:28 UTC
Message-ID
<xmqq7cvfgm0v.fsf@gitster.g>
In-Reply-To
<ZBS8vt97YJj3wMxn@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 14 quoted lines
> We don't look at the "to_fetch" or "nr_heads" parameters at all. At
> first glance this seems like a bug (or at least pessimisation), because
> it means we fetch more objects from the bundle than we actually need.
> But the bundle does not have any way of computing the set of reachable
> objects itself (we'd have to pull all of the objects out to walk them).
> And anyway, we've probably already paid most of the cost of grabbing the
> objects, since we must copy the bundle locally before accessing it.
>
> So it's perfectly reasonable for the bundle code to just pull everything
> into the local object store. Unneeded objects can be dropped later via
> gc, etc.
>
> But we should mark these unused parameters as such to avoid the wrath of
> -Wunused-parameter.
Very well described, and I agree with the reasoning.
Will queue all four.  Thanks.
Show 20 quoted lines
>
> Signed-off-by: Jeff King <peff@peff.net>
> ---
>  transport.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/transport.c b/transport.c
> index 81950bf755f..c5abf26f31e 100644
> --- a/transport.c
> +++ b/transport.c
> @@ -167,7 +167,8 @@ static struct ref *get_refs_from_bundle(struct transport *transport,
>  }
>  
>  static int fetch_refs_from_bundle(struct transport *transport,
> -			       int nr_heads, struct ref **to_fetch)
> +				  int nr_heads UNUSED,
> +				  struct ref **to_fetch UNUSED)
>  {
>  	struct bundle_transport_data *data = transport->data;
>  	struct strvec extra_index_pack_args = STRVEC_INIT;
Previous: Jeff King
Message 8 of 8 in “more unused-parameter fixes”
  1. 0/4 more unused-parameter fixesJeff King, Mar 17, 2023
  2. 1/4 mailmap: drop debugging codeJeff King, Mar 17, 2023
  3. Eric SunshineMar 17, 2023
  4. Jeff KingMar 17, 2023
  5. 2/4 http: drop unused parameter from start_object_request()Jeff King, Mar 17, 2023
  6. 3/4 http: mark unused parameter in fill_active_slot() callbacksJeff King, Mar 17, 2023
  7. 4/4 transport: mark unused parameters in fetch_refs_from_bundle()Jeff King, Mar 17, 2023
  8. Junio C HamanoMar 17, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.