Re: tools lib traceevent: Report better error message on badfunction args

From: Steven Rostedt
Date: Mon Nov 18 2013 - 21:31:38 EST


On Tue, 19 Nov 2013 11:23:56 +0900
Namhyung Kim <namhyung@xxxxxxxxxx> wrote:

> > arg->type = PRINT_FUNC;
> > @@ -2708,15 +2707,19 @@ process_func_handler(struct event_format *event, struct pevent_function_handler
> > }
> >
> > type = process_arg(event, farg, &token);
> > - if (i < (func->nr_args - 1))
> > - test = ",";
> > - else
> > - test = ")";
> > -
> > - if (test_type_token(type, token, EVENT_DELIM, test)) {
> > - free_arg(farg);
> > - free_token(token);
> > - return EVENT_ERROR;
> > + if (i < (func->nr_args - 1)) {
> > + if (type != EVENT_DELIM || strcmp(token, ",") != 0) {
> > + warning("Error: function '%s()' expects %d arguments but event %s only uses %d",
> > + func->name, func->nr_args,
> > + event->name, i + 1);
> > + return EVENT_ERROR;
> > + }
> > + } else {
> > + if (type != EVENT_DELIM || strcmp(token, ")") != 0) {
> > + warning("Error: function '%s()' only expects %d arguments but event %s has more",
> > + func->name, func->nr_args, event->name);
> > + return EVENT_ERROR;
>
> It seems that you missed to free farg and token in error paths.
>

Ug, you're right!

Thanks for the review. v2 coming up.

-- Steve
--
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/