From: Steven Rostedt <rostedt@goodmis.org>
To: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
Cc: linux-trace-devel@vger.kernel.org
Subject: Re: [PATCH v3 6/6] trace-cmd: Add new libtrasefs API to get the current trace clock
Date: Thu, 12 Nov 2020 14:23:58 -0500 [thread overview]
Message-ID: <20201112142358.0299e18c@gandalf.local.home> (raw)
In-Reply-To: <20201112091109.1239169-7-tz.stoyanov@gmail.com>
On Thu, 12 Nov 2020 11:11:09 +0200
"Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com> wrote:
> static void report_clock(struct buffer_instance *instance)
> {
> - char *str;
> - char *cont;
> char *clock;
>
> - str = get_instance_file_content(instance, "trace_clock");
> - if (!str)
> - return;
> -
> - clock = strstr(str, "[");
> - if (!clock)
> - goto out;
> - clock++;
> -
> - cont = strstr(clock, "]");
> - if (!cont) /* should never happen */
> - goto out;
> -
> - *cont = '\0';
> + if (instance)
> + clock = tracefs_get_clock(instance->tracefs);
> + else
> + clock = tracefs_get_clock(NULL);
Small nit, but I find it cleaner in a case that both sides of an if
condition do basically the same thing with a different variable, to just
set the variable:
struct tracefs_instance *tracefs = instance ? instance->tracefs : NULL;
[..]
clock = tracefs_get_clock(tracefs);
Other than that, the rest looks good.
Thanks Tzvetomir!
-- Steve
>
> /* Default clock is "local", only show others */
> - if (strcmp(clock, "local") == 0)
> - goto out;
> + if (clock && !strcmp(clock, "local") == 0)
> + printf("\nClock: %s\n", clock);
>
> - printf("\nClock: %s\n", clock);
> -
> - out:
> - free(str);
> + free(clock);
> }
>
> static void report_cpumask(struct buffer_instance *instance)
> diff --git a/utest/tracefs-utest.c b/utest/tracefs-utest.c
> index c42fea12..78eda481 100644
> --- a/utest/tracefs-utest.c
> +++ b/utest/tracefs-utest.c
> @@ -511,6 +511,33 @@ static void test_instances_walk(void)
> }
> }
>
prev parent reply other threads:[~2020-11-12 19:24 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-12 9:11 [PATCH v3 0/6] libtracefs fixes and improvements Tzvetomir Stoyanov (VMware)
2020-11-12 9:11 ` [PATCH v3 1/6] trace-cmd: Change tracefs.h include path Tzvetomir Stoyanov (VMware)
2020-11-12 9:11 ` [PATCH v3 2/6] libtracefs: Change get name API to return constant string Tzvetomir Stoyanov (VMware)
2020-11-12 19:10 ` Steven Rostedt
2020-11-12 9:11 ` [PATCH v3 3/6] libtracefs: Add new API to check if instance exists Tzvetomir Stoyanov (VMware)
2020-11-12 9:11 ` [PATCH v3 4/6] libtracefs: Combine allocate and create APIs into one Tzvetomir Stoyanov (VMware)
2020-11-12 19:14 ` Steven Rostedt
2020-11-12 9:11 ` [PATCH v3 5/6] libtracefs: Add new tracefs API tracefs_instances_walk() Tzvetomir Stoyanov (VMware)
2020-11-12 19:17 ` Steven Rostedt
2020-11-12 9:11 ` [PATCH v3 6/6] trace-cmd: Add new libtrasefs API to get the current trace clock Tzvetomir Stoyanov (VMware)
2020-11-12 19:23 ` Steven Rostedt [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=20201112142358.0299e18c@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=linux-trace-devel@vger.kernel.org \
--cc=tz.stoyanov@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).