[PATCH 3/3] perf: allow typecast for signed value

From: Hidetoshi Seto
Date: Tue Dec 06 2011 - 20:38:12 EST


Still I got following warning with btrfs tracepoints:

$ perf script
Warning: Error: expected type 5 but read 4
Warning: Error: expected type 5 but read 0

I found that the complained format is:

print fmt: "%s", (REC->val >= (u64)-4) ? "-" : __print_symbolic(...)
~
In perf's parser, the typecast, which is processed in process_paren(),
only expects that (unsigned) token or another parenthesis will follow
to the typecast. It should expect signed tokens can be there too.

Signed-off-by: Hidetoshi Seto <seto.hidetoshi@xxxxxxxxxxxxxx>
---
tools/perf/util/trace-event-parse.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c
index b709f78..032f3de 100644
--- a/tools/perf/util/trace-event-parse.c
+++ b/tools/perf/util/trace-event-parse.c
@@ -1645,10 +1645,11 @@ process_paren(struct event *event, struct print_arg *arg, char **tok)
type = read_token_item(&token);

/*
- * If the next token is an item or another open paren, then
- * this was a typecast.
+ * If the next token is an item (might be signed, with single op "-")
+ * or another open paren, then this was a typecast.
*/
if (event_item_type(type) ||
+ (type == EVENT_OP && strcmp(token, "-") == 0) ||
(type == EVENT_DELIM && strcmp(token, "(") == 0)) {

/* make this a typecast and contine */
--
1.7.7.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/