]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Simplify call_env expanding
authorNick Porter <nick@portercomputing.co.uk>
Tue, 15 Jul 2025 12:39:18 +0000 (13:39 +0100)
committerNick Porter <nick@portercomputing.co.uk>
Tue, 15 Jul 2025 13:15:46 +0000 (14:15 +0100)
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

index 31de8f44bdda6081c33462806943e7a6e3bf38ff..80f50e5b56e9fad08d7828869167f6848e51d8a1 100644 (file)
@@ -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;