Re: [PATCH v7 1/6] cat-file: add declaration of variable i inside its for loop
On Mon, Nov 25, 2024 at 4:51 AM Patrick Steinhardt <ps@pks.im> wrote:
Show 23 quoted lines
>
> On Mon, Nov 25, 2024 at 12:36:11AM -0500, Eric Ju wrote:
> > diff --git a/fetch-pack.c b/fetch-pack.c
> > index fe1fb3c1b7..bb7ec96963 100644
> > --- a/fetch-pack.c
> > +++ b/fetch-pack.c
> > @@ -1328,9 +1328,8 @@ static void write_fetch_command_and_capabilities(struct strbuf *req_buf,
> > if (advertise_sid && server_supports_v2("session-id"))
> > packet_buf_write(req_buf, "session-id=%s", trace2_session_id());
> > if (server_options && server_options->nr) {
> > - int i;
> > ensure_server_supports_v2("server-option");
> > - for (i = 0; i < server_options->nr; i++)
> > + for (int i = 0; i < server_options->nr; i++)
> > packet_buf_write(req_buf, "server-option=%s",
> > server_options->items[i].string);
> > }
>
> It's somewhat curious that you change the type to `size_t` while at it
> in other spots, but not here. Doubly so because `server_options` is a
> `struct string_list`, and `string_list::nr` is of type `size_t`.
>
> PatrickThank you.
Yes, I missed that. Will correct it in v8.