Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1370437

Re: [PATCH v5 1/4] perf config: Introduce perf_config_set class

From Masami Hiramatsu <mhiramat@kernel.org>
Newsgroups linux.kernel
Subject Re: [PATCH v5 1/4] perf config: Introduce perf_config_set class
Date 2016-04-04 10:20 +0200
Message-ID <rk7TQ-e4-27@gated-at.bofh.it> (permalink)
References <rjxdE-70V-13@gated-at.bofh.it> <rjxdE-70V-15@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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;
> +}

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v5 0/4] Infrastructure code for perf-config Taeung Song <treeze.taeung@gmail.com> - 2016-04-02 19:10 +0200
  [PATCH v5 1/4] perf config: Introduce perf_config_set class Taeung Song <treeze.taeung@gmail.com> - 2016-04-02 19:10 +0200
    Re: [PATCH v5 1/4] perf config: Introduce perf_config_set class Masami Hiramatsu <mhiramat@kernel.org> - 2016-04-04 10:20 +0200
      Re: [PATCH v5 1/4] perf config: Introduce perf_config_set class Taeung Song <treeze.taeung@gmail.com> - 2016-04-04 10:50 +0200
  [PATCH v5 4/4] perf config: Initialize perf_config_set with all default configs Taeung Song <treeze.taeung@gmail.com> - 2016-04-02 19:10 +0200
  [PATCH v5 2/4] perf config: Let show_config() work with perf_config_set Taeung Song <treeze.taeung@gmail.com> - 2016-04-02 19:10 +0200
  [PATCH v5 3/4] perf config: Prepare all default configs Taeung Song <treeze.taeung@gmail.com> - 2016-04-02 19:10 +0200

csiph-web