]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Fix more warnings
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 26 Jan 2022 14:45:25 +0000 (08:45 -0600)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 26 Jan 2022 14:45:25 +0000 (08:45 -0600)
src/lib/util/value.c
src/lib/util/value.h

index f8208b8f7da525d76ecdf155d694d567d34a1177..b3c2d1c57b13874485671b2d4009871e5c8f01af 100644 (file)
@@ -883,8 +883,6 @@ int fr_value_box_cmp_op(fr_token_t op, fr_value_box_t const *a, fr_value_box_t c
 {
        int compare = 0;
 
-       if (!a || !b) return -1;
-
        if (!fr_cond_assert(a->type != FR_TYPE_NULL)) return -1;
        if (!fr_cond_assert(b->type != FR_TYPE_NULL)) return -1;
 
@@ -3732,7 +3730,7 @@ void fr_value_box_strdup_shallow(fr_value_box_t *dst, fr_dict_attr_t const *enum
  *     - -1 on failure.
  */
 int fr_value_box_bstr_alloc(TALLOC_CTX *ctx, char **out, fr_value_box_t *dst, fr_dict_attr_t const *enumv,
-                          size_t len, bool tainted)
+                           size_t len, bool tainted)
 {
        char    *str;
 
@@ -5469,8 +5467,8 @@ int fr_value_box_list_concat_in_place(TALLOC_CTX *ctx,
 
        fr_dlist_t              entry;
 
-       if (!list || fr_dlist_empty(list)) {
-               fr_strerror_const("Invalid arguments.  List was NULL");
+       if (fr_dlist_empty(list)) {
+               fr_strerror_const("Invalid arguments.  List contains no elements");
                return -1;
        }
 
@@ -5498,7 +5496,7 @@ int fr_value_box_list_concat_in_place(TALLOC_CTX *ctx,
         *      i.e. we want to merge all its siblings
         *      into it.
         */
-       if (!out || (out == head_vb)) {
+       if (out == head_vb) {
                out = head_vb;  /* sync up out and head_vb */
 
                switch (type) {
@@ -5757,7 +5755,14 @@ void fr_value_box_list_untaint(fr_value_box_list_t *head)
  */
 void value_box_verify(char const *file, int line, fr_value_box_t const *vb, bool talloced)
 {
+DIAG_OFF(nonnull-compare)
+       /*
+        *      nonnull only does something if we're building
+        *      with ubsan...  We still want to assert event
+        *      if we're building without sanitizers.
+        */
        fr_fatal_assert_msg(vb, "CONSISTENCY CHECK FAILED %s[%i]: fr_value_box_t pointer was NULL", file, line);
+DIAG_ON(nonnull-compare)
 
        if (talloced) vb = talloc_get_type_abort_const(vb, fr_value_box_t);
 
index 0862d77d592463a850d157a13ec4aced3871932b..ab219ec5e0d4f7695aa2cd4ecd256f2a3ab5d587 100644 (file)
@@ -793,7 +793,7 @@ void                fr_value_box_strdup_shallow(fr_value_box_t *dst, fr_dict_attr_t const *enu
  */
 int            fr_value_box_bstr_alloc(TALLOC_CTX *ctx, char **out, fr_value_box_t *dst, fr_dict_attr_t const *enumv,
                                        size_t len, bool tainted)
-               CC_HINT(nonnull(2,3));
+               CC_HINT(nonnull(3));
 
 int            fr_value_box_bstr_realloc(TALLOC_CTX *ctx, char **out, fr_value_box_t *dst, size_t len)
                CC_HINT(nonnull(3));
@@ -831,7 +831,7 @@ int         fr_value_box_bstr_append_buffer(TALLOC_CTX *ctx, fr_value_box_t *dst, char
  */
 int            fr_value_box_mem_alloc(TALLOC_CTX *ctx, uint8_t **out, fr_value_box_t *dst, fr_dict_attr_t const *enumv,
                                       size_t len, bool tainted)
-               CC_HINT(nonnull(2,3));
+               CC_HINT(nonnull(3));
 
 int            fr_value_box_mem_realloc(TALLOC_CTX *ctx, uint8_t **out, fr_value_box_t *dst, size_t len)
                CC_HINT(nonnull(3));