[PATCH] perf: Fix accidentally preprocessed snprintf callback

From: Frederic Weisbecker
Date: Tue Apr 13 2010 - 20:37:57 EST


struct sort_entry has a callback named snprintf that turns an
entry into a string result.

But there are glibc versions that implement snprintf through a
macro. The following expression is then going to get the snprintf
call preprocessed:

ent->snprintf(...)

to finally end up in a build error:

util/hist.c: Dans la fonction Âhist_entry__snprintf :
util/hist.c:539: erreur: Âstruct sort_entry has no member named Â__builtin___snprintf_chkÂ

To fix this, rename struct sort_entry::snprintf() callback to
to_string(), assuming at least Java methods naming won't ever
conflict with perf.

Signed-off-by: Frederic Weisbecker <fweisbec@xxxxxxxxx>
Cc: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
Cc: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
Cc: Paul Mackerras <paulus@xxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxx>
---
tools/perf/util/hist.c | 4 ++--
tools/perf/util/sort.c | 10 +++++-----
tools/perf/util/sort.h | 4 ++--
3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 18cf8b3..d07eccd 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -536,8 +536,8 @@ int hist_entry__snprintf(struct hist_entry *self,
continue;

ret += snprintf(s + ret, size - ret, "%s", sep ?: " ");
- ret += se->snprintf(self, s + ret, size - ret,
- se->width ? *se->width : 0);
+ ret += se->to_string(self, s + ret, size - ret,
+ se->width ? *se->width : 0);
}

return ret;
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 9d24d4b..b8acf51 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -32,7 +32,7 @@ static int hist_entry__parent_snprintf(struct hist_entry *self, char *bf,
struct sort_entry sort_thread = {
.header = "Command: Pid",
.cmp = sort__thread_cmp,
- .snprintf = hist_entry__thread_snprintf,
+ .to_string = hist_entry__thread_snprintf,
.width = &threads__col_width,
};

@@ -40,27 +40,27 @@ struct sort_entry sort_comm = {
.header = "Command",
.cmp = sort__comm_cmp,
.collapse = sort__comm_collapse,
- .snprintf = hist_entry__comm_snprintf,
+ .to_string = hist_entry__comm_snprintf,
.width = &comms__col_width,
};

struct sort_entry sort_dso = {
.header = "Shared Object",
.cmp = sort__dso_cmp,
- .snprintf = hist_entry__dso_snprintf,
+ .to_string = hist_entry__dso_snprintf,
.width = &dsos__col_width,
};

struct sort_entry sort_sym = {
.header = "Symbol",
.cmp = sort__sym_cmp,
- .snprintf = hist_entry__sym_snprintf,
+ .to_string = hist_entry__sym_snprintf,
};

struct sort_entry sort_parent = {
.header = "Parent symbol",
.cmp = sort__parent_cmp,
- .snprintf = hist_entry__parent_snprintf,
+ .to_string = hist_entry__parent_snprintf,
.width = &parent_symbol__col_width,
};

diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h
index 6d7b4be..3a29fb5 100644
--- a/tools/perf/util/sort.h
+++ b/tools/perf/util/sort.h
@@ -82,8 +82,8 @@ struct sort_entry {

int64_t (*cmp)(struct hist_entry *, struct hist_entry *);
int64_t (*collapse)(struct hist_entry *, struct hist_entry *);
- int (*snprintf)(struct hist_entry *self, char *bf, size_t size,
- unsigned int width);
+ int (*to_string)(struct hist_entry *self, char *bf, size_t size,
+ unsigned int width);
unsigned int *width;
bool elide;
};
--
1.6.2.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/