]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
conf: port groups to new list type
authorChristian Brauner <christian.brauner@ubuntu.com>
Fri, 27 Aug 2021 13:12:00 +0000 (15:12 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Fri, 27 Aug 2021 13:44:04 +0000 (15:44 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/conf.c
src/lxc/conf.h
src/lxc/confile.c

index 789540b0a7e98a7fa8ce9069117efd909f6548ec..a7565fc71462a7604b15e4d3749eddaea7bc0d2e 100644 (file)
@@ -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;
 }
 
index 5fcae6364bbc8712b246662f525625052fc118f7..24bf1b71b13d3b8cd78cd508c1dbb1cd31f03a26 100644 (file)
@@ -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 */
index 096dff349a71ac0bb2b86679d61e5e13587b11aa..bb7c3dbfe13702f94a37f30e283cb8c002244450 100644 (file)
@@ -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;