fff-layer3-config: return error values in functions instead of terminating #260
No reviewers
Labels
No Label
RFC
RFT
WIP
blocked
bsp
bug
build/scripts/tools
duplicate
feature
fixed
layer3
mantis
more details required
needs changes
node
packages/fff
rejected
security
trivial
upstream
No Milestone
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: freifunk-franken/firmware#260
Loading…
Reference in New Issue
No description provided.
Delete Branch "fbl:testmodefix"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Many functions of configure-layer3 terminate the program after
successful execution, as they were originally only intended for
execution of configure-layer3 commands.
However, some functions are used both for command exection, but also as
helper functions. For example, revert_changes() is used as a helper
function in test_changes(). Terminating the program at the end of the
function therefore ends the exection of test_changes() prematurely. As a
result, the test mode of configure-layer3 never reloads services after
a successful configuration revert.
Replace exit commands with appropriate function return values, which can
then be evaluated by the caller where appropriate.
While at it, add a missing return to the parameter validation in
execute_subshell().
Fixes: #256
Reviewed-by: Robert Langhammer rlanghammer@web.de
@ -40,2 +40,3 @@
execute_subshell configure || return $?
exit 0
return 0
Ich glaub es reicht einfach
execute_subshell configure
alleine da stehen zu lassen. Die beidenreturn
s können weg. Die Funktion nimmt den Wert des letzten Befehls an.Das ist richtig, ich habe mich aber bewusst für diese etwas explizitere Form entschieden, weil ich das nicht offensichtlich finde. Dann müsste man es kommentieren, und dann kann ichs auch gleich ausschreiben.
Wenn noch mal jemand Code dazwischen fügt, dann bekommt der Code nicht versehentlich return values, die er eigentlich nicht haben soll.
@ -45,2 +46,4 @@
execute_subshell reload
reload_config
return 0
Brauchsts das?
Ja, sonst gibts als Rückgabewert den Exitstatus von reload_config.
@ -51,2 +54,3 @@
reload_services
exit 0
return 0
Und das?
Da reload_services sowieso immer 0 als return value hat.. Könnte man weglassen (da der Rückgabewert sowieso nirgends geprüft wird sowieso), aber ich finde es aus dem gleichen Grund wie weiter oben schöner, wenn man es explizit stehen lässt.
@ -56,2 +60,3 @@
execute_subshell revert
exit 0
return 0
Und hier?
Applied.
Pull request closed