lkml.org 
[lkml]   [2013]   [Dec]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 06/14] tools lib traceevent: Get rid of malloc_or_die() in find_event()
On Mon, Dec 09, 2013 at 02:34:03PM +0900, Namhyung Kim wrote:
> Make it return -2 to distinguish malloc allocation failure.
>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
> tools/lib/traceevent/parse-filter.c | 17 ++++++++++++++---
> 1 file changed, 14 insertions(+), 3 deletions(-)
>
> diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c
> index e9d17bfcdffd..06e5af9f8fc4 100644
> --- a/tools/lib/traceevent/parse-filter.c
> +++ b/tools/lib/traceevent/parse-filter.c
> @@ -301,7 +301,10 @@ find_event(struct pevent *pevent, struct event_list **events,
> sys_name = NULL;
> }
>
> - reg = malloc_or_die(strlen(event_name) + 3);
> + reg = malloc(strlen(event_name) + 3);
> + if (reg == NULL)
> + return -2;
> +

I guess we dont need error defines or enums when this is just
static function, but at least please add some comment (description)
of return values like in pevent_filter_match function

jirka


\
 
 \ /
  Last update: 2013-12-09 12:41    [W:0.250 / U:0.236 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site