[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210803170606.694085-17-rostedt@goodmis.org>
Date: Tue, 3 Aug 2021 13:06:00 -0400
From: Steven Rostedt <rostedt@...dmis.org>
To: linux-trace-devel@...r.kernel.org
Cc: linux-kernel@...r.kernel.org, Tom Zanussi <zanussi@...nel.org>,
Daniel Bristot de Oliveira <bristot@...hat.com>,
Masami Hiramatsu <mhiramat@...nel.org>,
Namhyung Kim <namhyung@...nel.org>,
linux-rt-users <linux-rt-users@...r.kernel.org>,
Clark Williams <williams@...hat.com>,
"Steven Rostedt (VMware)" <rostedt@...dmis.org>
Subject: [PATCH v3 16/22] libtracefs: Add error message when calculation has no label
From: "Steven Rostedt (VMware)" <rostedt@...dmis.org>
If a calculation between event fields is performed and there's no label
(name) for it, it errors out, causing the bison parser to give a strange
error:
FAILED MEMORY: add_selection(sb, (yyvsp[0].expr), NULL)
Failed creating synthetic event!: No such file or directory
Instead, just set the compare->name field to NULL, and report a better
error later on in the processing.
ERROR: 'no name'
Field calculations must be labeled 'AS name'
Signed-off-by: Steven Rostedt (VMware) <rostedt@...dmis.org>
---
src/tracefs-sqlhist.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/src/tracefs-sqlhist.c b/src/tracefs-sqlhist.c
index d7829d4804b1..81a0cd1a908b 100644
--- a/src/tracefs-sqlhist.c
+++ b/src/tracefs-sqlhist.c
@@ -243,8 +243,6 @@ __hidden int add_selection(struct sqlhist_bison *sb, void *select,
case EXPR_FIELD:
break;
case EXPR_COMPARE:
- if (!name)
- return -1;
expr->compare.name = name;
break;
case EXPR_NUMBER:
@@ -779,6 +777,9 @@ static int build_compare(struct tracefs_synth *synth,
enum tracefs_synth_calc calc;
int ret;
+ if (!compare->name)
+ return -1;
+
lval = &compare->lval->field;
rval = &compare->rval->field;
@@ -1117,6 +1118,14 @@ static void compare_error(struct tep_handle *tep,
{
struct compare *compare = &expr->compare;
+ if (!compare->name) {
+ sb->line_no = expr->line;
+ sb->line_idx = expr->idx + strlen("no name");
+
+ parse_error(sb, "no name",
+ "Field calculations must be labeled 'AS name'\n");
+ }
+
switch (errno) {
case ENODEV:
case EBADE:
--
2.30.2
Powered by blists - more mailing lists