Skip to content

Commit

Permalink
confile: cleanup set_config_environment()
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
  • Loading branch information
Christian Brauner committed Dec 8, 2020
1 parent 1543699 commit a6bf112
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/lxc/confile.c
Expand Up @@ -1391,14 +1391,14 @@ static int set_config_group(const char *key, const char *value,
static int set_config_environment(const char *key, const char *value,
struct lxc_conf *lxc_conf, void *data)
{
struct lxc_list *list_item = NULL;
__do_free struct lxc_list *list_item = NULL;

if (lxc_config_value_empty(value))
return lxc_clear_environment(lxc_conf);

list_item = malloc(sizeof(*list_item));
if (!list_item)
goto on_error;
return ret_errno(ENOMEM);

if (!strchr(value, '=')) {
const char *env_val;
Expand All @@ -1407,7 +1407,7 @@ static int set_config_environment(const char *key, const char *value,

env_val = getenv(env_key);
if (!env_val)
goto on_error;
return ret_errno(ENOENT);

env_var[0] = env_key;
env_var[1] = env_val;
Expand All @@ -1417,16 +1417,11 @@ static int set_config_environment(const char *key, const char *value,
}

if (!list_item->elem)
goto on_error;
return ret_errno(ENOMEM);

lxc_list_add_tail(&lxc_conf->environment, list_item);
lxc_list_add_tail(&lxc_conf->environment, move_ptr(list_item));

return 0;

on_error:
free(list_item);

return -1;
}

static int set_config_tty_max(const char *key, const char *value,
Expand Down

0 comments on commit a6bf112

Please sign in to comment.