1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-07 01:27:11 +03:00

systemctl: clarify code - some actions never appear in arg_action (#6638)

ACTION_EMERGENCY and ACTION_DEFAULT would be handled correctly by
start_with_fallback().  However there is no fallback available for
them, and they would never be set in `arg_action` in the first
place.  Remove the unused cases from the switch statement.

@poettering suggested this makes a good place to clarify the point,
explicitly listing all the `arg_action` values which would never be
set.
This commit is contained in:
Alan Jenkins 2017-08-31 09:54:12 +01:00 committed by Lennart Poettering
parent 58c6e4a2c0
commit 081dc63822

View File

@ -8562,6 +8562,10 @@ int main(int argc, char*argv[]) {
r = systemctl_main(argc, argv);
break;
/* Legacy command aliases set arg_action. They provide some fallbacks,
* e.g. to tell sysvinit to reboot after you have installed systemd
* binaries. */
case ACTION_HALT:
case ACTION_POWEROFF:
case ACTION_REBOOT:
@ -8574,8 +8578,6 @@ int main(int argc, char*argv[]) {
case ACTION_RUNLEVEL4:
case ACTION_RUNLEVEL5:
case ACTION_RESCUE:
case ACTION_EMERGENCY:
case ACTION_DEFAULT:
r = start_with_fallback();
break;
@ -8592,6 +8594,15 @@ int main(int argc, char*argv[]) {
r = runlevel_main();
break;
case ACTION_EXIT:
case ACTION_SUSPEND:
case ACTION_HIBERNATE:
case ACTION_HYBRID_SLEEP:
case ACTION_EMERGENCY:
case ACTION_DEFAULT:
/* systemctl verbs with no equivalent in the legacy commands.
* These cannot appear in arg_action. Fall through. */
case _ACTION_INVALID:
default:
assert_not_reached("Unknown action");