]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Use the FR_SBUFF_RETURN_ERROR macro
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sun, 4 Sep 2022 20:53:04 +0000 (16:53 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sun, 4 Sep 2022 20:57:37 +0000 (16:57 -0400)
14 files changed:
src/lib/ldap/filter.c
src/lib/server/cond_tokenize.c
src/lib/server/tmpl_tokenize.c
src/lib/unlang/xlat_expr.c
src/lib/unlang/xlat_tokenize.c
src/lib/util/base16.c
src/lib/util/base32.c
src/lib/util/base64.c
src/lib/util/dict_util.c
src/lib/util/regex.c
src/lib/util/sbuff.c
src/lib/util/size.c
src/lib/util/time.c
src/lib/util/value.c

index 8bf4eeb409ab5536409c45d09974712293a045ca..57e50236f39e94f55f57896c0462d4f5c3616c13 100644 (file)
@@ -95,7 +95,7 @@ static fr_slen_t ldap_filter_parse_logic(ldap_filter_t *node, fr_sbuff_t *sbuff,
        while (fr_sbuff_is_char(sbuff, '(')) {
                if (node->logic_op == LDAP_FILTER_LOGIC_NOT) {
                        fr_strerror_const("'!' operator can only apply to one filter");
-                       return fr_sbuff_error(sbuff);
+                       FR_SBUFF_ERROR_RETURN(sbuff);
                }
                MEM(child_node = talloc_zero(node, ldap_filter_t));
                fr_dlist_insert_tail(&node->children, child_node);
@@ -138,7 +138,7 @@ static fr_slen_t ldap_filter_parse_filter(ldap_filter_t *node, fr_sbuff_t *sbuff
        len = fr_sbuff_out_bstrncpy_allowed(&attr_sbuff, sbuff, FILTER_ATTR_MAX_LEN - 1, fr_ldap_attr_allowed_chars);
        if (len == 0) {
                fr_strerror_const("Missing attribute name");
-               return fr_sbuff_error(sbuff);
+               FR_SBUFF_ERROR_RETURN(sbuff);
        }
 
        MEM(node->attr = talloc_zero_array(node, char, len+1));
@@ -165,12 +165,12 @@ static fr_slen_t ldap_filter_parse_filter(ldap_filter_t *node, fr_sbuff_t *sbuff
                }
 
                fr_strerror_const("Unsupported extended match rule");
-               return fr_sbuff_error(sbuff);
+               FR_SBUFF_ERROR_RETURN(sbuff);
 
        found_op:
                if(!(fr_sbuff_next_if_char(sbuff, ':'))) {
                        fr_strerror_const("Missing ':' after extended match rule");
-                       return fr_sbuff_error(sbuff);
+                       FR_SBUFF_ERROR_RETURN(sbuff);
                }
        }
 
@@ -188,13 +188,13 @@ static fr_slen_t ldap_filter_parse_filter(ldap_filter_t *node, fr_sbuff_t *sbuff
 
        default:
                fr_strerror_const("Incorrect operator");
-               return fr_sbuff_error(sbuff);
+               FR_SBUFF_ERROR_RETURN(sbuff);
        }
 
        if (((node->op == LDAP_FILTER_OP_BIT_AND) || (node->op == LDAP_FILTER_OP_BIT_OR)) &&
            (op != LDAP_FILTER_OP_EQ)) {
                fr_strerror_const("Extended match rule only valid with '=' operator");
-               return fr_sbuff_error(sbuff);
+               FR_SBUFF_ERROR_RETURN(sbuff);
        }
 
        /*
@@ -205,7 +205,7 @@ static fr_slen_t ldap_filter_parse_filter(ldap_filter_t *node, fr_sbuff_t *sbuff
 
        if (len == 0) {
                fr_strerror_const("Missing filter value");
-               return fr_sbuff_error(sbuff);
+               FR_SBUFF_ERROR_RETURN(sbuff);
        }
 
        /*
@@ -229,7 +229,7 @@ static fr_slen_t ldap_filter_parse_filter(ldap_filter_t *node, fr_sbuff_t *sbuff
        case LDAP_FILTER_OP_SUBSTR:
                if (fr_value_box_bstrndup(node, node->value, NULL, val_buffer, len, false) < 0) {
                        fr_strerror_const("Failed parsing value for filter");
-                       return fr_sbuff_error(sbuff);
+                       FR_SBUFF_ERROR_RETURN(sbuff);
                }
                break;
 
@@ -244,7 +244,7 @@ static fr_slen_t ldap_filter_parse_filter(ldap_filter_t *node, fr_sbuff_t *sbuff
                if (fr_value_box_from_str(node, node->value, FR_TYPE_UINT32, NULL,
                                          val_buffer, len, NULL, false) < 0) {
                        fr_strerror_const("Failed parsing value for filter");
-                       return fr_sbuff_error(sbuff);
+                       FR_SBUFF_ERROR_RETURN(sbuff);
                }
                break;
 
@@ -293,7 +293,7 @@ static fr_slen_t ldap_filter_parse_node(ldap_filter_t *node, fr_sbuff_t *sbuff,
 
        if (!fr_sbuff_next_if_char(sbuff, '(')) {
                fr_strerror_const("Missing '('");
-               return fr_sbuff_error(sbuff);
+               FR_SBUFF_ERROR_RETURN(sbuff);
        }
 
        /*
@@ -313,7 +313,7 @@ static fr_slen_t ldap_filter_parse_node(ldap_filter_t *node, fr_sbuff_t *sbuff,
 
        if (!fr_sbuff_next_if_char(sbuff, ')')) {
                fr_strerror_const("Missing ')'");
-               return fr_sbuff_error(sbuff);
+               FR_SBUFF_ERROR_RETURN(sbuff);
        }
        parsed ++;
 
@@ -323,7 +323,7 @@ static fr_slen_t ldap_filter_parse_node(ldap_filter_t *node, fr_sbuff_t *sbuff,
         */
        if ((depth == 0) && (fr_sbuff_extend(sbuff))) {
                fr_strerror_const("Extra characters at the end of LDAP filter");
-               return fr_sbuff_error(sbuff);
+               FR_SBUFF_ERROR_RETURN(sbuff);
        }
 
        return parsed;
index 9858722e7deb2c9331171b4c887c0cb4f94e776d..4f5ddadbece9085f6608c52f17fd74dc8dfc7f97 100644 (file)
@@ -944,7 +944,7 @@ static fr_slen_t cond_tokenize_operand(fr_cond_t *c, tmpl_t **out,
        /*
         *      Parse (optional) cast
         */
-       if (tmpl_cast_from_substr(&our_t_rules, &our_in) < 0) return fr_sbuff_error(&our_in);
+       if (tmpl_cast_from_substr(&our_t_rules, &our_in) < 0) FR_SBUFF_ERROR_RETURN(&our_in);
 
        fr_sbuff_adv_past_whitespace(&our_in, SIZE_MAX, NULL);
        fr_sbuff_marker(&m, &our_in);
@@ -984,7 +984,7 @@ static fr_slen_t cond_tokenize_operand(fr_cond_t *c, tmpl_t **out,
        if (slen < 0) {
        error:
                talloc_free(vpt);
-               return fr_sbuff_error(&our_in);
+               FR_SBUFF_ERROR_RETURN(&our_in);
        }
 
        if ((type != T_BARE_WORD) && !fr_sbuff_next_if_char(&our_in, fr_token_quote[type])) { /* Quoting */
@@ -1424,7 +1424,7 @@ done:
        if (cond_normalise(ctx, lhs ? lhs->quote : T_INVALID, &c) < 0) {
                talloc_free(c);
                fr_sbuff_set_to_start(&our_in);
-               return fr_sbuff_error(&our_in);
+               FR_SBUFF_ERROR_RETURN(&our_in);
        }
 
        *out = c;
index c974bf427843065062ebdf2de9e6975051bff9fa..b2e8710834e8af278c41fa2b5026a3b05e6388df 100644 (file)
@@ -641,7 +641,7 @@ static fr_slen_t tmpl_request_ref_list_from_substr(TALLOC_CTX *ctx, tmpl_attr_er
                        fr_sbuff_set(&our_in, in);      /* Marker at the start */
                error:
                        tmpl_request_list_talloc_free_to_tail(out, tail);
-                       return fr_sbuff_error(&our_in);
+                       FR_SBUFF_ERROR_RETURN(&our_in);
                }
 
                /*
@@ -1327,7 +1327,7 @@ static fr_slen_t tmpl_attr_parse_filter(tmpl_attr_error_t *err, tmpl_attr_t *ar,
                fr_strerror_const("Filters not allowed here");
                if (err) *err = TMPL_ATTR_ERROR_FILTER_NOT_ALLOWED;
                fr_sbuff_set_to_start(&our_name);
-               return fr_sbuff_error(&our_name);
+               FR_SBUFF_ERROR_RETURN(&our_name);
        }
 
        ar->ar_filter_type = TMPL_ATTR_FILTER_TYPE_INDEX;
@@ -1353,7 +1353,7 @@ static fr_slen_t tmpl_attr_parse_filter(tmpl_attr_error_t *err, tmpl_attr_t *ar,
                fr_strerror_const("No closing ']' for array index");
                if (err) *err = TMPL_ATTR_ERROR_INVALID_ARRAY_INDEX;
        error:
-               return fr_sbuff_error(&our_name);
+               FR_SBUFF_ERROR_RETURN(&our_name);
 
        default:
        {
@@ -1546,7 +1546,7 @@ static inline int tmpl_attr_afrom_attr_substr(TALLOC_CTX *ctx, tmpl_attr_error_t
                if (err) *err = TMPL_ATTR_ERROR_NESTING_TOO_DEEP;
        error:
                fr_sbuff_marker_release(&m_s);
-               return fr_sbuff_error(name);
+               FR_SBUFF_ERROR_RETURN(name);
        }
 
        /*
@@ -2317,7 +2317,7 @@ static fr_slen_t tmpl_afrom_value_substr(TALLOC_CTX *ctx, tmpl_t **out, fr_sbuff
        if (!fr_type_is_leaf(t_rules->cast)) {
                fr_strerror_printf("%s is not a valid cast type",
                                   fr_type_to_str(t_rules->cast));
-               return fr_sbuff_error(&our_in);
+               FR_SBUFF_ERROR_RETURN(&our_in);
        }
 
        vpt = tmpl_alloc_null(ctx);
@@ -2325,7 +2325,7 @@ static fr_slen_t tmpl_afrom_value_substr(TALLOC_CTX *ctx, tmpl_t **out, fr_sbuff
                                     t_rules->cast, allow_enum ? t_rules->enumv : NULL,
                                     &our_in, p_rules, false) < 0) {
                talloc_free(vpt);
-               return fr_sbuff_error(&our_in);
+               FR_SBUFF_ERROR_RETURN(&our_in);
        }
 
        tmpl_init(vpt, TMPL_TYPE_DATA, quote, fr_sbuff_start(&our_in), fr_sbuff_used(&our_in), t_rules);
@@ -2365,7 +2365,7 @@ static fr_slen_t tmpl_afrom_bool_substr(TALLOC_CTX *ctx, tmpl_t **out, fr_sbuff_
 
        if (!tmpl_substr_terminal_check(&our_in, p_rules)) {
                fr_strerror_const("Unexpected text after bool");
-               return fr_sbuff_error(in);
+               FR_SBUFF_ERROR_RETURN(in);
        }
 
        MEM(vpt = tmpl_alloc(ctx, TMPL_TYPE_DATA, T_BARE_WORD, fr_sbuff_start(&our_in), fr_sbuff_used(&our_in)));
@@ -2412,7 +2412,7 @@ static fr_slen_t tmpl_afrom_octets_substr(TALLOC_CTX *ctx, tmpl_t **out, fr_sbuf
                fr_strerror_const("Hex string not even length");
        error:
                talloc_free(vpt);
-               return fr_sbuff_error(&our_in);
+               FR_SBUFF_ERROR_RETURN(&our_in);
        }
        if (len == 0) {
                fr_strerror_const("Zero length hex string is invalid");
@@ -2466,7 +2466,7 @@ static fr_slen_t tmpl_afrom_ipv4_substr(TALLOC_CTX *ctx, tmpl_t **out, fr_sbuff_
              fr_sbuff_out(NULL, &octet, &our_in) && fr_sbuff_next_if_char(&our_in, '.') &&
              fr_sbuff_out(NULL, &octet, &our_in))) {
        error:
-               return fr_sbuff_error(&our_in);
+               FR_SBUFF_ERROR_RETURN(&our_in);
        }
 
        /*
@@ -2550,7 +2550,7 @@ static fr_slen_t tmpl_afrom_ipv6_substr(TALLOC_CTX *ctx, tmpl_t **out, fr_sbuff_
        len = fr_sbuff_adv_past_allowed(&our_in, FR_IPADDR_STRLEN + 1, ipv6_chars, NULL);
        if ((len < 2) || (len > FR_IPADDR_STRLEN)) {
        error:
-               return fr_sbuff_error(&our_in);
+               FR_SBUFF_ERROR_RETURN(&our_in);
        }
 
        /*
@@ -2722,7 +2722,7 @@ static fr_slen_t tmpl_afrom_integer_substr(TALLOC_CTX *ctx, tmpl_t **out, fr_sbu
                if (!tmpl_substr_terminal_check(&our_in, p_rules)) {
                        fr_strerror_const("Unexpected text after signed integer");
                error:
-                       return fr_sbuff_error(&our_in);
+                       FR_SBUFF_ERROR_RETURN(&our_in);
                }
 
                MEM(vpt = tmpl_alloc(ctx, TMPL_TYPE_DATA,
@@ -2792,7 +2792,7 @@ static ssize_t tmpl_afrom_float_substr(TALLOC_CTX *ctx, tmpl_t **out, fr_sbuff_t
 
        if (!tmpl_substr_terminal_check(&our_in, p_rules)) {
                fr_strerror_const("Unexpected text after float");
-               return fr_sbuff_error(&our_in);
+               FR_SBUFF_ERROR_RETURN(&our_in);
        }
 
        MEM(vpt = tmpl_alloc(ctx, TMPL_TYPE_DATA,
@@ -2899,7 +2899,7 @@ fr_slen_t tmpl_afrom_substr(TALLOC_CTX *ctx, tmpl_t **out,
                                                               p_rules, t_rules);
                        }
 
-                       if (slen < 0) return fr_sbuff_error(&our_in);
+                       if (slen < 0) FR_SBUFF_ERROR_RETURN(&our_in);
 
                        if (xlat_needs_resolving(head)) UNRESOLVED_SET(&type);
 
@@ -3027,7 +3027,7 @@ fr_slen_t tmpl_afrom_substr(TALLOC_CTX *ctx, tmpl_t **out,
                        }
                bareword_error:
                        talloc_free(vpt);
-                       return fr_sbuff_error(&our_in);
+                       FR_SBUFF_ERROR_RETURN(&our_in);
                }
 
                /*
@@ -3091,7 +3091,7 @@ fr_slen_t tmpl_afrom_substr(TALLOC_CTX *ctx, tmpl_t **out,
                        slen = xlat_tokenize_ephemeral(vpt, &head, t_rules->xlat.runtime_el,
                                                       &our_in, p_rules, t_rules);
                }
-               if (slen < 0) return fr_sbuff_error(&our_in);
+               if (slen < 0) FR_SBUFF_ERROR_RETURN(&our_in);
 
                /*
                 *      If the string doesn't contain an xlat,
@@ -3151,7 +3151,7 @@ fr_slen_t tmpl_afrom_substr(TALLOC_CTX *ctx, tmpl_t **out,
                slen = xlat_tokenize_argv(vpt, &head, &our_in, p_rules, t_rules);
                if (slen < 0) {
                        talloc_free(vpt);
-                       return fr_sbuff_error(&our_in);
+                       FR_SBUFF_ERROR_RETURN(&our_in);
                }
 
                if (xlat_needs_resolving(head)) UNRESOLVED_SET(&type);
@@ -3182,7 +3182,7 @@ fr_slen_t tmpl_afrom_substr(TALLOC_CTX *ctx, tmpl_t **out,
                                                       p_rules, t_rules);
                }
 
-               if (slen < 0) return fr_sbuff_error(&our_in);
+               if (slen < 0) FR_SBUFF_ERROR_RETURN(&our_in);
 
                /*
                 *      Check if the string actually contains an xlat
@@ -3214,7 +3214,7 @@ fr_slen_t tmpl_afrom_substr(TALLOC_CTX *ctx, tmpl_t **out,
 
        default:
                fr_assert(0);
-               return fr_sbuff_error(&our_in);
+               FR_SBUFF_ERROR_RETURN(&our_in);
        }
 
        TMPL_VERIFY(vpt);
index c96a9e02df5e759693ec7fd76331149da3dfee05..1d15dc602118ee4c567729de437fcda829dbd5b3 100644 (file)
@@ -1910,7 +1910,7 @@ static fr_slen_t tokenize_unary(xlat_exp_head_t *head, xlat_exp_t **out, fr_sbuf
                fr_sbuff_skip_whitespace(&our_in);
                if (fr_sbuff_is_char(&our_in, c)) {
                        fr_strerror_const("Double operator is invalid");
-                       return fr_sbuff_error(&our_in);
+                       FR_SBUFF_ERROR_RETURN(&our_in);
                }
        }
 
@@ -2034,12 +2034,12 @@ static fr_slen_t expr_cast_from_substr(fr_type_t *cast, fr_sbuff_t *in)
 
        if (!fr_type_is_leaf(*cast)) {
                fr_strerror_printf("Invalid data type '%s' in cast", fr_type_to_str(*cast));
-               return fr_sbuff_error(&our_in)
+               FR_SBUFF_ERROR_RETURN(&our_in)
        }
 
        if (!fr_sbuff_next_if_char(&our_in, close)) {
                fr_strerror_const("Unterminated cast");
-               return fr_sbuff_error(&our_in)
+               FR_SBUFF_ERROR_RETURN(&our_in)
        }
        fr_sbuff_adv_past_whitespace(&our_in, SIZE_MAX, NULL);
 
@@ -2099,7 +2099,7 @@ static fr_slen_t tokenize_regex_rhs(xlat_exp_head_t *head, xlat_exp_t **out, fr_
        if (!vpt) {
        error:
                talloc_free(node);
-               return fr_sbuff_error(&our_in);
+               FR_SBUFF_ERROR_RETURN(&our_in);
        }
 
        /*
@@ -2120,7 +2120,7 @@ static fr_slen_t tokenize_regex_rhs(xlat_exp_head_t *head, xlat_exp_t **out, fr_
        fr_sbuff_marker(&flag, &our_in);
        if (tmpl_regex_flags_substr(vpt, &our_in, bracket_rules->terminals) < 0) {
                talloc_free(node);
-               return fr_sbuff_error(&our_in);
+               FR_SBUFF_ERROR_RETURN(&our_in);
        }
 
        fr_sbuff_skip_whitespace(&our_in);
@@ -2259,7 +2259,7 @@ static fr_slen_t tokenize_field(xlat_exp_head_t *head, xlat_exp_t **out, fr_sbuf
         */
        if (tmpl_afrom_substr(node, &vpt, &our_in, quote, p_rules, &our_t_rules) < 0) {
        error:
-               return fr_sbuff_error(&our_in);
+               FR_SBUFF_ERROR_RETURN(&our_in);
        }
 
        if (quote != T_BARE_WORD) {
@@ -2481,7 +2481,7 @@ static fr_slen_t tokenize_expression(xlat_exp_head_t *head, xlat_exp_t **out, fr
         *      Get the LHS of the operation.
         */
        slen = tokenize_unary(head, &lhs, &our_in, p_rules, t_rules, bracket_rules, &c, cond);
-       if (slen < 0) return fr_sbuff_error(&our_in);
+       if (slen < 0) FR_SBUFF_ERROR_RETURN(&our_in);
 
        if (slen == 0) {
                fr_assert(lhs == NULL);
@@ -2550,7 +2550,7 @@ redo:
        if (!binary_ops[op].str) {
                fr_strerror_printf("Invalid operator");
                fr_sbuff_set(&our_in, &m_op);
-               return fr_sbuff_error(&our_in);
+               FR_SBUFF_ERROR_RETURN(&our_in);
        }
 
        fr_assert(precedence[op] != 0);
@@ -2573,7 +2573,7 @@ redo:
                fr_strerror_printf("Operator '%c' is only applied to the left hand side of the '%s' operation, add (..) to evaluate the operation first", c, fr_tokens[op]);
        fail_lhs:
                fr_sbuff_set(&our_in, &m_lhs);
-               return fr_sbuff_error(&our_in);
+               FR_SBUFF_ERROR_RETURN(&our_in);
        }
 
        fr_sbuff_skip_whitespace(&our_in);
@@ -2591,7 +2591,7 @@ redo:
                if ((op != T_OP_CMP_EQ) && (op != T_OP_NE)) {
                        fr_strerror_printf("Invalid operatord '%s' for left hand side structural attribute", fr_tokens[op]);
                        fr_sbuff_set(&our_in, &m_op);
-                       return fr_sbuff_error(&our_in);
+                       FR_SBUFF_ERROR_RETURN(&our_in);
                }
 
                fr_assert(0);
@@ -2627,7 +2627,7 @@ redo:
                if (reparse_rcode(head, &rhs, true) < 0) {
                fail_rhs:
                        fr_sbuff_set(&our_in, &m_rhs);
-                       return fr_sbuff_error(&our_in);
+                       FR_SBUFF_ERROR_RETURN(&our_in);
                }
 
                if ((lhs->type == XLAT_FUNC) && (lhs->call.func->token == op)) {
index 5f92723bb8ecb10a563a1f74ad14e4bd6c3defd5..fc83391da3790418903ff639f8710b648048d396 100644 (file)
@@ -656,7 +656,7 @@ static inline int xlat_tokenize_attribute(xlat_exp_head_t *head, fr_sbuff_t *in,
        error:
                fr_sbuff_marker_release(&m_s);
                talloc_free(node);
-               return fr_sbuff_error(in);
+               FR_SBUFF_ERROR_RETURN(in);
        }
 
        /*
@@ -1445,7 +1445,7 @@ fr_slen_t xlat_tokenize_ephemeral(TALLOC_CTX *ctx, xlat_exp_head_t **out,
        if (xlat_tokenize_string(head, &our_in,
                                 false, p_rules, &our_t_rules) < 0) {
                talloc_free(head);
-               return fr_sbuff_error(&our_in);
+               FR_SBUFF_ERROR_RETURN(&our_in);
        }
 
        /*
@@ -1549,7 +1549,7 @@ fr_slen_t xlat_tokenize_argv(TALLOC_CTX *ctx, xlat_exp_head_t **out, fr_sbuff_t
                                }
                                talloc_free(head);
 
-                               return fr_sbuff_error(&our_in); /* error */
+                               FR_SBUFF_ERROR_RETURN(&our_in); /* error */
                        }
                        break;
 
@@ -1667,7 +1667,7 @@ fr_slen_t xlat_tokenize(TALLOC_CTX *ctx, xlat_exp_head_t **out, fr_sbuff_t *in,
        if (xlat_tokenize_string(head, &our_in,
                                  false, p_rules, t_rules) < 0) {
                talloc_free(head);
-               return fr_sbuff_error(&our_in);
+               FR_SBUFF_ERROR_RETURN(&our_in);
        }
 
        /*
index 51471fc44efa8296268eecf251720331ae187a68..e3131e5232884b5912453551f4183b4d0f2e667e 100644 (file)
@@ -156,7 +156,7 @@ fr_slen_t fr_base16_decode_nstd(fr_sbuff_parse_error_t *err, fr_dbuff_t *out, fr
                if (!a || !b) {
                        if (a && !b && no_trailing) {
                                if (err) *err = FR_SBUFF_PARSE_ERROR_TRAILING;
-                               return fr_sbuff_error(&our_in);
+                               FR_SBUFF_ERROR_RETURN(&our_in);
                        }
                        break;
                }
index a6697a196beeb08823071e003e13ee099d757a2d..078f3f62a11800eeb1bdece83ed14cab61dc70e3 100644 (file)
@@ -348,7 +348,7 @@ fr_slen_t fr_base32_decode_nstd(fr_sbuff_parse_error_t *err, fr_dbuff_t *out, fr
 
                        if (err) *err = FR_SBUFF_PARSE_ERROR_OUT_OF_SPACE;
 
-                       return fr_sbuff_error(&our_in);
+                       FR_SBUFF_ERROR_RETURN(&our_in);
                }
 
                fr_sbuff_advance(&our_in, 8);
@@ -423,7 +423,7 @@ fr_slen_t fr_base32_decode_nstd(fr_sbuff_parse_error_t *err, fr_dbuff_t *out, fr
        bad_format:
                if (err) *err = FR_SBUFF_PARSE_ERROR_FORMAT;
 
-               return fr_sbuff_error(&our_in);
+               FR_SBUFF_ERROR_RETURN(&our_in);
        }
 
        if (expect_padding) {
@@ -454,7 +454,7 @@ fr_slen_t fr_base32_decode_nstd(fr_sbuff_parse_error_t *err, fr_dbuff_t *out, fr
 
                if (err) *err = FR_SBUFF_PARSE_ERROR_TRAILING;
 
-               return fr_sbuff_error(&our_in);
+               FR_SBUFF_ERROR_RETURN(&our_in);
        }
 
        if (err) *err = FR_SBUFF_PARSE_OK;
index 4d4d9905ed76081a03a350b91a07326af3ddd572..c1036c15a08d71306b4f3cf21198310bef12949f 100644 (file)
@@ -427,7 +427,7 @@ fr_slen_t fr_base64_decode_nstd(fr_sbuff_parse_error_t *err, fr_dbuff_t *out, fr
 
                        if (err) *err = FR_SBUFF_PARSE_ERROR_OUT_OF_SPACE;
 
-                       return fr_sbuff_error(&our_in);
+                       FR_SBUFF_ERROR_RETURN(&our_in);
                }
 
                fr_sbuff_advance(&our_in, 4);
@@ -474,7 +474,7 @@ fr_slen_t fr_base64_decode_nstd(fr_sbuff_parse_error_t *err, fr_dbuff_t *out, fr
        bad_format:
                if (err) *err = FR_SBUFF_PARSE_ERROR_FORMAT;
 
-               return fr_sbuff_error(&our_in);
+               FR_SBUFF_ERROR_RETURN(&our_in);
        }
 
        if (expect_padding) {
@@ -499,7 +499,7 @@ fr_slen_t fr_base64_decode_nstd(fr_sbuff_parse_error_t *err, fr_dbuff_t *out, fr
 
                if (err) *err = FR_SBUFF_PARSE_ERROR_TRAILING;
 
-               return fr_sbuff_error(&our_in);
+               FR_SBUFF_ERROR_RETURN(&our_in);
        }
 
        fr_sbuff_set(in, &our_in);
index 195726ecfca25d11ebaa52e2c8e1093ed736815e..09bc464e731da2cd2452f957c14dc75806c8d596 100644 (file)
@@ -3040,13 +3040,13 @@ fr_slen_t fr_dict_enum_name_from_substr(fr_sbuff_t *out, fr_sbuff_parse_error_t
                if (fr_sbuff_used(&our_in) == 0) {
                        fr_strerror_const("VALUE name is empty");
                        if (err) *err = FR_SBUFF_PARSE_ERROR_NOT_FOUND;
-                       return fr_sbuff_error(&our_in);
+                       FR_SBUFF_ERROR_RETURN(&our_in);
                }
 
                fr_strerror_const("VALUE name must contain at least one alpha character");
                if (err) *err = FR_SBUFF_PARSE_ERROR_FORMAT;
                fr_sbuff_set_to_start(&our_in); /* Marker should be at the start of the enum */
-               return fr_sbuff_error(&our_in);
+               FR_SBUFF_ERROR_RETURN(&our_in);
        }
 
        /*
@@ -3055,7 +3055,7 @@ fr_slen_t fr_dict_enum_name_from_substr(fr_sbuff_t *out, fr_sbuff_parse_error_t
        if (tt && !fr_sbuff_is_terminal(&our_in, tt)) {
                fr_strerror_const("VALUE name has trailing text");
                if (err) *err = FR_SBUFF_PARSE_ERROR_TRAILING;
-               return fr_sbuff_error(&our_in);
+               FR_SBUFF_ERROR_RETURN(&our_in);
        }
 
        if (out) return fr_sbuff_out_bstrncpy_exact(out, in, fr_sbuff_used(&our_in));
index a85cc639c939d2b446bd4e3258144bb477fbc86b..9d39c64db3679746f89436e0960c1ffb2b2242fc 100644 (file)
@@ -1284,7 +1284,7 @@ fr_slen_t regex_flags_parse(int *err, fr_regex_flags_t *out, fr_sbuff_t *in,
                        if (err_on_dup && out->_f) { \
                                fr_strerror_printf("Duplicate regex flag '%c'", *our_in.p); \
                                if (err) *err = -2; \
-                               return fr_sbuff_error(&our_in); \
+                               FR_SBUFF_ERROR_RETURN(&our_in); \
                        } \
                        out->_f = 1; \
                        break
@@ -1302,7 +1302,7 @@ fr_slen_t regex_flags_parse(int *err, fr_regex_flags_t *out, fr_sbuff_t *in,
 
                        fr_strerror_printf("Unsupported regex flag '%c'", *our_in.p);
                        if (err) *err = -1;
-                       return fr_sbuff_error(&our_in);
+                       FR_SBUFF_ERROR_RETURN(&our_in);
                }
                fr_sbuff_advance(&our_in, 1);
        }
index be38511cb1d45659ff847347a3ab9392e7bb567e..690280e38f7f5507b2afb890191e18a02329e87c 100644 (file)
@@ -1156,7 +1156,7 @@ fr_slen_t fr_sbuff_out_##_name(fr_sbuff_parse_error_t *err, _type *out, fr_sbuff
                    ((tolower(*a_end) >= 'a') && (tolower(*a_end) <= 'f')))) { \
                        if (err) *err = FR_SBUFF_PARSE_ERROR_TRAILING; \
                        *out = (_type)(_max); \
-                       return fr_sbuff_error(&our_in); \
+                       FR_SBUFF_ERROR_RETURN(&our_in); \
                } \
                *out = (_type)(num); \
        } else { \
@@ -1216,7 +1216,7 @@ fr_slen_t fr_sbuff_out_##_name(fr_sbuff_parse_error_t *err, _type *out, fr_sbuff
                    ((tolower(*a_end) >= 'a') && (tolower(*a_end) <= 'f')))) { \
                        if (err) *err = FR_SBUFF_PARSE_ERROR_TRAILING; \
                        *out = (_type)(_max); \
-                       return fr_sbuff_error(&our_in); \
+                       FR_SBUFF_ERROR_RETURN(&our_in); \
                } \
                if (err) *err = FR_SBUFF_PARSE_OK; \
                *out = (_type)(num); \
@@ -1291,7 +1291,7 @@ fr_slen_t fr_sbuff_out_##_name(fr_sbuff_parse_error_t *err, _type *out, fr_sbuff
        } \
        if (no_trailing && (*end != '\0')) { \
                if (err) *err = FR_SBUFF_PARSE_ERROR_TRAILING; \
-               return fr_sbuff_error(&our_in); \
+               FR_SBUFF_ERROR_RETURN(&our_in); \
        } \
        *out = res; \
        return fr_sbuff_advance(in, end - buff); \
index f8fd3ee2f5f9fe7fd64731cc78feff43d02f3cb7..647c8f99310469275e01f0587fdaefdcb20d9c99 100644 (file)
@@ -65,7 +65,7 @@ fr_slen_t fr_size_from_str(size_t *out, fr_sbuff_t *in)
 
        *out = 0;
 
-       if (fr_sbuff_out(NULL, &size, &our_in) < 0) return fr_sbuff_error(&our_in);
+       if (fr_sbuff_out(NULL, &size, &our_in) < 0) FR_SBUFF_ERROR_RETURN(&our_in);
        if (!fr_sbuff_extend(&our_in)) goto done;
 
        c = tolower(fr_sbuff_char(&our_in, '\0'));
@@ -79,7 +79,7 @@ fr_slen_t fr_size_from_str(size_t *out, fr_sbuff_t *in)
                if (size & 0x01) {
                        fr_strerror_const("Sizes specified in nibbles must be an even number");
                        fr_sbuff_set_to_start(&our_in);
-                       return fr_sbuff_error(&our_in);
+                       FR_SBUFF_ERROR_RETURN(&our_in);
                }
                size /= 2;
                break;
@@ -112,14 +112,14 @@ fr_slen_t fr_size_from_str(size_t *out, fr_sbuff_t *in)
 
                if (((size_t)c >= units_len) || units[(uint8_t)c] == 0) {
                        fr_strerror_printf("Unknown unit '%c'", c);
-                       return fr_sbuff_error(&our_in);
+                       FR_SBUFF_ERROR_RETURN(&our_in);
                }
 
                if (!fr_multiply(&size, size, units[(uint8_t)c])) {
                overflow:
                        fr_strerror_printf("Value must be less than %zu", (size_t)SIZE_MAX);
                        fr_sbuff_set_to_start(&our_in);
-                       return fr_sbuff_error(&our_in);
+                       FR_SBUFF_ERROR_RETURN(&our_in);
                }
        }
        }
index ead6f9c3f9d947cfb9c58d82449d25d7ffe95f2d..9dcf3ba49dfee65c987aa8e937c1be9ffc721ee0 100644 (file)
@@ -274,7 +274,7 @@ fr_slen_t fr_time_delta_from_substr(fr_time_delta_t *out, fr_sbuff_t *in, fr_tim
        num_error:
                fr_strerror_printf("Failed parsing time_delta: %s",
                                   fr_table_str_by_value(sbuff_parse_error_table, sberr, "<INVALID>"));
-               return fr_sbuff_error(&our_in);
+               FR_SBUFF_ERROR_RETURN(&our_in);
        }
        fr_sbuff_out_by_longest_prefix(&match_len, &res, fr_time_precision_table, &our_in, FR_TIME_RES_INVALID);
 
@@ -328,7 +328,7 @@ fr_slen_t fr_time_delta_from_substr(fr_time_delta_t *out, fr_sbuff_t *in, fr_tim
                if (f_len > 9) {
                        fr_strerror_const("Too much precision for time_delta");
                        fr_sbuff_set(&our_in, fr_sbuff_current(&m_f) + 10);
-                       return fr_sbuff_error(&our_in);
+                       FR_SBUFF_ERROR_RETURN(&our_in);
                }
 
                /*
@@ -351,11 +351,11 @@ fr_slen_t fr_time_delta_from_substr(fr_time_delta_t *out, fr_sbuff_t *in, fr_tim
                        /* Got a qualifier but there's stuff after */
                        if (res != FR_TIME_RES_INVALID) {
                                fr_strerror_const("Trailing data after time_delta");
-                               return fr_sbuff_error(&our_in);
+                               FR_SBUFF_ERROR_RETURN(&our_in);
                        }
 
                        fr_strerror_const("Invalid precision qualifier for time_delta");
-                       return fr_sbuff_error(&our_in);
+                       FR_SBUFF_ERROR_RETURN(&our_in);
                }
 
                /* Scale defaults to hint */
@@ -376,7 +376,7 @@ fr_slen_t fr_time_delta_from_substr(fr_time_delta_t *out, fr_sbuff_t *in, fr_tim
                overflow:
                        fr_strerror_printf("time_delta would %s", negative ? "underflow" : "overflow");
                        fr_sbuff_set_to_start(&our_in);
-                       return fr_sbuff_error(&our_in);
+                       FR_SBUFF_ERROR_RETURN(&our_in);
                }
 
                {
@@ -421,7 +421,7 @@ fr_slen_t fr_time_delta_from_substr(fr_time_delta_t *out, fr_sbuff_t *in, fr_tim
                        if (minutes > UINT16_MAX) {
                                fr_strerror_printf("minutes component of time_delta is too large");
                                fr_sbuff_set_to_start(&our_in);
-                               return fr_sbuff_error(&our_in);
+                               FR_SBUFF_ERROR_RETURN(&our_in);
                        }
                /*
                 *      hours:minutes:seconds
@@ -435,12 +435,12 @@ fr_slen_t fr_time_delta_from_substr(fr_time_delta_t *out, fr_sbuff_t *in, fr_tim
                        if (hours > UINT16_MAX) {
                                fr_strerror_printf("hours component of time_delta is too large");
                                fr_sbuff_set_to_start(&our_in);
-                               return fr_sbuff_error(&our_in);
+                               FR_SBUFF_ERROR_RETURN(&our_in);
                        }
 
                        if (minutes > UINT16_MAX) {
                                fr_strerror_printf("minutes component of time_delta is too large");
-                               return fr_sbuff_error(&m1);
+                               FR_SBUFF_ERROR_RETURN(&m1);
                        }
                }
 
index 6834728fba17f64124fc57c41954514d3a142c3a..c4e1a175e1e78e7b8e4e735d02ae937ba36c1a67 100644 (file)
@@ -4703,7 +4703,7 @@ parse:
 
                if ((hex_len & 0x01) != 0) {
                        fr_strerror_printf("Length of hex string is not even, got %zu bytes", hex_len);
-                       return fr_sbuff_error(&our_in);
+                       FR_SBUFF_ERROR_RETURN(&our_in);
                }
 
                /*
@@ -4718,7 +4718,7 @@ parse:
 
                if (unlikely(fr_base16_decode(NULL, &FR_DBUFF_TMP(bin_buff, hex_len), &our_in, false) < 0)) {
                        talloc_free(bin_buff);
-                       return fr_sbuff_error(&our_in);
+                       FR_SBUFF_ERROR_RETURN(&our_in);
                }
 
                return fr_sbuff_set(in, &our_in);
@@ -4890,13 +4890,13 @@ parse:
                if (err != FR_SBUFF_PARSE_OK) {
                ether_error:
                        fr_sbuff_parse_error_to_strerror(err);
-                       return fr_sbuff_error(&our_in);
+                       FR_SBUFF_ERROR_RETURN(&our_in);
                }
 
                if (!fr_sbuff_next_if_char(&our_in, ':')) {
                ether_sep_error:
                        fr_strerror_const("Missing separator, expected ':'");
-                       return fr_sbuff_error(&our_in);
+                       FR_SBUFF_ERROR_RETURN(&our_in);
                }
 
                fr_base16_decode(&err, &dbuff, &our_in, true);