lkml.org 
[lkml]   [2016]   [Apr]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v5 1/4] perf config: Introduce perf_config_set class
Hi,

2016-04-03 2:08 GMT+09:00 Taeung Song <treeze.taeung@gmail.com>:
[...]
> +static struct perf_config_section *add_section(struct list_head *sections,
> + const char *section_name)
> +{
> + struct perf_config_section *section = zalloc(sizeof(*section));
> +
> + if (!section)
> + return NULL;
> +
> + INIT_LIST_HEAD(&section->items);
> + section->name = strdup(section_name);
> + if (!section->name) {
> + pr_debug("%s: strdup failed\n", __func__);
> + free(section);
> + return NULL;
> + }
> +
> + list_add_tail(&section->node, sections);
> + return section;
> +}
> +
> +static struct perf_config_item *add_config_item(struct perf_config_section *section,
> + const char *name)
> +{
> + struct perf_config_item *item = zalloc(sizeof(*item));
> +
> + if (!item)
> + return NULL;
> +
> + item->name = strdup(name);
> + if (!item->name) {
> + pr_debug("%s: strdup failed\n", __func__);
> + goto out_err;

As you did in above add_section(), you can do free(item)
and return NULL here instead of using goto.

Other parts looks OK for me.

Thank you,

> + }
> +
> + list_add_tail(&item->node, &section->items);
> + return item;
> +
> +out_err:
> + free(item);
> + return NULL;
> +}

\
 
 \ /
  Last update: 2016-04-04 11:02    [W:0.049 / U:0.376 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site