All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf: Fix accidentally preprocessed snprintf callback
@ 2010-04-14  0:37 Frederic Weisbecker
  2010-04-14  0:41 ` Frederic Weisbecker
  2010-04-14 17:11 ` [PATCH v3] perf: Fix accidentally preprocessed snprintf callback Frederic Weisbecker
  0 siblings, 2 replies; 7+ messages in thread
From: Frederic Weisbecker @ 2010-04-14  0:37 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: LKML, Frederic Weisbecker, Arnaldo Carvalho de Melo,
	Peter Zijlstra, Paul Mackerras, Ingo Molnar

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@gmail.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Ingo Molnar <mingo@elte.hu>
---
 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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-04-14 17:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-14  0:37 [PATCH] perf: Fix accidentally preprocessed snprintf callback Frederic Weisbecker
2010-04-14  0:41 ` Frederic Weisbecker
2010-04-14  2:28   ` Arnaldo Carvalho de Melo
2010-04-14 14:55     ` Frederic Weisbecker
2010-04-14 17:09     ` [PATCH v2] struct sort_entry has a callback named snprintf that turns an entry into a string result Frederic Weisbecker
2010-04-14 17:11 ` [PATCH v3] perf: Fix accidentally preprocessed snprintf callback Frederic Weisbecker
2010-04-14 17:31   ` Arnaldo Carvalho de Melo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.