]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
add FR_TYPE_INTERNAL
authorAlan T. DeKok <aland@freeradius.org>
Mon, 12 May 2025 18:31:45 +0000 (14:31 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 12 May 2025 18:31:45 +0000 (14:31 -0400)
to hold multiple types which aren't leaf types, and which aren't
structural types.  But which are internal types that nothing
else should use

src/lib/json/json.c
src/lib/unlang/xlat_builtin.c
src/lib/util/htrie.h
src/lib/util/types.h
src/lib/util/value.c

index ddb388744c03954fd088bb8b8a57ee4dc6034c6b..079588c1d73de9f9c6f953de2540117a8f082530 100644 (file)
@@ -443,9 +443,7 @@ fr_slen_t fr_json_str_from_value(fr_sbuff_t *out, fr_value_box_t *vb, bool inclu
                fr_strerror_const("Structural boxes not yet supported");
                return -1;
 
-       case FR_TYPE_VOID:
-       case FR_TYPE_VALUE_BOX:
-       case FR_TYPE_MAX:
+       case FR_TYPE_INTERNAL:
                fr_strerror_printf("Box type %s cannot be converted to string", fr_type_to_str(vb->type));
                return -1;
        }
index a34697fbebdce72846e4317f41aca5a57a529c8b..086a7309b2bc321444ee1cde8ac88a274d4cc347 100644 (file)
@@ -361,11 +361,7 @@ static int CC_HINT(nonnull(2,3)) filename_xlat_escape(UNUSED request_t *request,
        case FR_TYPE_OCTETS:
                return 0;
 
-       case FR_TYPE_STRUCTURAL:
-       case FR_TYPE_NULL:
-       case FR_TYPE_VALUE_BOX:
-       case FR_TYPE_VOID:
-       case FR_TYPE_MAX:
+       case FR_TYPE_NON_LEAF:
                fr_assert(0);
                return -1;
 
index f0d3df737d3f196cb1eb6f175f34401d6f7ba9cc..0ed68ef27d14e12cae93a991ea6af66d7276716d 100644 (file)
@@ -164,11 +164,7 @@ static inline fr_htrie_type_t fr_htrie_hint(fr_type_t type)
        case FR_TYPE_FLOAT64:
                return FR_HTRIE_RB;
 
-       case FR_TYPE_VOID:
-       case FR_TYPE_NULL:
-       case FR_TYPE_VALUE_BOX:
-       case FR_TYPE_STRUCTURAL:
-       case FR_TYPE_MAX:
+       case FR_TYPE_NON_LEAF:
                break;
        }
 
index a098e7e1d233a53ec4b6e78973ef3a9358409843..26ea970d247784dbd7f347e5b29116858623398e 100644 (file)
@@ -256,6 +256,17 @@ typedef enum {
        FR_TYPE_VARIABLE_SIZE_DEF(_mid, _mid, _mid) \
        FR_TYPE_NUMERIC_DEF(_mid, _mid, _end)
 
+/** Types which are internal, and should not be used for real data.
+ *
+ * - Boxes (can represent any type)
+ * - Void (opaque types)
+ * - Invalid values
+ */
+#define FR_TYPE_INTERNAL_DEF(_beg, _mid, _end) \
+       _beg(FR_TYPE_VALUE_BOX) \
+       _mid(FR_TYPE_VOID) \
+       _end(FR_TYPE_MAX)
+
 /** Types which do not represent leaf values
  *
  * - Structural
@@ -265,11 +276,10 @@ typedef enum {
  * - Invalid values
  */
 #define FR_TYPE_NON_LEAF_DEF(_beg, _mid, _end) \
-       _beg(FR_TYPE_VALUE_BOX) \
-       _mid(FR_TYPE_VOID) \
-       _mid(FR_TYPE_NULL) \
-       _mid(FR_TYPE_MAX) \
+       _beg(FR_TYPE_NULL) \
+       FR_TYPE_INTERNAL_DEF(_mid, _mid, _mid) \
        FR_TYPE_STRUCTURAL_DEF(_mid, _mid, _end)
+
 /** @} */
 
 /** @name Macros that emit multiple case statements to group types
@@ -296,6 +306,7 @@ typedef enum {
 #define FR_TYPE_STRUCTURAL                     FR_TYPE_STRUCTURAL_DEF(CASE_BEG, CASE_MID, CASE_END)
 #define FR_TYPE_LEAF                           FR_TYPE_LEAF_DEF(CASE_BEG, CASE_MID, CASE_END)
 #define FR_TYPE_NON_LEAF                       FR_TYPE_NON_LEAF_DEF(CASE_BEG, CASE_MID, CASE_END)
+#define FR_TYPE_INTERNAL                       FR_TYPE_INTERNAL_DEF(CASE_BEG, CASE_MID, CASE_END)
 /** @} */
 
 /** @name Bool arrays that group types
index 8ceb7bc21343e7851db7a65323c289bb01e17b7f..dd3a3391bddc0f4d2dca68a40e0d622835c6a04a 100644 (file)
@@ -3712,11 +3712,7 @@ int fr_value_box_cast(TALLOC_CTX *ctx, fr_value_box_t *dst,
        /*
         *      Invalid types for casting (should have been caught earlier)
         */
-       case FR_TYPE_VALUE_BOX:
-       case FR_TYPE_STRUCTURAL:
-       case FR_TYPE_NULL:
-       case FR_TYPE_VOID:
-       case FR_TYPE_MAX:
+       case FR_TYPE_NON_LEAF:
                fr_strerror_printf("Invalid cast from %s to %s.  Invalid destination type",
                                   fr_type_to_str(src->type),
                                   fr_type_to_str(dst_type));
@@ -4044,9 +4040,7 @@ int fr_value_box_copy(TALLOC_CTX *ctx, fr_value_box_t *dst, const fr_value_box_t
        case FR_TYPE_STRUCT:
        case FR_TYPE_VSA:
        case FR_TYPE_VENDOR:
-       case FR_TYPE_VALUE_BOX:
-       case FR_TYPE_VOID:
-       case FR_TYPE_MAX:
+       case FR_TYPE_INTERNAL:
                fr_strerror_printf("Cannot copy data type '%s'", fr_type_to_str(src->type));
                return -1;
        }
@@ -6132,9 +6126,7 @@ int fr_value_box_escape_in_place(fr_value_box_t *vb, fr_value_box_escape_t const
        case FR_TYPE_STRUCT:
        case FR_TYPE_VSA:
        case FR_TYPE_VENDOR:
-       case FR_TYPE_VALUE_BOX:
-       case FR_TYPE_VOID:
-       case FR_TYPE_MAX:
+       case FR_TYPE_INTERNAL:
                fr_strerror_printf("Cannot escape data type '%s'", fr_type_to_str(vb->type));
                return -1;