git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: "René Scharfe" <l.s.r@web.de>
Cc: Git Mailing List <git@vger.kernel.org>,
	Junio C Hamano <gitster@pobox.com>, Mike Hommey <mh@glandium.org>
Subject: Re: [PATCH] grep: use return value of strbuf_detach()
Date: Mon, 26 Aug 2019 16:58:53 +0200 (CEST)	[thread overview]
Message-ID: <nycvar.QRO.7.76.6.1908261658210.46@tvgsbejvaqbjf.bet> (raw)
In-Reply-To: <caf49742-65ee-7b2a-0179-ee11822b2350@web.de>

[-- Attachment #1: Type: text/plain, Size: 1108 bytes --]

Hi René,

On Sun, 25 Aug 2019, René Scharfe wrote:

> Append the strbuf buffer only after detaching it.  There is no practical
> difference here, as the strbuf is not empty and no strbuf_ function is
> called between storing the pointer to the still attached buffer and
> calling strbuf_detach(), so that pointer is valid, but make sure to
> follow the standard sequence anyway for consistency.

ACK!

Thanks,
Dscho

>
> Signed-off-by: René Scharfe <l.s.r@web.de>
> ---
>  builtin/grep.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/builtin/grep.c b/builtin/grep.c
> index 2699001fbd..69ac053acc 100644
> --- a/builtin/grep.c
> +++ b/builtin/grep.c
> @@ -1110,8 +1110,8 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
>  			strbuf_addf(&buf, "+/%s%s",
>  					strcmp("less", pager) ? "" : "*",
>  					opt.pattern_list->pattern);
> -			string_list_append(&path_list, buf.buf);
> -			strbuf_detach(&buf, NULL);
> +			string_list_append(&path_list,
> +					   strbuf_detach(&buf, NULL));
>  		}
>  	}
>
> --
> 2.23.0
>

      reply	other threads:[~2019-08-26 14:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-25 13:26 [PATCH] grep: use return value of strbuf_detach() René Scharfe
2019-08-26 14:58 ` Johannes Schindelin [this message]

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=nycvar.QRO.7.76.6.1908261658210.46@tvgsbejvaqbjf.bet \
    --to=johannes.schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=l.s.r@web.de \
    --cc=mh@glandium.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.
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).