From 9b6281a6e7fe8a683d4ff788bd3c029a5911cdf8 Mon Sep 17 00:00:00 2001 From: Daniel-Constantin Mierla Date: Fri, 24 Jan 2025 18:15:04 +0100 Subject: [PATCH] docs/cookbooks: core - proper details about no-return in route block --- docs/cookbooks/5.2.x/core.md | 8 +++++--- docs/cookbooks/5.3.x/core.md | 8 +++++--- docs/cookbooks/5.4.x/core.md | 8 +++++--- docs/cookbooks/5.5.x/core.md | 12 +++++++++--- docs/cookbooks/5.6.x/core.md | 12 +++++++++--- docs/cookbooks/5.7.x/core.md | 14 ++++++++++---- docs/cookbooks/5.8.x/core.md | 12 +++++++++--- docs/cookbooks/devel/core.md | 24 +++++++++++++++--------- 8 files changed, 67 insertions(+), 31 deletions(-) diff --git a/docs/cookbooks/5.2.x/core.md b/docs/cookbooks/5.2.x/core.md index ae32ae2f..2340a590 100644 --- a/docs/cookbooks/5.2.x/core.md +++ b/docs/cookbooks/5.2.x/core.md @@ -3221,9 +3221,11 @@ In bool expressions: - Negative is FALSE - Positive is TRUE -If no value is specified, or a route reaches its end without executing a -return statement, it returns 1. If return is used in the top level route -is equivalent with exit \[val\]. +If no value is specified, it returns 1. If return is used in the top level route +is equivalent with exit `[val]`. If no `return` is at the end of the routing block, +the return code is the value of the last executed action, therefore it is highly +recommended to return an explicit value (e.g., `return(1)`) to avoid unexpected +config execution. Example usage: diff --git a/docs/cookbooks/5.3.x/core.md b/docs/cookbooks/5.3.x/core.md index 05cbfb62..7a954a1d 100644 --- a/docs/cookbooks/5.3.x/core.md +++ b/docs/cookbooks/5.3.x/core.md @@ -3346,9 +3346,11 @@ In bool expressions: - Negative is FALSE - Positive is TRUE -If no value is specified, or a route reaches its end without executing a -return statement, it returns 1. If return is used in the top level route -is equivalent with exit \[val\]. +If no value is specified, it returns 1. If return is used in the top level route +is equivalent with exit `[val]`. If no `return` is at the end of the routing block, +the return code is the value of the last executed action, therefore it is highly +recommended to return an explicit value (e.g., `return(1)`) to avoid unexpected +config execution. Example usage: diff --git a/docs/cookbooks/5.4.x/core.md b/docs/cookbooks/5.4.x/core.md index ebecfd15..521486ce 100644 --- a/docs/cookbooks/5.4.x/core.md +++ b/docs/cookbooks/5.4.x/core.md @@ -3417,9 +3417,11 @@ In bool expressions: - Negative is FALSE - Positive is TRUE -If no value is specified, or a route reaches its end without executing a -return statement, it returns 1. If return is used in the top level route -is equivalent with exit \[val\]. +If no value is specified, it returns 1. If return is used in the top level route +is equivalent with exit `[val]`. If no `return` is at the end of the routing block, +the return code is the value of the last executed action, therefore it is highly +recommended to return an explicit value (e.g., `return(1)`) to avoid unexpected +config execution. Example usage: diff --git a/docs/cookbooks/5.5.x/core.md b/docs/cookbooks/5.5.x/core.md index 1233a077..007393d2 100644 --- a/docs/cookbooks/5.5.x/core.md +++ b/docs/cookbooks/5.5.x/core.md @@ -3620,9 +3620,11 @@ In bool expressions: - Negative is FALSE - Positive is TRUE -If no value is specified, or a route reaches its end without executing a -return statement, it returns 1. If return is used in the top level route -is equivalent with exit \[val\]. +If no value is specified, it returns 1. If return is used in the top level route +is equivalent with exit `[val]`. If no `return` is at the end of the routing block, +the return code is the value of the last executed action, therefore it is highly +recommended to return an explicit value (e.g., `return(1)`) to avoid unexpected +config execution. Example usage: @@ -4111,6 +4113,10 @@ number of recursive levels, avoiding ending up in infinite loops -- see The sub-route blocks allow to make the configuration file modular, simplifying the logic and helping to avoid duplication of actions. +If no `return` is at the end of the routing block, the return code is the value +of the last executed action, therefore it is highly recommended to return an +explicit value (e.g., `return(1)`) to avoid unexpected config execution. + ### branch_route Request's branch routing block. It contains a set of actions to be taken diff --git a/docs/cookbooks/5.6.x/core.md b/docs/cookbooks/5.6.x/core.md index 38df568e..c2135a1f 100644 --- a/docs/cookbooks/5.6.x/core.md +++ b/docs/cookbooks/5.6.x/core.md @@ -3748,9 +3748,11 @@ In bool expressions: - Negative is FALSE - Positive is TRUE -If no value is specified, or a route reaches its end without executing a -return statement, it returns 1. If return is used in the top level route -is equivalent with exit `[val]`. +If no value is specified, it returns 1. If return is used in the top level route +is equivalent with exit `[val]`. If no `return` is at the end of the routing block, +the return code is the value of the last executed action, therefore it is highly +recommended to return an explicit value (e.g., `return(1)`) to avoid unexpected +config execution. Example usage: @@ -4238,6 +4240,10 @@ number of recursive levels, avoiding ending up in infinite loops -- see The sub-route blocks allow to make the configuration file modular, simplifying the logic and helping to avoid duplication of actions. +If no `return` is at the end of the routing block, the return code is the value +of the last executed action, therefore it is highly recommended to return an +explicit value (e.g., `return(1)`) to avoid unexpected config execution. + ### branch_route Request's branch routing block. It contains a set of actions to be taken diff --git a/docs/cookbooks/5.7.x/core.md b/docs/cookbooks/5.7.x/core.md index fc46cc14..3a2b0a5a 100644 --- a/docs/cookbooks/5.7.x/core.md +++ b/docs/cookbooks/5.7.x/core.md @@ -4400,9 +4400,11 @@ In logical evaluation expressions: - Negative is FALSE - Positive is TRUE -If no value is specified, or a route reaches its end without executing a -return statement, it returns 1. If return is used in the top level route -is equivalent with exit `[val]`. +If no value is specified, it returns 1. If return is used in the top level route +is equivalent with exit `[val]`. If no `return` is at the end of the routing block, +the return code is the value of the last executed action, therefore it is highly +recommended to return an explicit value (e.g., `return(1)`) to avoid unexpected +config execution. Example usage: @@ -4868,7 +4870,7 @@ Example of usage: } ``` -### route +### route block This block is used to define 'sub-routes' - group of actions that can be executed from another routing block. Originally targeted as being @@ -4920,6 +4922,10 @@ number of recursive levels, avoiding ending up in infinite loops -- see The sub-route blocks allow to make the configuration file modular, simplifying the logic and helping to avoid duplication of actions. +If no `return` is at the end of the routing block, the return code is the value +of the last executed action, therefore it is highly recommended to return an +explicit value (e.g., `return(1)`) to avoid unexpected config execution. + ### branch_route Request's branch routing block. It contains a set of actions to be taken diff --git a/docs/cookbooks/5.8.x/core.md b/docs/cookbooks/5.8.x/core.md index 6f4ebf35..67d627b9 100644 --- a/docs/cookbooks/5.8.x/core.md +++ b/docs/cookbooks/5.8.x/core.md @@ -4511,9 +4511,11 @@ In logical evaluation expressions: - Negative is FALSE - Positive is TRUE -If no value is specified, or a route reaches its end without executing a -return statement, it returns 1. If return is used in the top level route -is equivalent with exit `[val]`. +If no value is specified, it returns 1. If return is used in the top level route +is equivalent with exit `[val]`. If no `return` is at the end of the routing block, +the return code is the value of the last executed action, therefore it is highly +recommended to return an explicit value (e.g., `return(1)`) to avoid unexpected +config execution. Example usage: @@ -5031,6 +5033,10 @@ number of recursive levels, avoiding ending up in infinite loops -- see The sub-route blocks allow to make the configuration file modular, simplifying the logic and helping to avoid duplication of actions. +If no `return` is at the end of the routing block, the return code is the value +of the last executed action, therefore it is highly recommended to return an +explicit value (e.g., `return(1)`) to avoid unexpected config execution. + ### branch_route Request's branch routing block. It contains a set of actions to be taken diff --git a/docs/cookbooks/devel/core.md b/docs/cookbooks/devel/core.md index 85a84a55..55b50d9e 100644 --- a/docs/cookbooks/devel/core.md +++ b/docs/cookbooks/devel/core.md @@ -4648,28 +4648,30 @@ In logical evaluation expressions: - Negative is FALSE - Positive is TRUE -If no value is specified, or a route reaches its end without executing a -return statement, it returns 1. If return is used in the top level route -is equivalent with exit `[val]`. +If no value is specified, it returns 1. If return is used in the top level route +is equivalent with exit `[val]`. If no `return` is at the end of the routing block, +the return code is the value of the last executed action, therefore it is highly +recommended to return an explicit value (e.g., `return(1)`) to avoid unexpected +config execution. Example usage: ``` c request_route { if (route(RET)) { - xlog("L_NOTICE","method $rm is INVITE\n"); + xlog("L_NOTICE","method $rm is INVITE\n"); } else { - xlog("L_NOTICE","method $rm is REGISTER\n"); + xlog("L_NOTICE","method $rm is REGISTER\n"); }; } route[RET] { if (is_method("INVITE")) { - return(1); + return(1); } else if (is_method("REGISTER")) { - return(-1); + return(-1); } else { - return(0); + return(0); }; } ``` @@ -5125,7 +5127,7 @@ Example of usage: } ``` -### route +### route block This block is used to define 'sub-routes' - group of actions that can be executed from another routing block. Originally targeted as being @@ -5177,6 +5179,10 @@ number of recursive levels, avoiding ending up in infinite loops -- see The sub-route blocks allow to make the configuration file modular, simplifying the logic and helping to avoid duplication of actions. +If no `return` is at the end of the routing block, the return code is the value +of the last executed action, therefore it is highly recommended to return an +explicit value (e.g., `return(1)`) to avoid unexpected config execution. + ### branch_route Request's branch routing block. It contains a set of actions to be taken