]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
hoist "is_raw" to be more public
authorAlan T. DeKok <aland@freeradius.org>
Fri, 8 Sep 2023 13:01:19 +0000 (09:01 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 8 Sep 2023 13:44:23 +0000 (09:44 -0400)
There was already an "is_raw" field in the unresolved sub-structure
so just hoist it out, and use it instead of da->flags.is_raw

src/lib/server/tmpl.h
src/lib/server/tmpl_tokenize.c

index 281205cce4ceb85af854b5814b0b714cf4fff9b5..83a17ea01e96fd27feada3ffd1c55dcb762717c8 100644 (file)
@@ -429,7 +429,6 @@ typedef struct {
 
                struct {
                        char                    * _CONST name;          //!< Undefined reference type.
-                       bool                    _CONST is_raw;          //!< User wants the leaf to be raw.
                        fr_dict_attr_t const    * _CONST namespace;     //!< Namespace we should be trying
                                                                        ///< to resolve this attribute in.
                } unresolved;
@@ -440,9 +439,10 @@ typedef struct {
                                                        ///< Should point to the referenced
                                                        ///< attribute.
 
-       bool                    _CONST resolve_only;    //!< This reference and those before it
+       unsigned int            _CONST resolve_only : 1; //!< This reference and those before it
                                                        ///< in the list can only be used for
                                                        ///< resolution, not building out trees.
+       unsigned int            _CONST is_raw : 1;      /// is a raw reference
 
        tmpl_attr_type_t        _CONST type;            //!< Type of attribute reference.
 
@@ -489,42 +489,13 @@ FR_DLIST_FUNCS(tmpl_request_list, tmpl_request_t, entry)
 #define ar_parent                      parent
 #define ar_unknown                     unknown.da
 #define ar_unresolved                  unresolved.name
-#define ar_unresolved_raw              unresolved.is_raw
 #define ar_unresolved_namespace                unresolved.namespace
 
 #define ar_is_normal(_ar)              ((_ar)->ar_type == TMPL_ATTR_TYPE_NORMAL)
 #define ar_is_unspecified(_ar)         ((_ar)->ar_type == TMPL_ATTR_TYPE_UNSPEC)
 #define ar_is_unknown(_ar)             ((_ar)->ar_type == TMPL_ATTR_TYPE_UNKNOWN)
 #define ar_is_unresolved(_ar)          ((_ar)->ar_type == TMPL_ATTR_TYPE_UNRESOLVED)
-
-/** Indicate whether an attribute reference is raw
- *
- * Determining whether an attribute reference is raw, is slightly more complex
- * given the raw flag is either coming from the attribute or an internal
- * "is_raw" flag in the unresolved entry.
- *
- * @param[in] ar       to check for rawness.
- * @return
- *     - true if the attribute reference is raw.
- *     - false if the attribute reference is not raw.
- */
-static inline bool ar_is_raw(tmpl_attr_t const *ar)
-{
-       switch (ar->ar_type) {
-       case TMPL_ATTR_TYPE_NORMAL:
-       case TMPL_ATTR_TYPE_UNKNOWN:
-               return ar->ar_da->flags.is_raw;
-
-       case TMPL_ATTR_TYPE_UNRESOLVED:
-               return ar->ar_unresolved_raw;
-
-       case TMPL_ATTR_TYPE_UNSPEC:
-               return false;
-       }
-
-       fr_assert_fail("ar type (%i) is invalid", (int)ar->ar_type);
-       return false;
-}
+#define ar_is_raw(_ar)                 ((_ar)->is_raw)
 
 #define ar_num                         filter.num
 #define ar_cond                                filter.cond
index 7d90132a695c461234c6f3cdcb9761baa09d77bb..3aedccd01a968c7e7b4f18a97bbfaf4977a247cd 100644 (file)
@@ -3836,13 +3836,6 @@ static inline CC_HINT(always_inline) int tmpl_attr_resolve(tmpl_t *vpt, tmpl_res
                        next->ar_unresolved_namespace = da;
                }
 
-               /*
-                *      If the user wanted the leaf
-                *      to be raw, and it's not, correct
-                *      that now.
-                */
-               if (ar->ar_unresolved_raw) attr_to_raw(vpt, ar);
-
                /*
                 *      Remove redundant attributes
                 *
@@ -4127,7 +4120,7 @@ static void attr_to_raw(tmpl_t *vpt, tmpl_attr_t *ref)
        {
                ref->da = ref->ar_unknown = fr_dict_unknown_afrom_da(vpt, ref->da);
                ref->ar_unknown->type = FR_TYPE_OCTETS;
-               ref->ar_unknown->flags.is_raw = 1;
+               ref->is_raw = 1;
                ref->ar_unknown->flags.is_unknown = 1;
                ref->type = TMPL_ATTR_TYPE_UNKNOWN;
        }
@@ -4137,11 +4130,11 @@ static void attr_to_raw(tmpl_t *vpt, tmpl_attr_t *ref)
 
        case TMPL_ATTR_TYPE_UNKNOWN:
                ref->ar_unknown->type = FR_TYPE_OCTETS;
-               ref->ar_unknown->flags.is_raw = 1;
+               ref->is_raw = 1;
                break;
 
        case TMPL_ATTR_TYPE_UNRESOLVED:
-               ref->ar_unresolved_raw = true;
+               ref->is_raw = true;
                break;
        }