From: Alan T. DeKok Date: Fri, 8 Sep 2023 13:01:19 +0000 (-0400) Subject: hoist "is_raw" to be more public X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=83dedf4e33da3e51b81b47576f159e0dce78aba9;p=thirdparty%2Ffreeradius-server.git hoist "is_raw" to be more public 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 --- diff --git a/src/lib/server/tmpl.h b/src/lib/server/tmpl.h index 281205cce4c..83a17ea01e9 100644 --- a/src/lib/server/tmpl.h +++ b/src/lib/server/tmpl.h @@ -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 diff --git a/src/lib/server/tmpl_tokenize.c b/src/lib/server/tmpl_tokenize.c index 7d90132a695..3aedccd01a9 100644 --- a/src/lib/server/tmpl_tokenize.c +++ b/src/lib/server/tmpl_tokenize.c @@ -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; }