Skip to content

Commit 3678fd4

Browse files
committed
quiet static analyis
1 parent 66b81eb commit 3678fd4

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/lib/unlang/xlat_expr.c

+11-9
Original file line numberDiff line numberDiff line change
@@ -2066,6 +2066,7 @@ static fr_slen_t tokenize_unary(xlat_exp_head_t *head, xlat_exp_t **out, fr_sbuf
20662066
static xlat_exp_t *expr_cast_alloc(TALLOC_CTX *ctx, fr_type_t type, xlat_exp_t *child)
20672067
{
20682068
xlat_exp_t *cast, *node;
2069+
char const *str;
20692070

20702071
/*
20712072
* Create a "cast" node. The first argument is a UINT8 value-box of the cast type. The RHS is
@@ -2083,11 +2084,11 @@ static xlat_exp_t *expr_cast_alloc(TALLOC_CTX *ctx, fr_type_t type, xlat_exp_t *
20832084
* to print the name of the type, and not the
20842085
* number.
20852086
*/
2087+
str = fr_type_to_str(type);
2088+
fr_assert(str != NULL);
2089+
20862090
MEM(node = xlat_exp_alloc(cast, XLAT_BOX, NULL, 0));
2087-
{
2088-
char const *type_name = fr_table_str_by_value(fr_type_table, type, "<INVALID>");
2089-
xlat_exp_set_name(node, type_name, strlen(type_name));
2090-
}
2091+
xlat_exp_set_name(node, str, strlen(str));
20912092

20922093
fr_value_box_init(&node->data, FR_TYPE_UINT8, attr_cast_base, false);
20932094
node->data.vb_uint8 = type;
@@ -2247,7 +2248,7 @@ static ssize_t tokenize_rcode(xlat_exp_head_t *head, xlat_exp_t **out, fr_sbuff_
22472248
if (!fr_sbuff_is_terminal(&our_in, terminals)) {
22482249
if (!fr_dict_attr_allowed_chars[fr_sbuff_char(&our_in, '\0')]) {
22492250
fr_strerror_const("Unexpected text after return code");
2250-
return -slen;
2251+
FR_SBUFF_ERROR_RETURN(&our_in);
22512252
}
22522253
return 0;
22532254
}
@@ -2394,11 +2395,12 @@ static fr_slen_t tokenize_field(xlat_exp_head_t *head, xlat_exp_t **out, fr_sbuf
23942395
* Peek for rcodes.
23952396
*/
23962397
slen = tokenize_rcode(head, &node, &our_in, p_rules->terminals);
2397-
if (slen < 0) {
2398-
fr_sbuff_advance(&our_in, -slen);
2399-
FR_SBUFF_ERROR_RETURN(&our_in);
2398+
if (slen < 0) FR_SBUFF_ERROR_RETURN(&our_in);
2399+
2400+
if (slen > 0) {
2401+
fr_assert(node != NULL);
2402+
goto done;
24002403
}
2401-
if (slen > 0) goto done;
24022404
FALL_THROUGH;
24032405

24042406
default:

0 commit comments

Comments
 (0)