From 0939d5c36039c89d02f7db45239bac08b7e44903 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Fri, 20 Jun 2025 04:18:00 +0900 Subject: [PATCH] reboot-util: merge with raw-reboot.h The header raw-reboot.h is only used with reboot-util. Let's merge them. --- src/basic/raw-reboot.h | 15 --------------- src/core/emergency-action.c | 2 -- src/shared/reboot-util.c | 8 +++++--- src/shared/reboot-util.h | 8 ++++++++ src/shutdown/shutdown.c | 2 -- src/systemctl/systemctl-util.c | 1 - 6 files changed, 13 insertions(+), 23 deletions(-) delete mode 100644 src/basic/raw-reboot.h diff --git a/src/basic/raw-reboot.h b/src/basic/raw-reboot.h deleted file mode 100644 index d72ae1e955c..00000000000 --- a/src/basic/raw-reboot.h +++ /dev/null @@ -1,15 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -#pragma once - -#include -#include -#include -#include - -/* glibc defines the reboot() API call, which is a wrapper around the system call of the same name, but without the - * extra "arg" parameter. Since we need that parameter for some calls, let's add a "raw" wrapper that is defined the - * same way, except it takes the additional argument. */ - -static inline int raw_reboot(int cmd, const void *arg) { - return (int) syscall(SYS_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, cmd, arg); -} diff --git a/src/core/emergency-action.c b/src/core/emergency-action.c index 989bb1753e5..439228c8995 100644 --- a/src/core/emergency-action.c +++ b/src/core/emergency-action.c @@ -1,12 +1,10 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include #include #include "ansi-color.h" #include "emergency-action.h" #include "manager.h" -#include "raw-reboot.h" #include "reboot-util.h" #include "special.h" #include "string-table.h" diff --git a/src/shared/reboot-util.c b/src/shared/reboot-util.c index f82c0654dc5..948e15631d8 100644 --- a/src/shared/reboot-util.c +++ b/src/shared/reboot-util.c @@ -1,10 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include #include #include #include -#include +#include #include #if HAVE_XENCTRL @@ -20,13 +19,16 @@ #include "fileio.h" #include "log.h" #include "proc-cmdline.h" -#include "raw-reboot.h" #include "reboot-util.h" #include "string-util.h" #include "umask-util.h" #include "utf8.h" #include "virt.h" +int raw_reboot(int cmd, const void *arg) { + return syscall(SYS_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, cmd, arg); +} + bool reboot_parameter_is_valid(const char *parameter) { assert(parameter); diff --git a/src/shared/reboot-util.h b/src/shared/reboot-util.h index 55419dfb149..276361aea8e 100644 --- a/src/shared/reboot-util.h +++ b/src/shared/reboot-util.h @@ -1,8 +1,16 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once +#include /* IWYU pragma: export */ +#include /* IWYU pragma: export */ + #include "forward.h" +/* glibc defines the reboot() API call, which is a wrapper around the system call of the same name, but + * without the extra "arg" parameter. Since we need that parameter for some calls, let's add a "raw" wrapper + * that is defined the same way, except it takes the additional argument. */ +int raw_reboot(int cmd, const void *arg); + bool reboot_parameter_is_valid(const char *parameter); int update_reboot_parameter_and_warn(const char *parameter, bool keep); diff --git a/src/shutdown/shutdown.c b/src/shutdown/shutdown.c index bb767161bde..3317068e478 100644 --- a/src/shutdown/shutdown.c +++ b/src/shutdown/shutdown.c @@ -4,11 +4,9 @@ ***/ #include -#include #include #include #include -#include #include #include diff --git a/src/systemctl/systemctl-util.c b/src/systemctl/systemctl-util.c index 019b763a869..faefc556195 100644 --- a/src/systemctl/systemctl-util.c +++ b/src/systemctl/systemctl-util.c @@ -1,7 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #include -#include #include #include "sd-bus.h" -- 2.47.3