lkml.org 
[lkml]   [2013]   [Nov]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: tools lib traceevent: Report better error message on bad function args
On Tue, 19 Nov 2013 11:23:56 +0900
Namhyung Kim <namhyung@kernel.org> 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


\
 
 \ /
  Last update: 2013-11-19 04:01    [W:0.047 / U:1.892 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site