From: Alan Jenkins Date: Thu, 31 Aug 2017 08:54:12 +0000 (+0100) Subject: systemctl: clarify code - some actions never appear in arg_action (#6638) X-Git-Tag: v235~196 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=081dc6382276072a23bba23fe03ec7d9a27102e6;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 36675dc4997..d0c7ed79a33 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -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");