confile: cleanup set_config_group()

parent fad06846
...@@ -1277,40 +1277,34 @@ static int set_config_monitor_signal_pdeath(const char *key, const char *value, ...@@ -1277,40 +1277,34 @@ static int set_config_monitor_signal_pdeath(const char *key, const char *value,
static int set_config_group(const char *key, const char *value, static int set_config_group(const char *key, const char *value,
struct lxc_conf *lxc_conf, void *data) struct lxc_conf *lxc_conf, void *data)
{ {
char *groups, *token; __do_free char *groups = NULL;
struct lxc_list *grouplist; char *token;
int ret = 0;
if (lxc_config_value_empty(value)) if (lxc_config_value_empty(value))
return lxc_clear_groups(lxc_conf); return lxc_clear_groups(lxc_conf);
groups = strdup(value); groups = strdup(value);
if (!groups) if (!groups)
return -1; return ret_errno(ENOMEM);
/* In case several groups are specified in a single line split these /* In case several groups are specified in a single line split these
* groups in a single element for the list. * groups in a single element for the list.
*/ */
lxc_iterate_parts(token, groups, " \t") { lxc_iterate_parts(token, groups, " \t") {
__do_free struct lxc_list *grouplist = NULL;
grouplist = malloc(sizeof(*grouplist)); grouplist = malloc(sizeof(*grouplist));
if (!grouplist) { if (!grouplist)
ret = -1; return ret_errno(ENOMEM);
break;
}
grouplist->elem = strdup(token); grouplist->elem = strdup(token);
if (!grouplist->elem) { if (!grouplist->elem)
free(grouplist); return ret_errno(ENOMEM);
ret = -1;
break;
}
lxc_list_add_tail(&lxc_conf->groups, grouplist); lxc_list_add_tail(&lxc_conf->groups, move_ptr(grouplist));
} }
free(groups); return 0;
return ret;
} }
static int set_config_environment(const char *key, const char *value, static int set_config_environment(const char *key, const char *value,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment