{"thread":{"id":"51730","subject":"[PATCH] trace2: use warning() directly in tr2_dst_malformed_warning()","startedAt":"2019-08-25T17:44:21Z","lastAt":"2019-09-04T09:14:08Z","messageCount":2,"participants":["René Scharfe","Jeff Hostetler"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"381117","messageId":"2492824a-6aff-8b82-801a-808ee944a99e@web.de","threadId":"51730","inReplyTo":null,"subject":"[PATCH] trace2: use warning() directly in tr2_dst_malformed_warning()","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2019-08-25T17:44:10Z","receivedAt":"2019-08-25T17:44:21Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Let warning() format the message instead of using an intermediate strbuf\nfor that.  This is shorter, easier to read and avoids an allocation.\n\nSigned-off-by: René Scharfe <l.s.r@web.de>\n---\n trace2/tr2_dst.c | 9 ++-------\n 1 file changed, 2 insertions(+), 7 deletions(-)\n\ndiff --git a/trace2/tr2_dst.c b/trace2/tr2_dst.c\nindex 5dda0ca1cd..c69857515f 100644\n--- a/trace2/tr2_dst.c\n+++ b/trace2/tr2_dst.c\n@@ -215,13 +215,8 @@ static int tr2_dst_try_unix_domain_socket(struct tr2_dst *dst,\n static void tr2_dst_malformed_warning(struct tr2_dst *dst,\n \t\t\t\t      const char *tgt_value)\n {\n-\tstruct strbuf buf = STRBUF_INIT;\n-\n-\tstrbuf_addf(&buf, \"trace2: unknown value for '%s': '%s'\",\n-\t\t    tr2_sysenv_display_name(dst->sysenv_var), tgt_value);\n-\twarning(\"%s\", buf.buf);\n-\n-\tstrbuf_release(&buf);\n+\twarning(\"trace2: unknown value for '%s': '%s'\",\n+\t\ttr2_sysenv_display_name(dst->sysenv_var), tgt_value);\n }\n\n int tr2_dst_get_trace_fd(struct tr2_dst *dst)\n--\n2.23.0\n\n"},{"id":"381796","messageId":"04604b38-73c1-23e2-77a0-cb716beb507e@jeffhostetler.com","threadId":"51730","inReplyTo":"2492824a-6aff-8b82-801a-808ee944a99e@web.de","subject":"Re: [PATCH] trace2: use warning() directly in tr2_dst_malformed_warning()","fromName":"Jeff Hostetler","fromEmail":"git@jeffhostetler.com","sentAt":"2019-09-04T09:14:04Z","receivedAt":"2019-09-04T09:14:08Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"\n\nOn 8/25/2019 1:44 PM, René Scharfe wrote:\n> Let warning() format the message instead of using an intermediate strbuf\n> for that.  This is shorter, easier to read and avoids an allocation.\n> \n> Signed-off-by: René Scharfe <l.s.r@web.de>\n> ---\n>   trace2/tr2_dst.c | 9 ++-------\n>   1 file changed, 2 insertions(+), 7 deletions(-)\n> \n> diff --git a/trace2/tr2_dst.c b/trace2/tr2_dst.c\n> index 5dda0ca1cd..c69857515f 100644\n> --- a/trace2/tr2_dst.c\n> +++ b/trace2/tr2_dst.c\n> @@ -215,13 +215,8 @@ static int tr2_dst_try_unix_domain_socket(struct tr2_dst *dst,\n>   static void tr2_dst_malformed_warning(struct tr2_dst *dst,\n>   \t\t\t\t      const char *tgt_value)\n>   {\n> -\tstruct strbuf buf = STRBUF_INIT;\n> -\n> -\tstrbuf_addf(&buf, \"trace2: unknown value for '%s': '%s'\",\n> -\t\t    tr2_sysenv_display_name(dst->sysenv_var), tgt_value);\n> -\twarning(\"%s\", buf.buf);\n> -\n> -\tstrbuf_release(&buf);\n> +\twarning(\"trace2: unknown value for '%s': '%s'\",\n> +\t\ttr2_sysenv_display_name(dst->sysenv_var), tgt_value);\n>   }\n> \n>   int tr2_dst_get_trace_fd(struct tr2_dst *dst)\n> --\n> 2.23.0\n> \n\ngood catch!  thanks!\n\nJeff\n"}]}