From d1d7772a1e19af934d39ada4e3772a59cc6e6f49 Mon Sep 17 00:00:00 2001 From: Nick Porter Date: Tue, 15 Jul 2025 13:39:18 +0100 Subject: [PATCH] Simplify call_env expanding Pointers to source tmpls are always set in call_env_expand_start, so don't need handling in call_env_expand_repeat. Parse only envs are never pushed as tmpls, so will never be processed in call_env_expand_repeat. --- src/lib/unlang/call_env.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/lib/unlang/call_env.c b/src/lib/unlang/call_env.c index 31de8f44bd..80f50e5b56 100644 --- a/src/lib/unlang/call_env.c +++ b/src/lib/unlang/call_env.c @@ -64,15 +64,11 @@ FR_DLIST_FUNCS(call_env_parsed, call_env_parsed_t, entry) /** Parse the result of call_env tmpl expansion */ static inline CC_HINT(always_inline) -call_env_result_t call_env_result(TALLOC_CTX *ctx, request_t *request, void *out, - void **tmpl_out, call_env_parsed_t const *env, +call_env_result_t call_env_result(TALLOC_CTX *ctx, request_t *request, void *out, call_env_parsed_t const *env, fr_value_box_list_t *tmpl_expanded) { fr_value_box_t *vb; - if (tmpl_out) *tmpl_out = UNCONST(tmpl_t *, env->data.tmpl); - if (call_env_parse_only(env->rule->flags)) return CALL_ENV_SUCCESS; - vb = fr_value_box_list_head(tmpl_expanded); if (!vb) { if (!call_env_nullable(env->rule->flags)) { @@ -252,7 +248,7 @@ again: } /* coverity[var_deref_model] */ - result = call_env_result(*call_env_rctx->data, request, box_out, NULL, env, &call_env_rctx->tmpl_expanded); + result = call_env_result(*call_env_rctx->data, request, box_out, env, &call_env_rctx->tmpl_expanded); if (result != CALL_ENV_SUCCESS) { if (call_env_rctx->result) *call_env_rctx->result = result; return UNLANG_ACTION_FAIL; @@ -269,11 +265,11 @@ again: /** Extract expanded call environment tmpl and store in env_data * - * If there are more tmpls to expand, push the next expansion. + * If there are more call environments to evaluate, push the next one. */ static unlang_action_t call_env_expand_repeat(UNUSED unlang_result_t *p_result, request_t *request, void *uctx) { - void *out = NULL, *tmpl_out = NULL; + void *out = NULL; call_env_rctx_t *call_env_rctx = talloc_get_type_abort(uctx, call_env_rctx_t); call_env_parsed_t const *env; call_env_result_t result; @@ -289,7 +285,6 @@ static unlang_action_t call_env_expand_repeat(UNUSED unlang_result_t *p_result, env = call_env_rctx->last_expanded; if (!env) return UNLANG_ACTION_CALCULATE_RESULT; - if (call_env_parse_only(env->rule->flags)) goto parse_only; /* * Find the location of the output */ @@ -304,11 +299,8 @@ static unlang_action_t call_env_expand_repeat(UNUSED unlang_result_t *p_result, out = ((uint8_t *)array) + env->rule->pair.size * env->multi_index; } -parse_only: - if (env->rule->pair.parsed.offset >= 0) tmpl_out = ((uint8_t *)*call_env_rctx->data) + env->rule->pair.parsed.offset; - /* coverity[var_deref_model] */ - result = call_env_result(*call_env_rctx->data, request, out, tmpl_out, env, &call_env_rctx->tmpl_expanded); + result = call_env_result(*call_env_rctx->data, request, out, env, &call_env_rctx->tmpl_expanded); if (result != CALL_ENV_SUCCESS) { if (call_env_rctx->result) *call_env_rctx->result = result; return UNLANG_ACTION_FAIL; -- 2.47.2