* [PATCH] grep: use return value of strbuf_detach()
@ 2019-08-25 13:26 René Scharfe
2019-08-26 14:58 ` Johannes Schindelin
0 siblings, 1 reply; 2+ messages in thread
From: René Scharfe @ 2019-08-25 13:26 UTC (permalink / raw)
To: Git Mailing List; +Cc: Junio C Hamano, Mike Hommey, Johannes Schindelin
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.
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] grep: use return value of strbuf_detach()
2019-08-25 13:26 [PATCH] grep: use return value of strbuf_detach() René Scharfe
@ 2019-08-26 14:58 ` Johannes Schindelin
0 siblings, 0 replies; 2+ messages in thread
From: Johannes Schindelin @ 2019-08-26 14:58 UTC (permalink / raw)
To: René Scharfe; +Cc: Git Mailing List, Junio C Hamano, Mike Hommey
[-- 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
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-08-26 14:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-25 13:26 [PATCH] grep: use return value of strbuf_detach() René Scharfe
2019-08-26 14:58 ` Johannes Schindelin
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).