]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Remove small amounts of duplicate code
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 17 Jun 2021 17:55:16 +0000 (12:55 -0500)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 17 Jun 2021 19:25:19 +0000 (14:25 -0500)
src/lib/unlang/function.c
src/lib/unlang/map.c
src/lib/unlang/module.c
src/lib/unlang/parallel.c
src/lib/unlang/tmpl.c
src/lib/unlang/xlat.c

index c1986c3839b2e914c552ffde9b89f2f78e4ca893..d4558c3c6d5a477d99644beedd1a4918536dfc9e 100644 (file)
@@ -134,11 +134,7 @@ static unlang_action_t unlang_function_call(rlm_rcode_t *p_result, request_t *re
         *      eventually start heading back up the stack.
         */
        default:
-               if (state->repeat) {
-                       frame->process = unlang_function_call_repeat;
-                       repeatable_set(frame);
-               }
-
+               if (state->repeat) frame_repeat(frame, unlang_function_call_repeat);
        }
        request->module = caller;
 
index 9850dddd5eb5cbc4f8e0ef55e7b4b397d754b0dc..2bdadb5f0c50bb6cb34c24897359e1e9f0915fb2 100644 (file)
@@ -276,12 +276,11 @@ static unlang_action_t unlang_update_state_init(rlm_rcode_t *p_result, request_t
        fr_value_box_list_init(&update_state->lhs_result);
        fr_value_box_list_init(&update_state->rhs_result);
        fr_dlist_init(&update_state->vlm_head, vp_list_mod_t, entry);
-       repeatable_set(frame);
 
        /*
         *      Call list_mod_create
         */
-       frame->process = list_mod_create;
+       frame_repeat(frame, list_mod_create);
        return list_mod_create(p_result, request, frame);
 }
 
index 3d9a54df1b8d38853f413e41babd20523f52ca63..eedffae1c2724c3fec63023aa5de13619548350e 100644 (file)
@@ -573,8 +573,7 @@ unlang_action_t unlang_module_yield(request_t *request,
         *      so that the resume function is always
         *      called going back up the stack.
         */
-       frame->process = unlang_module_resume;
-       repeatable_set(frame);
+       frame_repeat(frame, unlang_module_resume);
 
        return UNLANG_ACTION_YIELD;
 }
