From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Jiri Olsa <jolsa@redhat.com>
Cc: Pierre.Gondois@arm.com, linux-kernel@vger.kernel.org,
douglas.raillard@arm.com, peterz@infradead.org, mingo@redhat.com,
mark.rutland@arm.com, alexander.shishkin@linux.intel.com,
namhyung@kernel.org
Subject: Re: [PATCH v1] perf: cast (struct timeval).tv_sec when printing
Date: Thu, 25 Feb 2021 15:49:45 -0300 [thread overview]
Message-ID: <YDfxSXAwDBps7TEW@kernel.org> (raw)
In-Reply-To: <YDfRbnZxBLdStPb9@krava>
Em Thu, Feb 25, 2021 at 05:33:50PM +0100, Jiri Olsa escreveu:
> On Wed, Feb 24, 2021 at 06:24:10PM +0000, Pierre.Gondois@arm.com wrote:
> > From: Pierre Gondois <Pierre.Gondois@arm.com>
> >
> > The musl-libc [1] defines (struct timeval).tv_sec as a
> > 'long long' for arm and other architectures. The default
> > build having a '-Wformat' flag, not casting the field
> > when printing prevents from building perf.
> >
> > This patch casts the (struct timeval).tv_sec fields to the
> > expected format.
> >
> > [1] git://git.musl-libc.org/musl
> >
> > Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
>
> Acked-by: Jiri Olsa <jolsa@redhat.com>
Thanks, applied.
- Arnaldo
> thanks,
> jirka
>
> > ---
> > tools/perf/bench/sched-messaging.c | 4 ++--
> > tools/perf/bench/sched-pipe.c | 4 ++--
> > tools/perf/bench/syscall.c | 4 ++--
> > tools/perf/util/header.c | 4 ++--
> > tools/perf/util/stat-display.c | 2 +-
> > 5 files changed, 9 insertions(+), 9 deletions(-)
> >
> > diff --git a/tools/perf/bench/sched-messaging.c b/tools/perf/bench/sched-messaging.c
> > index cecce93ccc63..488f6e6ba1a5 100644
> > --- a/tools/perf/bench/sched-messaging.c
> > +++ b/tools/perf/bench/sched-messaging.c
> > @@ -309,11 +309,11 @@ int bench_sched_messaging(int argc, const char **argv)
> > num_groups, num_groups * 2 * num_fds,
> > thread_mode ? "threads" : "processes");
> > printf(" %14s: %lu.%03lu [sec]\n", "Total time",
> > - diff.tv_sec,
> > + (unsigned long) diff.tv_sec,
> > (unsigned long) (diff.tv_usec / USEC_PER_MSEC));
> > break;
> > case BENCH_FORMAT_SIMPLE:
> > - printf("%lu.%03lu\n", diff.tv_sec,
> > + printf("%lu.%03lu\n", (unsigned long) diff.tv_sec,
> > (unsigned long) (diff.tv_usec / USEC_PER_MSEC));
> > break;
> > default:
> > diff --git a/tools/perf/bench/sched-pipe.c b/tools/perf/bench/sched-pipe.c
> > index 3c88d1f201f1..a960e7a93aec 100644
> > --- a/tools/perf/bench/sched-pipe.c
> > +++ b/tools/perf/bench/sched-pipe.c
> > @@ -156,7 +156,7 @@ int bench_sched_pipe(int argc, const char **argv)
> > result_usec += diff.tv_usec;
> >
> > printf(" %14s: %lu.%03lu [sec]\n\n", "Total time",
> > - diff.tv_sec,
> > + (unsigned long) diff.tv_sec,
> > (unsigned long) (diff.tv_usec / USEC_PER_MSEC));
> >
> > printf(" %14lf usecs/op\n",
> > @@ -168,7 +168,7 @@ int bench_sched_pipe(int argc, const char **argv)
> >
> > case BENCH_FORMAT_SIMPLE:
> > printf("%lu.%03lu\n",
> > - diff.tv_sec,
> > + (unsigned long) diff.tv_sec,
> > (unsigned long) (diff.tv_usec / USEC_PER_MSEC));
> > break;
> >
> > diff --git a/tools/perf/bench/syscall.c b/tools/perf/bench/syscall.c
> > index 5fe621cff8e9..9b751016f4b6 100644
> > --- a/tools/perf/bench/syscall.c
> > +++ b/tools/perf/bench/syscall.c
> > @@ -54,7 +54,7 @@ int bench_syscall_basic(int argc, const char **argv)
> > result_usec += diff.tv_usec;
> >
> > printf(" %14s: %lu.%03lu [sec]\n\n", "Total time",
> > - diff.tv_sec,
> > + (unsigned long) diff.tv_sec,
> > (unsigned long) (diff.tv_usec/1000));
> >
> > printf(" %14lf usecs/op\n",
> > @@ -66,7 +66,7 @@ int bench_syscall_basic(int argc, const char **argv)
> >
> > case BENCH_FORMAT_SIMPLE:
> > printf("%lu.%03lu\n",
> > - diff.tv_sec,
> > + (unsigned long) diff.tv_sec,
> > (unsigned long) (diff.tv_usec / 1000));
> > break;
> >
> > diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
> > index 4fe9e2a54346..20effdff76ce 100644
> > --- a/tools/perf/util/header.c
> > +++ b/tools/perf/util/header.c
> > @@ -1618,8 +1618,8 @@ static void print_clock_data(struct feat_fd *ff, FILE *fp)
> >
> > fprintf(fp, "# clockid: %s (%u)\n", clockid_name(clockid), clockid);
> > fprintf(fp, "# reference time: %s = %ld.%06d (TOD) = %ld.%09ld (%s)\n",
> > - tstr, tod_ns.tv_sec, (int) tod_ns.tv_usec,
> > - clockid_ns.tv_sec, clockid_ns.tv_nsec,
> > + tstr, (long) tod_ns.tv_sec, (int) tod_ns.tv_usec,
> > + (long) clockid_ns.tv_sec, clockid_ns.tv_nsec,
> > clockid_name(clockid));
> > }
> >
> > diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c
> > index cce7a76d6473..7f09cdaf5b60 100644
> > --- a/tools/perf/util/stat-display.c
> > +++ b/tools/perf/util/stat-display.c
> > @@ -983,7 +983,7 @@ static void print_interval(struct perf_stat_config *config,
> > if (config->interval_clear)
> > puts(CONSOLE_CLEAR);
> >
> > - sprintf(prefix, "%6lu.%09lu%s", ts->tv_sec, ts->tv_nsec, config->csv_sep);
> > + sprintf(prefix, "%6lu.%09lu%s", (unsigned long) ts->tv_sec, ts->tv_nsec, config->csv_sep);
> >
> > if ((num_print_interval == 0 && !config->csv_output) || config->interval_clear) {
> > switch (config->aggr_mode) {
> > --
> > 2.17.1
> >
>
--
- Arnaldo
prev parent reply other threads:[~2021-02-25 18:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-24 18:24 [PATCH v1] perf: cast (struct timeval).tv_sec when printing Pierre.Gondois
2021-02-25 16:33 ` Jiri Olsa
2021-02-25 18:49 ` Arnaldo Carvalho de Melo [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=YDfxSXAwDBps7TEW@kernel.org \
--to=acme@kernel.org \
--cc=Pierre.Gondois@arm.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=douglas.raillard@arm.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.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