git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Bruno Albuquerque <bga@google.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] object-info: support for retrieving object info
Date: Thu, 15 Apr 2021 15:15:09 -0700	[thread overview]
Message-ID: <xmqqmttznqj6.fsf@gitster.g> (raw)
In-Reply-To: <20210415212017.1407303-1-bga@google.com> (Bruno Albuquerque's message of "Thu, 15 Apr 2021 14:20:17 -0700")

Bruno Albuquerque <bga@google.com> writes:

> +int cap_object_info(struct repository *r, struct strvec *keys,
> +		    struct packet_reader *request)
> +{
> +	struct packet_writer writer;
> +	packet_writer_init(&writer, 1);

This triggers -Wdeclaration-after-statement below.  Move it down.

> +	int parsed_header;
> +	struct requested_info info;
> +

Puzzling blank line here.  There does not seem to be a good reason
why 'parsed_header' bit plus 'info' pair together closely than to
the other 'oid_str_list' variable, so it does not make much sense as
a grouping aid.

> +	struct string_list oid_str_list = STRING_LIST_INIT_DUP;
> +

Here, just before "parsed_header = 0;" after the blank line that
separates the decls and the statements, is a good place to say
"packet_writer_init()".  Also it may make more sense to give initial
value to parsed_header where it is declared.

> +	parsed_header = 0;
> +	while (packet_reader_read(request) == PACKET_READ_NORMAL) {
> +		if (!strcmp("size", request->line)) {
> +			info.size = 1;
> +			continue;

And upon further inspection, nobody seems to use parsed_header at
all.  Let's lose it.

Perhaps this minimum fix-up squashed in?

Next time, perhaps try "make DEVELOPER=YesPlease test" to catch
possible problems like these early?

Thanks.


 protocol-caps.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git c/protocol-caps.c w/protocol-caps.c
index c15e397756..922bfeb905 100644
--- c/protocol-caps.c
+++ w/protocol-caps.c
@@ -78,13 +78,10 @@ int cap_object_info(struct repository *r, struct strvec *keys,
 		    struct packet_reader *request)
 {
 	struct packet_writer writer;
-	packet_writer_init(&writer, 1);
-	int parsed_header;
 	struct requested_info info;
-
 	struct string_list oid_str_list = STRING_LIST_INIT_DUP;
 
-	parsed_header = 0;
+	packet_writer_init(&writer, 1);
 	while (packet_reader_read(request) == PACKET_READ_NORMAL) {
 		if (!strcmp("size", request->line)) {
 			info.size = 1;


  parent reply	other threads:[~2021-04-15 22:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-15 21:20 [PATCH] object-info: support for retrieving object info Bruno Albuquerque
2021-04-15 21:53 ` Junio C Hamano
2021-04-15 23:06   ` Bruno Albuquerque
2021-04-15 22:15 ` Junio C Hamano [this message]
2021-04-20 23:43   ` Bruno Albuquerque
2021-04-16 22:01 ` brian m. carlson
2021-04-19 21:18   ` Bruno Albuquerque

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqmttznqj6.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=bga@google.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).