All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf: Fix dynamic field detection
@ 2010-04-14 21:58 Frederic Weisbecker
  2010-04-14 23:39 ` [tip:perf/core] " tip-bot for Thomas Gleixner
  0 siblings, 1 reply; 2+ messages in thread
From: Frederic Weisbecker @ 2010-04-14 21:58 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: LKML, Thomas Gleixner, Arnaldo Carvalho de Melo, Peter Zijlstra,
	Paul Mackerras, Tom Zanussi, Steven Rostedt, Ingo Molnar,
	Frederic Weisbecker

From: Thomas Gleixner <tglx@linutronix.de>

Checking if a tracing field is an array with a dynamic length
requires to check the field type and seek the "__data_loc" string
that prepends the actual type, as can be found in a trace event
format file:

	field:__data_loc char[] name;	offset:16;	size:4;	signed:1;

But we actually use strcmp() to check if the field type fully
matches "__data_loc", which may fail as we trip over the rest of the
type.

To fix this, use strncmp to only check if it starts with "__data_loc".

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
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>
Cc: Tom Zanussi <tzanussi@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
---
 tools/perf/util/trace-event-parse.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c
index 17d6d66..d6ef414 100644
--- a/tools/perf/util/trace-event-parse.c
+++ b/tools/perf/util/trace-event-parse.c
@@ -761,7 +761,7 @@ static int field_is_string(struct format_field *field)
 
 static int field_is_dynamic(struct format_field *field)
 {
-	if (!strcmp(field->type, "__data_loc"))
+	if (!strncmp(field->type, "__data_loc", 10))
 		return 1;
 
 	return 0;
-- 
1.6.2.3


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

* [tip:perf/core] perf: Fix dynamic field detection
  2010-04-14 21:58 [PATCH] perf: Fix dynamic field detection Frederic Weisbecker
@ 2010-04-14 23:39 ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 2+ messages in thread
From: tip-bot for Thomas Gleixner @ 2010-04-14 23:39 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, paulus, acme, hpa, mingo, tzanussi, a.p.zijlstra,
	fweisbec, rostedt, tglx, mingo

Commit-ID:  a1e2f60e3efc812bf66a2be0d8530ee175003f6d
Gitweb:     http://git.kernel.org/tip/a1e2f60e3efc812bf66a2be0d8530ee175003f6d
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Wed, 14 Apr 2010 23:58:03 +0200
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Thu, 15 Apr 2010 01:34:46 +0200

perf: Fix dynamic field detection

Checking if a tracing field is an array with a dynamic length
requires to check the field type and seek the "__data_loc"
string that prepends the actual type, as can be found in a trace
event format file:

	field:__data_loc char[] name;	offset:16;	size:4;	signed:1;

But we actually use strcmp() to check if the field type fully
matches "__data_loc", which may fail as we trip over the rest of
the type.

To fix this, use strncmp to only check if it starts with
"__data_loc".

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
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: Tom Zanussi <tzanussi@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
LKML-Reference: <1271282283-23721-1-git-send-regression-fweisbec@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 tools/perf/util/trace-event-parse.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c
index 17d6d66..d6ef414 100644
--- a/tools/perf/util/trace-event-parse.c
+++ b/tools/perf/util/trace-event-parse.c
@@ -761,7 +761,7 @@ static int field_is_string(struct format_field *field)
 
 static int field_is_dynamic(struct format_field *field)
 {
-	if (!strcmp(field->type, "__data_loc"))
+	if (!strncmp(field->type, "__data_loc", 10))
 		return 1;
 
 	return 0;

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

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

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-14 21:58 [PATCH] perf: Fix dynamic field detection Frederic Weisbecker
2010-04-14 23:39 ` [tip:perf/core] " tip-bot for Thomas Gleixner

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.