1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-22 17:35:35 +03:00

battery-check: parse options before checking for kernel command line

Otherwise --help/--version/etc which exit immediately will do pointless work
This commit is contained in:
Luca Boccassi 2024-11-08 12:23:37 +00:00
parent 1ca315be00
commit 60d23b7f4a

View File

@ -123,14 +123,14 @@ static int run(int argc, char *argv[]) {
log_setup(); log_setup();
r = proc_cmdline_get_bool("systemd.battery_check", PROC_CMDLINE_STRIP_RD_PREFIX|PROC_CMDLINE_TRUE_WHEN_MISSING, &arg_doit);
if (r < 0)
log_warning_errno(r, "Failed to parse systemd.battery_check= kernel command line option, ignoring: %m");
r = parse_argv(argc, argv); r = parse_argv(argc, argv);
if (r <= 0) if (r <= 0)
return r; return r;
r = proc_cmdline_get_bool("systemd.battery_check", PROC_CMDLINE_STRIP_RD_PREFIX|PROC_CMDLINE_TRUE_WHEN_MISSING, &arg_doit);
if (r < 0)
log_warning_errno(r, "Failed to parse systemd.battery_check= kernel command line option, ignoring: %m");
if (!arg_doit) { if (!arg_doit) {
log_info("Checking battery status and AC power existence is disabled by the kernel command line, skipping execution."); log_info("Checking battery status and AC power existence is disabled by the kernel command line, skipping execution.");
return 0; return 0;