]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
These are really asserts
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 1 Mar 2021 19:25:02 +0000 (19:25 +0000)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 1 Mar 2021 19:25:02 +0000 (19:25 +0000)
src/lib/util/value.c

index 7c61c7aee2790ba2f5a361be812f67f6e421de0c..dc8c25eded8915cbbfa1db2799260764d3c11099 100644 (file)
@@ -2570,22 +2570,18 @@ static inline int fr_value_box_cast_integer_to_integer(UNUSED TALLOC_CTX *ctx, f
         *      Helps catch invalid fr_value_box_field_sizes
         *      entries, and shuts up clang analyzer.
         */
-       if (unlikely(len == 0)) {
-               fr_strerror_printf("Invalid cast from %s to %s.  %"PRId64" "
-                                  "invalid source type len, expected > 0, got %zu",
-                                  fr_table_str_by_value(fr_value_box_type_table, src->type, "<INVALID>"),
-                                  fr_table_str_by_value(fr_value_box_type_table, dst_type, "<INVALID>"),
-                                  len);
-               return -1;
-       }
-       if (unlikely(len > sizeof(uint64_t))) {
-               fr_strerror_printf("Invalid cast from %s to %s.  %"PRId64" "
-                                  "invalid source type len, expected <= %zu, got %zu",
-                                  fr_table_str_by_value(fr_value_box_type_table, src->type, "<INVALID>"),
-                                  fr_table_str_by_value(fr_value_box_type_table, dst_type, "<INVALID>"),
-                                  sizeof(uint64_t), len);
-               return -1;
-       }
+       if (!fr_cond_assert_msg(len == 0, "Invalid cast from %s to %s. "
+                               "invalid source type len, expected > 0, got %zu",
+                               fr_table_str_by_value(fr_value_box_type_table, src->type, "<INVALID>"),
+                               fr_table_str_by_value(fr_value_box_type_table, dst_type, "<INVALID>"),
+                               len)) return -1;
+
+       if (!fr_cond_assert_msg(len > sizeof(uint64_t),
+                               "Invalid cast from %s to %s. "
+                               "invalid source type len, expected <= %zu, got %zu",
+                               fr_table_str_by_value(fr_value_box_type_table, src->type, "<INVALID>"),
+                               fr_table_str_by_value(fr_value_box_type_table, dst_type, "<INVALID>"),
+                               sizeof(uint64_t), len)) return -1;
 #endif
 
        switch (src->type) {