git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Miriam Rubio <mirucam@gmail.com>
Cc: git@vger.kernel.org, Pranit Bauva <pranit.bauva@gmail.com>,
	Lars Schneider <larsxschneider@gmail.com>,
	Christian Couder <chriscool@tuxfamily.org>,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	Tanushree Tumane <tanushreetumane@gmail.com>
Subject: Re: [PATCH v3 2/7] bisect--helper: reimplement `bisect_replay` shell function in C
Date: Sat, 23 Jan 2021 21:13:32 -0800	[thread overview]
Message-ID: <xmqqr1ma29z7.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <xmqq35yr2nh0.fsf@gitster.c.googlers.com> (Junio C. Hamano's message of "Sat, 23 Jan 2021 16:22:03 -0800")

Junio C Hamano <gitster@pobox.com> writes:

> Miriam Rubio <mirucam@gmail.com> writes:
>
>> From: Pranit Bauva <pranit.bauva@gmail.com>
>>
>> Reimplement the `bisect_replay` shell function in C and also add
>> `--bisect-replay` subcommand to `git bisect--helper` to call it from
>> git-bisect.sh
>> ...
>> +static int process_replay_line(struct bisect_terms *terms, struct strbuf *line)
>> +{
>> +	const char *p = line->buf + strspn(line->buf, " \t");
>> +
>> +	if ((!skip_prefix(p, "git bisect", &p) &&
>> +	!skip_prefix(p, "git-bisect", &p)) || !isspace(*p))
>> +		return 0;
>> +	p += strspn(p, " \t");
>> +
>> +	char *word_end = (char*)p + strcspn(p, " \t");
>> +	char *rev = word_end + strspn(word_end, " \t");
>
> Are these lines new in this round?
>
> These break builds with -Werror=declaration-after-statement.


The following fix-up is tentatively queued at the tip of the topic
in tonight's pushout.  There might be better way to do what this
function is doing (especially I am skeptical about the way the code
casts const away), so please don't blindly trust it, but at least it
should please the compiler.

(char*) should be spelled (char *), by the way.

Thanks.


diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c
index 3b0a6a7d0c..c673f87795 100644
--- a/builtin/bisect--helper.c
+++ b/builtin/bisect--helper.c
@@ -918,14 +918,15 @@ static enum bisect_error bisect_log(void)
 static int process_replay_line(struct bisect_terms *terms, struct strbuf *line)
 {
 	const char *p = line->buf + strspn(line->buf, " \t");
+	char *word_end, *rev;
 
 	if ((!skip_prefix(p, "git bisect", &p) &&
 	!skip_prefix(p, "git-bisect", &p)) || !isspace(*p))
 		return 0;
 	p += strspn(p, " \t");
 
-	char *word_end = (char*)p + strcspn(p, " \t");
-	char *rev = word_end + strspn(word_end, " \t");
+	word_end = (char*)p + strcspn(p, " \t");
+	rev = word_end + strspn(word_end, " \t");
 	*word_end = '\0'; /* NUL-terminate the word */
 
 	get_terms(terms);
-- 
2.30.0-492-gde1138eff7


  reply	other threads:[~2021-01-24  5:14 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-23 15:40 [PATCH v3 0/7] Finish converting git bisect to C part 3 Miriam Rubio
2021-01-23 15:40 ` [PATCH v3 1/7] bisect--helper: reimplement `bisect_log` shell function in C Miriam Rubio
2021-01-24 13:56   ` Rafael Silva
2021-01-25 19:23     ` Miriam R.
2021-01-26 18:32       ` Junio C Hamano
2021-01-27 14:10         ` Miriam R.
2021-01-23 15:40 ` [PATCH v3 2/7] bisect--helper: reimplement `bisect_replay` " Miriam Rubio
2021-01-24  0:22   ` Junio C Hamano
2021-01-24  5:13     ` Junio C Hamano [this message]
2021-01-25 19:18     ` Miriam R.
2021-01-23 15:40 ` [PATCH v3 3/7] bisect--helper: retire `--bisect-write` subcommand Miriam Rubio
2021-01-23 15:40 ` [PATCH v3 4/7] bisect--helper: use `res` instead of return in BISECT_RESET case option Miriam Rubio
2021-01-23 15:40 ` [PATCH v3 5/7] bisect--helper: retire `--bisect-auto-next` subcommand Miriam Rubio
2021-01-23 15:40 ` [PATCH v3 6/7] bisect--helper: reimplement `bisect_skip` shell function in C Miriam Rubio
2021-01-23 15:40 ` [PATCH v3 7/7] bisect--helper: retire `--check-and-set-terms` subcommand Miriam Rubio
2021-01-26  1:58 ` [PATCH v3 0/7] Finish converting git bisect to C part 3 Junio C Hamano
2021-01-26 14:18   ` Miriam R.
2021-01-26 19:12     ` Junio C Hamano
2021-01-27 14:11       ` Miriam R.

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

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

  git send-email \
    --in-reply-to=xmqqr1ma29z7.fsf@gitster.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=chriscool@tuxfamily.org \
    --cc=git@vger.kernel.org \
    --cc=larsxschneider@gmail.com \
    --cc=mirucam@gmail.com \
    --cc=pranit.bauva@gmail.com \
    --cc=tanushreetumane@gmail.com \
    /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.
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 NNTP newsgroup(s).