perf: cast (struct timeval).tv_sec when printing
PATCH 1/1 perf: cast (struct timeval).tv_sec when printing
From: Pierre Gondois <[email protected]>
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
--- 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(-)
tools/perf/bench/sched-messaging.c +2 -2
@@ -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 :
tools/perf/bench/sched-pipe.c +2 -2
@@ -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 ;
tools/perf/bench/syscall.c +2 -2
@@ -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 ;
tools/perf/util/header.c +2 -2
@@ -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)); }
tools/perf/util/stat-display.c +1 -1
@@ -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) {
Signature · 1 line
2.17.1
Quoted 7 lines · On Wed, Feb 24, 2021 at 06:24:10PM +0000, [email protected] wrote:
From: Pierre Gondois <[email protected]>
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.
Quoted 6 lines
This patch casts the (struct timeval).tv_sec fields to the expected format.
[1]
git://git.musl-libc.org/muslSigned-off-by Pierre Gondois <[email protected]>
thanks,
jirka
Quoted 101 lines
--- 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(-)tools/perf/bench/sched-messaging.c +2
-2@@ -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 :tools/perf/bench/sched-pipe.c +2
-2@@ -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 ;tools/perf/bench/syscall.c +2
-2@@ -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 ;tools/perf/util/header.c +2
-2@@ -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)); }tools/perf/util/stat-display.c +1
-1@@ -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) {Signature · 1 line
2.17.1
Em Thu, Feb 25, 2021 at 05:33:50PM +0100, Jiri Olsa escreveu:
Quoted 8 lines · On Wed, Feb 24, 2021 at 06:24:10PM +0000, [email protected] wrote:
Quoted 7 lines
From: Pierre Gondois <[email protected]>
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.
Quoted 8 lines
Quoted 6 lines
This patch casts the (struct timeval).tv_sec fields to the expected format.
[1]
git://git.musl-libc.org/muslSigned-off-by Pierre Gondois <[email protected]>Acked-by Jiri Olsa <[email protected]>
Thanks, applied.
- Arnaldo
Quoted 105 lines
thanks,
jirkaQuoted 101 lines
--- 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(-)tools/perf/bench/sched-messaging.c +2
-2@@ -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 :tools/perf/bench/sched-pipe.c +2
-2@@ -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 ;tools/perf/bench/syscall.c +2
-2@@ -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 ;tools/perf/util/header.c +2
-2@@ -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)); }tools/perf/util/stat-display.c +1
-1@@ -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) {Signature · 1 line
2.17.1
Signature · 1 line
- Arnaldo