]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Remove manual NULL checks
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 11 Oct 2021 03:45:31 +0000 (22:45 -0500)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 11 Oct 2021 03:45:31 +0000 (22:45 -0500)
src/lib/util/pair.c
src/lib/util/pair_print.c

index 35298cd47b57567f74ba673a8ff0add6e948f9ac..5bbe9bcac8434d86d0cf6eac68bd7f93974684b3 100644 (file)
@@ -332,8 +332,6 @@ fr_pair_t *fr_pair_copy(TALLOC_CTX *ctx, fr_pair_t const *vp)
 {
        fr_pair_t *n;
 
-       if (!vp) return NULL;
-
        VP_VERIFY(vp);
 
        n = fr_pair_afrom_da(ctx, vp->da);
@@ -511,8 +509,6 @@ void *fr_pair_iter_next_by_da(fr_dlist_head_t *list, void *to_eval, void *uctx)
        fr_pair_t       *c;
        fr_dict_attr_t  *da = uctx;
 
-       if (!to_eval) return NULL;
-
        for (c = to_eval; c; c = fr_dlist_next(list, c)) {
                VP_VERIFY(c);
                if (c->da == da) break;
@@ -536,8 +532,6 @@ void *fr_pair_iter_next_by_ancestor(fr_dlist_head_t *list, void *to_eval, void *
        fr_pair_t       *c;
        fr_dict_attr_t  *da = uctx;
 
-       if (!to_eval) return NULL;
-
        for (c = to_eval; c; c = fr_dlist_next(list, c)) {
                VP_VERIFY(c);
                if (fr_dict_attr_common_parent(da, c->da, true)) break;
@@ -1645,8 +1639,6 @@ int fr_pair_value_copy(fr_pair_t *dst, fr_pair_t *src)
  */
 int fr_pair_value_from_str(fr_pair_t *vp, char const *value, ssize_t inlen, char quote, bool tainted)
 {
-       if (!value) return -1;
-
        /*
         *      This is not yet supported because the rest of the APIs
         *      to parse pair names, etc. don't yet enforce "inlen".
@@ -2238,8 +2230,6 @@ int fr_pair_value_enum_box(fr_value_box_t const **out, fr_pair_t *vp)
 {
        fr_dict_enum_value_t const      *dv;
 
-       if (!out || !vp ) return -1;
-
        if (vp->da && vp->da->flags.has_value &&
            (dv = fr_dict_enum_by_value(vp->da, &vp->data))) {
                *out = dv->value;
@@ -2256,10 +2246,6 @@ int fr_pair_value_enum_box(fr_value_box_t const **out, fr_pair_t *vp)
  */
 void fr_pair_verify(char const *file, int line, fr_pair_t const *vp)
 {
-       if (!vp) {
-               fr_fatal_assert_fail("CONSISTENCY CHECK FAILED %s[%u]: fr_pair_t pointer was NULL", file, line);
-       }
-
        (void) talloc_get_type_abort_const(vp, fr_pair_t);
 
        if (!vp->da) {
index 0b299a2c18e82e7f63c9f4df72fe77a64d7e2ea2..9dee92ad40e0f1fc50b80398fb03fdb13da1e723 100644 (file)
@@ -103,10 +103,6 @@ ssize_t fr_pair_print(fr_sbuff_t *out, fr_pair_t const *parent, fr_pair_t const
        fr_sbuff_t              our_out = FR_SBUFF_NO_ADVANCE(out);
        fr_dict_attr_t const    *parent_da = NULL;
 
-       if (!out) return 0;
-
-       if (!vp || !vp->da) return 0;
-
        VP_VERIFY(vp);
 
        if ((vp->op > T_INVALID) && (vp->op < T_TOKEN_LAST)) {
@@ -144,7 +140,6 @@ void fr_pair_fprint(FILE *fp, fr_pair_t const *vp)
        char            buff[1024];
        fr_sbuff_t      sbuff = FR_SBUFF_OUT(buff, sizeof(buff));
 
-       if (!fp) return;
        VP_VERIFY(vp);
 
        fr_sbuff_in_char(&sbuff, '\t');