lkml.org 
[lkml]   [2012]   [Sep]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH 27/30] tools lib traceevent: Carve out events format parsing routine
Date
On Mon, 24 Sep 2012 12:59:41 -0300, Arnaldo Carvalho de Melo wrote:
> From: Arnaldo Carvalho de Melo <acme@redhat.com>
>
> The pevent_parse_event() routine will parse a events/sys/tp/format file
> and add an event_format instance to the pevent struct.
>
> This patch introduces a pevent_parse_format() routine with just the bits
> needed to parse the event/sys/tp/format file and just return the
> event_format instance, useful for when all we want is to parse the
> format file, without requiring the pevent struct.
[snip]
> +enum pevent_errno pevent_parse_event(struct pevent *pevent, const char *buf,
> + unsigned long size, const char *sys)
> +{
> + struct event_format *event = NULL;
> + int ret = __pevent_parse_format(&event, pevent, buf, size, sys);
> +
> + if (event == NULL)
> + return ret;
> +
> + /* Add pevent to event so that it can be referenced */
> + event->pevent = pevent;
> +
> + if (add_event(pevent, event))
> + goto event_add_failed;

It seems we should set the 'ret' to a proper pevent_errno -
PEVENT_ERRNO__MEM_ALLOC_FAILED.


> +
> +#define PRINT_ARGS 0
> + if (PRINT_ARGS && event->print_fmt.args)
> + print_args(event->print_fmt.args);
> +
> + return 0;
> +
> +event_add_failed:
> + free(event->system);
> + free(event->name);
> + free(event);

At this point, the 'event' also has fields and format information and
they all need to be freed. Looks like calling pevent_free_format()
would be the right thing IMHO.

Thanks,
Namhyung

> return ret;
> }


\
 
 \ /
  Last update: 2012-09-25 07:01    [W:0.193 / U:0.068 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site