@@ -740,8 +739,11 @@ static unlang_action_t unlang_module_resume(rlm_rcode_t *p_result, request_t *re
                 *      and when the I/O operation completes
                 *      it shouldn't be called again.
                 */
-               if (!state->resume) frame->process = unlang_module_resume_done;
-               repeatable_set(frame);
+               if (!state->resume) {
+                       frame_repeat(frame, unlang_module_resume_done);
+               } else {
+                       repeatable_set(frame);
+               }
                return UNLANG_ACTION_YIELD;
 
        /*
@@ -760,10 +762,11 @@ static unlang_action_t unlang_module_resume(rlm_rcode_t *p_result, request_t *re
                 *      after the child returns.
                 */
                if (!state->resume) {
-                       frame->process = unlang_module_resume_done;
+                       frame_repeat(frame, unlang_module_resume_done);
                        state->set_rcode = false;       /* Preserve the child rcode */
+               } else {
+                       repeatable_set(frame);
                }
-               repeatable_set(frame);
                return UNLANG_ACTION_PUSHED_CHILD;
 
        case UNLANG_ACTION_CALCULATE_RESULT:
@@ -880,11 +883,10 @@ static unlang_action_t unlang_module(rlm_rcode_t *p_result, request_t *request,
                 *      it shouldn't be called again.
                 */
                if (!state->resume) {
-                       frame->process = unlang_module_resume_done;
+                       frame_repeat(frame, unlang_module_resume_done);
                } else {
-                       frame->process = unlang_module_resume;
+                       frame_repeat(frame, unlang_module_resume);
                }
-               repeatable_set(frame);
                return UNLANG_ACTION_YIELD;
 
        /*
@@ -903,10 +905,11 @@ static unlang_action_t unlang_module(rlm_rcode_t *p_result, request_t *request,
                 *      after the child returns.
                 */
                if (!state->resume) {
-                       frame->process = unlang_module_done;
+                       frame_repeat(frame, unlang_module_done);
                        state->set_rcode = false;       /* Preserve the child rcode */
+               } else {
+                       repeatable_set(frame);
                }
-               repeatable_set(frame);
                return UNLANG_ACTION_PUSHED_CHILD;
 
        case UNLANG_ACTION_CALCULATE_RESULT:
index 8b04ec41664d4dd88ec6a6627bdeec2fdb823681..e733ae68ce5302a9591e896702520929c565abc3 100644 (file)
@@ -404,8 +404,7 @@ static unlang_action_t unlang_parallel_process(rlm_rcode_t *p_result, request_t
         *      a function to process the results
         *      of the children.
         */
-       frame->process = unlang_parallel_resume;
-       repeatable_set(frame);
+       frame_repeat(frame, unlang_parallel_resume);
 
        /*
         *      Yield to the children
index d61905a3e1c012d969d536e97562e8b2bb5b648b..5536b2ea822ce8d5cc2f15842ed230b80d664076 100644 (file)
@@ -285,9 +285,7 @@ static unlang_action_t unlang_tmpl_exec_wait_resume(rlm_rcode_t *p_result, reque
        }
 
        fr_dlist_talloc_free(&state->box); /* this is the xlat expansion, and not the output string we want */
-
-       frame->process = unlang_tmpl_exec_wait_final;
-       repeatable_set(frame);
+       frame_repeat(frame, unlang_tmpl_exec_wait_final);
 
        return UNLANG_ACTION_YIELD;
 }
@@ -348,9 +346,7 @@ static unlang_action_t unlang_tmpl(rlm_rcode_t *p_result, request_t *request, un
                 *      Inline exec's are only called from in-line
                 *      text in the configuration files.
                 */
-               frame->process = unlang_tmpl_exec_nowait_resume;
-
-               repeatable_set(frame);
+               frame_repeat(frame, unlang_tmpl_exec_nowait_resume);
                if (unlang_xlat_push(state->ctx, &state->box, request, tmpl_xlat(ut->tmpl), false) < 0) {
                        *p_result = RLM_MODULE_FAIL;
                        return UNLANG_ACTION_STOP_PROCESSING;
@@ -362,8 +358,7 @@ static unlang_action_t unlang_tmpl(rlm_rcode_t *p_result, request_t *request, un
         *      XLAT structs are allowed.
         */
        if (ut->tmpl->type == TMPL_TYPE_XLAT) {
-               frame->process = unlang_tmpl_resume;
-               repeatable_set(frame);
+               frame_repeat(frame, unlang_tmpl_resume);
                if (unlang_xlat_push(state->ctx, &state->box, request, tmpl_xlat(ut->tmpl), false) < 0) {
                        *p_result = RLM_MODULE_FAIL;
                        return UNLANG_ACTION_STOP_PROCESSING;
@@ -392,8 +387,7 @@ static unlang_action_t unlang_tmpl(rlm_rcode_t *p_result, request_t *request, un
        /*
         *      Expand the arguments to the program we're executing.
         */
-       frame->process = unlang_tmpl_exec_wait_resume;
-       repeatable_set(frame);
+       frame_repeat(frame, unlang_tmpl_exec_wait_resume);
        if (unlang_xlat_push(state->ctx, &state->box, request, xlat, false) < 0) {
                *p_result = RLM_MODULE_FAIL;
                return UNLANG_ACTION_STOP_PROCESSING;
index 63c8347c56d89879bb21c2bfa72dc8ab6502609c..44d9f0b663268864edaf240d8ee28e9f744c6119 100644 (file)
@@ -287,8 +287,7 @@ static unlang_action_t unlang_xlat(rlm_rcode_t *p_result, request_t *request, un
        case XLAT_ACTION_PUSH_CHILD:
                fr_assert(child);
 
-               repeatable_set(frame);
-               frame->process = unlang_xlat_repeat;
+               frame_repeat(frame, unlang_xlat_repeat);
 
                /*
                 *      Clear out the results of any previous expansions