lkml.org 
[lkml]   [2012]   [Mar]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patches in this message
/
From
Subject[PATCH 2/2] perf tools: Fix parsing of unary operator in ?: expression
Date
Parsing an expression like

print fmt: "reason %s (%d)", …, REC->errno < 0 ? -REC->errno : REC->reason

in kvm_space_exit fails with

Fatal unknown op ':'

The colon after a simple operator signals the end of this expression. The
token should not be advanced, because the colon is handled in
process_cond(). Hence, it's enough to signal there's an operation
heading.

Signed-off-by: Jörg Sommer <joerg@alea.gnuu.de>
---
An alternative could be:

--- a/tools/perf/util/trace-event-parse.c
+++ b/tools/perf/util/trace-event-parse.c
@@ -1287,7 +1287,7 @@ process_op(struct event *event, struct print_arg *arg, char **tok)
return EVENT_NONE;
}

- if (type == EVENT_OP) {
+ if (type == EVENT_OP && strcmp(*tok, ":") != 0) {
int prio;

/* higher prios need to be closer to the root */

tools/perf/util/trace-event-parse.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c
index 185e284..d7b5880 100644
--- a/tools/perf/util/trace-event-parse.c
+++ b/tools/perf/util/trace-event-parse.c
@@ -1125,6 +1125,7 @@ static int get_op_prio(char *op)
case '|':
return 13;
case '?':
+ case ':':
return 16;
default:
die("unknown op '%c'", op[0]);
@@ -1202,6 +1203,8 @@ process_op(struct event *event, struct print_arg *arg, char **tok)

type = process_arg(event, right, tok);

+ } else if (strcmp(token, ":") == 0) {
+ return EVENT_OP;
} else if (strcmp(token, "?") == 0) {

left = malloc_or_die(sizeof(*left));
--
1.7.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2012-03-25 23:15    [W:0.056 / U:0.108 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site