From: Jeff Hostetler via GitGitGadget Date: Tue, 04 Oct 2022 16:20:04 GMT Subject: [PATCH 6/9] trace2: convert ctx.thread_name to flex array Message-ID: <6492b6d2b989e08bb539fff3ffe5bdf50fa0a195.1664900407.git.gitgitgadget@gmail.com> In-Reply-To: From: Jeff Hostetler Convert the `tr2tls_thread_ctx.thread_name` field from a `strbuf` to a "flex array" at the end of the context structure. The `thread_name` field is a constant string that is constructed when the context is created. Using a (non-const) `strbuf` structure for it caused some confusion in the past because it implied that someone could rename a thread after it was created. That usage was not intended. Changing it to a "flex array" will hopefully make the intent more clear. Also, move the maximum thread_name truncation to tr2_tgt_perf.c because it is the only target that needs to worry about output column alignment. Signed-off-by: Jeff Hostetler --- trace2/tr2_tgt_event.c | 2 +- trace2/tr2_tgt_perf.c | 8 ++++++-- trace2/tr2_tls.c | 25 +++++++++++++------------ trace2/tr2_tls.h | 9 +-------- 4 files changed, 21 insertions(+), 23 deletions(-) diff --git a/trace2/tr2_tgt_event.c b/trace2/tr2_tgt_event.c index 37a3163be12..52f9356c695 100644 --- a/trace2/tr2_tgt_event.c +++ b/trace2/tr2_tgt_event.c @@ -90,7 +90,7 @@ static void event_fmt_prepare(const char *event_name, const char *file, jw_object_string(jw, "event", event_name); jw_object_string(jw, "sid", tr2_sid_get()); - jw_object_string(jw, "thread", ctx->thread_name.buf); + jw_object_string(jw, "thread", ctx->thread_name); /* * In brief mode, only emit