]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Revert "do ENUM fixups before anything else"
authorAlan T. DeKok <aland@freeradius.org>
Wed, 9 Dec 2020 17:21:58 +0000 (12:21 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 9 Dec 2020 17:21:58 +0000 (12:21 -0500)
This reverts commit aa4e38fc1c95ebaed93c2977ad8c4b411806a54a.

src/lib/util/dict_tokenize.c

index b2f3746e3bf7986eaaba1e4286ca49fb3e66dd15..0970a1fc0c189b019977f04da8dba4d8e9ce9c70 100644 (file)
@@ -49,7 +49,7 @@ typedef enum {
 struct dict_fixup_s {
        char                    *filename;              //!< where the "enum" was defined
        int                     line;                   //!< ditto
-       fr_dlist_t              entry;                  //!< linked list of fixups
+       dict_fixup_t            *next;                  //!< Next in the linked list of fixups.
        dict_fixup_type_t       type;                   //!< type of the fixup
 
        fr_dict_attr_t const    *parent;                //!< Parent namespace.
@@ -96,7 +96,7 @@ typedef struct {
 
        TALLOC_CTX              *fixup_pool;            //!< Temporary pool for fixups, reduces holes
 
-       fr_dlist_head_t         fixups;                 //! various fixups
+       dict_fixup_t            *fixups;                //! various fixups
 
        fr_dict_attr_t          *ext_fixup;             //!< Head of a list of attributes to apply fixups to.
 } dict_tokenize_ctx_t;
@@ -200,15 +200,8 @@ static dict_fixup_t *dict_fixup_alloc(dict_tokenize_ctx_t *ctx, dict_fixup_type_
        }
        fixup->line = ctx->stack[ctx->stack_depth].line;
 
-       /*
-        *      Do ENUMs before CLONE.
-        */
-       if (type == DICT_FIXUP_ENUM) {
-               fr_dlist_insert_head(&ctx->fixups, fixup);
-       } else {
-               fr_dlist_insert_tail(&ctx->fixups, fixup);
-       }
-
+       fixup->next = ctx->fixups;
+       ctx->fixups = fixup;
 
        return fixup;
 }
@@ -1703,11 +1696,11 @@ static fr_dict_attr_t const *dict_find_or_load_reference(fr_dict_t **dict_def, c
 
 static int fr_dict_finalise(dict_tokenize_ctx_t *ctx)
 {
-       dict_fixup_t *fixup;
+       dict_fixup_t *fixup, *next;
+
+       for (fixup = ctx->fixups; fixup != NULL; fixup = next) {
+               next = fixup->next;
 
-       for (fixup = fr_dlist_head(&ctx->fixups);
-            fixup != NULL;
-            fixup = fr_dlist_next(&ctx->fixups, fixup)) {
                switch (fixup->type) {
                case DICT_FIXUP_ENUM: {
                        fr_dict_attr_t *da;
@@ -1860,7 +1853,7 @@ static int fr_dict_finalise(dict_tokenize_ctx_t *ctx)
 
                } /* switch over fixup type */
        }         /* loop over fixups */
-       fr_dlist_init(&ctx->fixups, dict_fixup_t, entry);
+       ctx->fixups = NULL;
 
        if (ctx->ext_fixup) {
                fr_dict_attr_t *da;
@@ -2278,10 +2271,7 @@ static int _dict_from_file(dict_tokenize_ctx_t *ctx,
                         *
                         *      @todo - make a nested ctx?
                         */
-                       if (!ctx->fixup_pool) {
-                               ctx->fixup_pool = talloc_pool(NULL, DICT_FIXUP_POOL_SIZE);
-                               fr_dlist_init(&ctx->fixups, dict_fixup_t, entry);
-                       }
+                       if (!ctx->fixup_pool) ctx->fixup_pool = talloc_pool(NULL, DICT_FIXUP_POOL_SIZE);
 
 
                        // check if there's a linked library for the
@@ -2631,7 +2621,6 @@ static int dict_from_file(fr_dict_t *dict,
        memset(&ctx, 0, sizeof(ctx));
        ctx.dict = dict;
        ctx.fixup_pool = talloc_pool(NULL, DICT_FIXUP_POOL_SIZE);
-       fr_dlist_init(&ctx.fixups, dict_fixup_t, entry);
        ctx.stack[0].dict = dict;
        ctx.stack[0].da = dict->root;
        ctx.stack[0].nest = FR_TYPE_MAX;