From: Christian Brauner Date: Fri, 27 Aug 2021 13:12:00 +0000 (+0200) Subject: conf: port groups to new list type X-Git-Tag: lxc-5.0.0~97^2~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ffb2a35f0bacd67c78943db3e675b6bc24526353;p=thirdparty%2Flxc.git conf: port groups to new list type Signed-off-by: Christian Brauner --- diff --git a/src/lxc/conf.c b/src/lxc/conf.c index 789540b0a..a7565fc71 100644 --- a/src/lxc/conf.c +++ b/src/lxc/conf.c @@ -3375,7 +3375,7 @@ struct lxc_conf *lxc_conf_init(void) new->hooks_version = 0; for (i = 0; i < NUM_LXC_HOOKS; i++) INIT_LIST_HEAD(&new->hooks[i]); - lxc_list_init(&new->groups); + INIT_LIST_HEAD(&new->groups); INIT_LIST_HEAD(&new->state_clients); new->lsm_aa_profile = NULL; INIT_LIST_HEAD(&new->lsm_aa_raw); @@ -4635,15 +4635,15 @@ int lxc_clear_procs(struct lxc_conf *c, const char *key) int lxc_clear_groups(struct lxc_conf *c) { - struct lxc_list *it, *next; + struct string_entry *entry, *nentry; - lxc_list_for_each_safe (it, &c->groups, next) { - lxc_list_del(it); - free(it->elem); - free(it); + list_for_each_entry_safe(entry, nentry, &c->groups, head) { + list_del(&entry->head); + free(entry->val); + free(entry); } - lxc_list_init(&c->groups); + INIT_LIST_HEAD(&c->groups); return 0; } diff --git a/src/lxc/conf.h b/src/lxc/conf.h index 5fcae6364..24bf1b71b 100644 --- a/src/lxc/conf.h +++ b/src/lxc/conf.h @@ -450,7 +450,7 @@ struct lxc_conf { unsigned int start_auto; unsigned int start_delay; int start_order; - struct lxc_list groups; + struct list_head groups; int nbd_idx; /* unshare the mount namespace in the monitor */ diff --git a/src/lxc/confile.c b/src/lxc/confile.c index 096dff349..bb7c3dbfe 100644 --- a/src/lxc/confile.c +++ b/src/lxc/confile.c @@ -1488,21 +1488,25 @@ static int set_config_group(const char *key, const char *value, if (!groups) 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. */ lxc_iterate_parts(token, groups, " \t") { - __do_free struct lxc_list *grouplist = NULL; + __do_free char *val = NULL; + __do_free struct string_entry *entry = NULL; - grouplist = lxc_list_new(); - if (!grouplist) + entry = zalloc(sizeof(struct string_entry)); + if (!entry) return ret_errno(ENOMEM); - grouplist->elem = strdup(token); - if (!grouplist->elem) + val = strdup(token); + if (!val) return ret_errno(ENOMEM); - lxc_list_add_tail(&lxc_conf->groups, move_ptr(grouplist)); + entry->val = move_ptr(val); + list_add_tail(&entry->head, &lxc_conf->groups); + move_ptr(entry); } return 0; @@ -4429,15 +4433,15 @@ static int get_config_group(const char *key, char *retv, int inlen, struct lxc_conf *c, void *data) { int len, fulllen = 0; - struct lxc_list *it; + struct string_entry *entry; if (!retv) inlen = 0; else memset(retv, 0, inlen); - lxc_list_for_each(it, &c->groups) { - strprint(retv, inlen, "%s\n", (char *)it->elem); + list_for_each_entry(entry, &c->groups, head) { + strprint(retv, inlen, "%s\n", entry->val); } return fulllen;