connection: Simplify '{un,}set_default_gateway' Flow
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest4 patches 0 repliesNew
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/4 | connection: Simplify 'set_default_gateway' flow.src/ | +38 | 0 replies | |
| 2/4 | connection: Simplify 'unset_default_gateway' flow.src/ | +31 | 0 replies | |
| 3/4 | connection: Add additional DBG statements to '{un,}set_default_gateway'.src/ | +26 | 0 replies | |
| 4/4 | connection: Document '{un,}set_default_gateway'.src/ | +56 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH 0/4] connection: Simplify '{un,}set_default_gateway' Flow
Ostensibly over time, the logic of both 'set_default_gateway' and 'unset_default_gateway' has become a bit complicated with early returns, gotos (in the case of 'set_default_gateway'), repeated state checks, and duplicated function calls (in the case of 'set_default_gateway').
However, amidst all of that, there is a simpler flow to surface. At its core, the functions are two identical outer conditional blocks:
one for IPv4 and one for IPv6 and three inner conditional blocks within those: one for a VPN, one for a gateway with an any/unspecified address, and one for everything else. In the case of 'set_default_gateway', on success, a call to '__connman_service_indicate_default' is made; on failure, it is not.
This simplifies the flows of both functions accordingly, curtailing the number of early returns, eliminating all of the gotos, and reducing the repeated state checks and function calls to one through the use of those simplified conditional blocks.
Additionally, this adds 'DBG' statements and documentation to both functions.
Grant Erickson (4):
connection: Simplify 'set_default_gateway' flow.
connection: Simplify 'unset_default_gateway' flow.
connection: Add additional DBG statements to '{un,}set_default_gateway'.
connection: Document '{un,}set_default_gateway'.
src/connection.c | 223 ++++++++++++++++++++++++++++++----------------- 1 file changed, 145 insertions(+), 78 deletions(-)
Signature · 1 line
2.42.0