aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVaibhav Nagarnaik <vnagarnaik@google.com>2011-07-25 14:40:57 -0400
committerSteven Rostedt <rostedt@goodmis.org>2011-07-29 12:43:19 -0400
commit5040a618353d685c4441b8e64b28d4d248a032d0 (patch)
treef9f5d82ee6039587e561e55da5e7fa5be09ca741
parentcc31fde359acd4f9be790b30a264493fec38a274 (diff)
parse-events: Handle opcode parsing error
If an invalid opcode is encountered in parsing event print format, the trace-cmd calls exit() without parsing any other events. This patch adds handling for such an error where the get_op_prio() is called. If the return value is -1, then the event print format parsing is skipped and parsing continues. Cc: Michael Rubin <mrubin@google.com> Cc: David Sharp <dhsharp@google.com> Signed-off-by: Vaibhav Nagarnaik <vnagarnaik@google.com> Link: http://lkml.kernel.org/r/1311619257-4970-1-git-send-email-vnagarnaik@google.com Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--parse-events.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/parse-events.c b/parse-events.c
index 32c13ac..8cec1ea 100644
--- a/parse-events.c
+++ b/parse-events.c
@@ -1588,7 +1588,7 @@ static int get_op_prio(char *op)
1588 case '?': 1588 case '?':
1589 return 16; 1589 return 16;
1590 default: 1590 default:
1591 die("unknown op '%c'", op[0]); 1591 do_warning("unknown op '%c'", op[0]);
1592 return -1; 1592 return -1;
1593 } 1593 }
1594 } else { 1594 } else {
@@ -1609,22 +1609,22 @@ static int get_op_prio(char *op)
1609 } else if (strcmp(op, "||") == 0) { 1609 } else if (strcmp(op, "||") == 0) {
1610 return 15; 1610 return 15;
1611 } else { 1611 } else {
1612 die("unknown op '%s'", op); 1612 do_warning("unknown op '%s'", op);
1613 return -1; 1613 return -1;
1614 } 1614 }
1615 } 1615 }
1616} 1616}
1617 1617
1618static void set_op_prio(struct print_arg *arg) 1618static int set_op_prio(struct print_arg *arg)
1619{ 1619{
1620 1620
1621 /* single ops are the greatest */ 1621 /* single ops are the greatest */
1622 if (!arg->op.left || arg->op.left->type == PRINT_NULL) { 1622 if (!arg->op.left || arg->op.left->type == PRINT_NULL)
1623 arg->op.prio = 0; 1623 arg->op.prio = 0;
1624 return; 1624 else
1625 } 1625 arg->op.prio = get_op_prio(arg->op.op);
1626 1626
1627 arg->op.prio = get_op_prio(arg->op.op); 1627 return arg->op.prio;
1628} 1628}
1629 1629
1630/* Note, *tok does not get freed, but will most likely be saved */ 1630/* Note, *tok does not get freed, but will most likely be saved */
@@ -1706,7 +1706,10 @@ process_op(struct event_format *event, struct print_arg *arg, char **tok)
1706 arg->op.op = token; 1706 arg->op.op = token;
1707 arg->op.left = left; 1707 arg->op.left = left;
1708 1708
1709 set_op_prio(arg); 1709 if (set_op_prio(arg) == -1) {
1710 event->flags |= EVENT_FL_FAILED;
1711 goto out_free;
1712 }
1710 1713
1711 type = read_token_item(&token); 1714 type = read_token_item(&token);
1712 *tok = token; 1715 *tok = token;