]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
update pure flags
authorAlan T. DeKok <aland@freeradius.org>
Thu, 25 Nov 2021 02:29:49 +0000 (21:29 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 25 Nov 2021 16:21:10 +0000 (11:21 -0500)
we default to pure, and various other things will over-ride
the flag if necessary.  e.g. impure functions will set the flag
to false, as will attribute references.

src/lib/unlang/xlat_tokenize.c

index 6e881bc944a4e7d2f43e59e7164ddec445652539..2e4a11883d409ba5706d797a137d6dd8f386a7e1 100644 (file)
@@ -119,6 +119,7 @@ static inline CC_HINT(always_inline) xlat_exp_t *xlat_exp_alloc_null(TALLOC_CTX
        xlat_exp_t *node;
 
        MEM(node = talloc_zero(ctx, xlat_exp_t));
+       node->flags.pure = true;        /* everything starts pure */
 
        return node;
 }
@@ -139,11 +140,13 @@ static inline CC_HINT(always_inline) xlat_exp_t *xlat_exp_alloc(TALLOC_CTX *ctx,
 
        node = xlat_exp_alloc_null(ctx);
        node->type = type;
-       if (in) node->fmt = talloc_bstrndup(node, in, inlen);
+       node->flags.pure = true;        /* everything starts pure */
+
+       if (!in) return node;
+
+       node->fmt = talloc_bstrndup(node, in, inlen);
 
        if (type == XLAT_BOX) {
-               node->flags.pure = true;         /* value boxes are always pure */
-               node->flags.needs_async = false; /* value boxes are always non-async */
                fr_value_box_strdup_shallow(&node->data, NULL, node->fmt, false);
        }
 
@@ -158,11 +161,6 @@ static inline CC_HINT(always_inline) xlat_exp_t *xlat_exp_alloc(TALLOC_CTX *ctx,
 static inline CC_HINT(always_inline) void xlat_exp_set_type(xlat_exp_t *node, xlat_type_t type)
 {
        node->type = type;
-
-       if (type == XLAT_BOX) {
-               node->flags.pure = true;         /* value boxes are always pure */
-               node->flags.needs_async = false; /* value boxes are always non-async */
-       }
 }
 
 #if 0