confile: cleanup set_config_cap_keep()

parent d312dc05
...@@ -2107,16 +2107,16 @@ int add_elem_to_mount_list(const char *value, struct lxc_conf *lxc_conf) { ...@@ -2107,16 +2107,16 @@ int add_elem_to_mount_list(const char *value, struct lxc_conf *lxc_conf) {
static int set_config_cap_keep(const char *key, const char *value, static int set_config_cap_keep(const char *key, const char *value,
struct lxc_conf *lxc_conf, void *data) struct lxc_conf *lxc_conf, void *data)
{ {
char *keepcaps, *token; __do_free char *keepcaps = NULL;
struct lxc_list *keeplist; __do_free struct lxc_list *keeplist = NULL;
int ret = -1; char *token;
if (lxc_config_value_empty(value)) if (lxc_config_value_empty(value))
return lxc_clear_config_keepcaps(lxc_conf); return lxc_clear_config_keepcaps(lxc_conf);
keepcaps = strdup(value); keepcaps = strdup(value);
if (!keepcaps) if (!keepcaps)
return -1; return ret_errno(ENOMEM);
/* In case several capability keep is specified in a single line /* In case several capability keep is specified in a single line
* split these caps in a single element for the list. * split these caps in a single element for the list.
...@@ -2127,23 +2127,16 @@ static int set_config_cap_keep(const char *key, const char *value, ...@@ -2127,23 +2127,16 @@ static int set_config_cap_keep(const char *key, const char *value,
keeplist = malloc(sizeof(*keeplist)); keeplist = malloc(sizeof(*keeplist));
if (!keeplist) if (!keeplist)
goto on_error; return ret_errno(ENOMEM);
keeplist->elem = strdup(token); keeplist->elem = strdup(token);
if (!keeplist->elem) { if (!keeplist->elem)
free(keeplist); return ret_errno(ENOMEM);
goto on_error;
}
lxc_list_add_tail(&lxc_conf->keepcaps, keeplist); lxc_list_add_tail(&lxc_conf->keepcaps, move_ptr(keeplist));
} }
ret = 0; return 0;
on_error:
free(keepcaps);
return ret;
} }
static int set_config_cap_drop(const char *key, const char *value, static int set_config_cap_drop(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