* [PATCH v2] perf tools: Remove cast of non-variadic function to variadic
@ 2013-10-31 23:47 Michael Hudson-Doyle
2013-11-01 13:36 ` Arnaldo Carvalho de Melo
2013-11-04 6:54 ` [tip:perf/core] " tip-bot for Michael Hudson-Doyle
0 siblings, 2 replies; 4+ messages in thread
From: Michael Hudson-Doyle @ 2013-10-31 23:47 UTC (permalink / raw)
To: linux-kernel; +Cc: Jiri Olsa, Arnaldo Carvalho de Melo, Will Deacon, Jean Pihet
4fb71074a570 (perf ui/hist: Consolidate hpp helpers) introduced a cast of
percent_color_snprintf to a function pointer type with varargs. Change
percent_color_snprintf to be variadic and remove the cast.
The symptom of this was all percentages being reported as 0.00% in perf
report --stdio output.
Signed-off-by: Michael Hudson-Doyle <michael.hudson@linaro.org>
Acked-by: Will Deacon <will.deacon@arm.com>
Cc: <stable@vger.kernel.org>
---
tools/perf/ui/hist.c | 2 +-
tools/perf/util/color.c | 11 +++++++++--
tools/perf/util/color.h | 2 +-
3 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index 0a19328..78f4c92 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -117,7 +117,7 @@ static int hpp__color_##_type(struct perf_hpp_fmt *fmt __maybe_unused, \
struct perf_hpp *hpp, struct hist_entry *he) \
{ \
return __hpp__fmt(hpp, he, he_get_##_field, " %6.2f%%", \
- (hpp_snprint_fn)percent_color_snprintf, true); \
+ percent_color_snprintf, true); \
}
#define __HPP_ENTRY_PERCENT_FN(_type, _field) \
diff --git a/tools/perf/util/color.c b/tools/perf/util/color.c
index 11e46da..66e44a5 100644
--- a/tools/perf/util/color.c
+++ b/tools/perf/util/color.c
@@ -318,8 +318,15 @@ int percent_color_fprintf(FILE *fp, const char *fmt, double percent)
return r;
}
-int percent_color_snprintf(char *bf, size_t size, const char *fmt, double percent)
+int percent_color_snprintf(char *bf, size_t size, const char *fmt, ...)
{
- const char *color = get_percent_color(percent);
+ va_list args;
+ double percent;
+ const char *color;
+
+ va_start(args, fmt);
+ percent = va_arg(args, double);
+ va_end(args);
+ color = get_percent_color(percent);
return color_snprintf(bf, size, color, fmt, percent);
}
diff --git a/tools/perf/util/color.h b/tools/perf/util/color.h
index dea082b..fced384 100644
--- a/tools/perf/util/color.h
+++ b/tools/perf/util/color.h
@@ -39,7 +39,7 @@ int color_fprintf(FILE *fp, const char *color, const char *fmt, ...);
int color_snprintf(char *bf, size_t size, const char *color, const char *fmt, ...);
int color_fprintf_ln(FILE *fp, const char *color, const char *fmt, ...);
int color_fwrite_lines(FILE *fp, const char *color, size_t count, const char *buf);
-int percent_color_snprintf(char *bf, size_t size, const char *fmt, double percent);
+int percent_color_snprintf(char *bf, size_t size, const char *fmt, ...);
int percent_color_fprintf(FILE *fp, const char *fmt, double percent);
const char *get_percent_color(double percent);
--
1.8.3.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] perf tools: Remove cast of non-variadic function to variadic
2013-10-31 23:47 [PATCH v2] perf tools: Remove cast of non-variadic function to variadic Michael Hudson-Doyle
@ 2013-11-01 13:36 ` Arnaldo Carvalho de Melo
2013-11-01 18:10 ` Michael Hudson-Doyle
2013-11-04 6:54 ` [tip:perf/core] " tip-bot for Michael Hudson-Doyle
1 sibling, 1 reply; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2013-11-01 13:36 UTC (permalink / raw)
To: Michael Hudson-Doyle; +Cc: linux-kernel, Jiri Olsa, Will Deacon, Jean Pihet
Em Thu, Oct 31, 2013 at 04:47:45PM -0700, Michael Hudson-Doyle escreveu:
> -int percent_color_snprintf(char *bf, size_t size, const char *fmt, double percent)
> +int percent_color_snprintf(char *bf, size_t size, const char *fmt, ...)
> {
> - const char *color = get_percent_color(percent);
> + va_list args;
> + double percent;
> + const char *color;
> +
> + va_start(args, fmt);
> + percent = va_arg(args, double);
> + va_end(args);
> + color = get_percent_color(percent);
> return color_snprintf(bf, size, color, fmt, percent);
> }
As a bug fix I'm merging this now, but I wonder if, since we're doing
the va_start/end dance here, can't we call some color_vsnprintf variant
so as to avoid doing it twice?
I'll look into that after going thru more urgent stuff.
- Arnaldo
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] perf tools: Remove cast of non-variadic function to variadic
2013-11-01 13:36 ` Arnaldo Carvalho de Melo
@ 2013-11-01 18:10 ` Michael Hudson-Doyle
0 siblings, 0 replies; 4+ messages in thread
From: Michael Hudson-Doyle @ 2013-11-01 18:10 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo; +Cc: linux-kernel, Jiri Olsa, Will Deacon, Jean Pihet
Arnaldo Carvalho de Melo <acme@redhat.com> writes:
> Em Thu, Oct 31, 2013 at 04:47:45PM -0700, Michael Hudson-Doyle escreveu:
>> -int percent_color_snprintf(char *bf, size_t size, const char *fmt, double percent)
>> +int percent_color_snprintf(char *bf, size_t size, const char *fmt, ...)
>> {
>> - const char *color = get_percent_color(percent);
>> + va_list args;
>> + double percent;
>> + const char *color;
>> +
>> + va_start(args, fmt);
>> + percent = va_arg(args, double);
>> + va_end(args);
>> + color = get_percent_color(percent);
>> return color_snprintf(bf, size, color, fmt, percent);
>> }
>
> As a bug fix I'm merging this now, but I wonder if, since we're doing
> the va_start/end dance here, can't we call some color_vsnprintf variant
> so as to avoid doing it twice?
I thought that, but we need to get the percent argument anyway. I
couldn't decide if it was better to call color_vsnprintf with args or
color_snprintf with percent so I went for the laziest option / minimal
diff. Can clearly write a patch for the alternative if you like...
> I'll look into that after going thru more urgent stuff.
Thanks!
Cheers,
mwh
^ permalink raw reply [flat|nested] 4+ messages in thread
* [tip:perf/core] perf tools: Remove cast of non-variadic function to variadic
2013-10-31 23:47 [PATCH v2] perf tools: Remove cast of non-variadic function to variadic Michael Hudson-Doyle
2013-11-01 13:36 ` Arnaldo Carvalho de Melo
@ 2013-11-04 6:54 ` tip-bot for Michael Hudson-Doyle
1 sibling, 0 replies; 4+ messages in thread
From: tip-bot for Michael Hudson-Doyle @ 2013-11-04 6:54 UTC (permalink / raw)
To: linux-tip-commits
Cc: acme, linux-kernel, hpa, mingo, will.deacon, jean.pihet,
namhyung, jolsa, tglx, michael.hudson
Commit-ID: 53805eca3d89b095062c11a6798689bb0af09216
Gitweb: http://git.kernel.org/tip/53805eca3d89b095062c11a6798689bb0af09216
Author: Michael Hudson-Doyle <michael.hudson@linaro.org>
AuthorDate: Thu, 31 Oct 2013 16:47:45 -0700
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 1 Nov 2013 10:40:51 -0300
perf tools: Remove cast of non-variadic function to variadic
The 4fb71074a570 (perf ui/hist: Consolidate hpp helpers) cset introduced
a cast of percent_color_snprintf to a function pointer type with
varargs. Change percent_color_snprintf to be variadic and remove the
cast.
The symptom of this was all percentages being reported as 0.00% in perf
report --stdio output on the armhf arch.
Signed-off-by: Michael Hudson-Doyle <michael.hudson@linaro.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Will Deacon <will.deacon@arm.com>
Cc: Jean Pihet <jean.pihet@linaro.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: stable@vger.kernel.org
Link: http://lkml.kernel.org/r/87zjppvw7y.fsf@canonical.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/ui/hist.c | 2 +-
tools/perf/util/color.c | 11 +++++++++--
tools/perf/util/color.h | 2 +-
3 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index 0a19328..78f4c92 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -117,7 +117,7 @@ static int hpp__color_##_type(struct perf_hpp_fmt *fmt __maybe_unused, \
struct perf_hpp *hpp, struct hist_entry *he) \
{ \
return __hpp__fmt(hpp, he, he_get_##_field, " %6.2f%%", \
- (hpp_snprint_fn)percent_color_snprintf, true); \
+ percent_color_snprintf, true); \
}
#define __HPP_ENTRY_PERCENT_FN(_type, _field) \
diff --git a/tools/perf/util/color.c b/tools/perf/util/color.c
index 11e46da..66e44a5 100644
--- a/tools/perf/util/color.c
+++ b/tools/perf/util/color.c
@@ -318,8 +318,15 @@ int percent_color_fprintf(FILE *fp, const char *fmt, double percent)
return r;
}
-int percent_color_snprintf(char *bf, size_t size, const char *fmt, double percent)
+int percent_color_snprintf(char *bf, size_t size, const char *fmt, ...)
{
- const char *color = get_percent_color(percent);
+ va_list args;
+ double percent;
+ const char *color;
+
+ va_start(args, fmt);
+ percent = va_arg(args, double);
+ va_end(args);
+ color = get_percent_color(percent);
return color_snprintf(bf, size, color, fmt, percent);
}
diff --git a/tools/perf/util/color.h b/tools/perf/util/color.h
index dea082b..fced384 100644
--- a/tools/perf/util/color.h
+++ b/tools/perf/util/color.h
@@ -39,7 +39,7 @@ int color_fprintf(FILE *fp, const char *color, const char *fmt, ...);
int color_snprintf(char *bf, size_t size, const char *color, const char *fmt, ...);
int color_fprintf_ln(FILE *fp, const char *color, const char *fmt, ...);
int color_fwrite_lines(FILE *fp, const char *color, size_t count, const char *buf);
-int percent_color_snprintf(char *bf, size_t size, const char *fmt, double percent);
+int percent_color_snprintf(char *bf, size_t size, const char *fmt, ...);
int percent_color_fprintf(FILE *fp, const char *fmt, double percent);
const char *get_percent_color(double percent);
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-11-04 6:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-31 23:47 [PATCH v2] perf tools: Remove cast of non-variadic function to variadic Michael Hudson-Doyle
2013-11-01 13:36 ` Arnaldo Carvalho de Melo
2013-11-01 18:10 ` Michael Hudson-Doyle
2013-11-04 6:54 ` [tip:perf/core] " tip-bot for Michael Hudson-Doyle
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).