Skip to content

Commit 53805ec

Browse files
Michael Hudson-Doyleacmel
authored andcommitted
perf tools: Remove cast of non-variadic function to variadic
The 4fb7107 (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>
1 parent e8a923c commit 53805ec

3 files changed

Lines changed: 11 additions & 4 deletions

File tree

‎tools/perf/ui/hist.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ static int hpp__color_##_type(struct perf_hpp_fmt *fmt __maybe_unused, \
117117
struct perf_hpp *hpp, struct hist_entry *he) \
118118
{ \
119119
return __hpp__fmt(hpp, he, he_get_##_field, " %6.2f%%", \
120-
(hpp_snprint_fn)percent_color_snprintf, true); \
120+
percent_color_snprintf, true); \
121121
}
122122

123123
#define __HPP_ENTRY_PERCENT_FN(_type, _field) \

‎tools/perf/util/color.c‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,15 @@ int percent_color_fprintf(FILE *fp, const char *fmt, double percent)
318318
return r;
319319
}
320320

321-
int percent_color_snprintf(char *bf, size_t size, const char *fmt, double percent)
321+
int percent_color_snprintf(char *bf, size_t size, const char *fmt, ...)
322322
{
323-
const char *color = get_percent_color(percent);
323+
va_list args;
324+
double percent;
325+
const char *color;
326+
327+
va_start(args, fmt);
328+
percent = va_arg(args, double);
329+
va_end(args);
330+
color = get_percent_color(percent);
324331
return color_snprintf(bf, size, color, fmt, percent);
325332
}

‎tools/perf/util/color.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ int color_fprintf(FILE *fp, const char *color, const char *fmt, ...);
3939
int color_snprintf(char *bf, size_t size, const char *color, const char *fmt, ...);
4040
int color_fprintf_ln(FILE *fp, const char *color, const char *fmt, ...);
4141
int color_fwrite_lines(FILE *fp, const char *color, size_t count, const char *buf);
42-
int percent_color_snprintf(char *bf, size_t size, const char *fmt, double percent);
42+
int percent_color_snprintf(char *bf, size_t size, const char *fmt, ...);
4343
int percent_color_fprintf(FILE *fp, const char *fmt, double percent);
4444
const char *get_percent_color(double percent);
4545

0 commit comments

Comments
 (0)