[PATCH 20/20 v2] tracing: Add argument error message too many args for function based events

From: Steven Rostedt
Date: Wed Feb 07 2018 - 15:29:57 EST


From: "Steven Rostedt (VMware)" <rostedt@xxxxxxxxxxx>

If too many arguments are added to the function_events, have the error
message state that instead of saying the type of argument that passed the
allowed amount is incorrect.

Signed-off-by: Steven Rostedt (VMware) <rostedt@xxxxxxxxxxx>
---
kernel/trace/trace_event_ftrace.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/kernel/trace/trace_event_ftrace.c b/kernel/trace/trace_event_ftrace.c
index 314d025dc676..e612b1c4fc40 100644
--- a/kernel/trace/trace_event_ftrace.c
+++ b/kernel/trace/trace_event_ftrace.c
@@ -1380,8 +1380,14 @@ static void add_failure(struct func_event *func_event, char *token,

trace_seq_printf(s, "\n%*s\n", len, "^");

- trace_seq_printf(s, "Unexpected token '%s' for %s state",
- save_token, func_state_names[state]);
+ /* for COMMA or PARAM state, the error could be too many args */
+ if ((state == FUNC_STATE_COMMA || state == FUNC_STATE_PARAM) &&
+ func_event->arg_cnt >= max_args)
+ trace_seq_printf(s, "Error: Too many arguments (max of %d)",
+ max_args);
+ else
+ trace_seq_printf(s, "Unexpected token '%s' for %s state",
+ save_token, func_state_names[state]);

finish:
len = min(ERR_SIZE-1, s->seq.len);
--
2.15.1