From: Daan De Meyer Date: Thu, 22 May 2025 08:00:39 +0000 (+0200) Subject: boot: Clean up includes X-Git-Tag: v258-rc1~522 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c60a8c72d1e64a383c0b839f915d142458123092;p=thirdparty%2Fsystemd.git boot: Clean up includes Instead of introducing efi-forward.h, we use efi.h for the same purpose in the boot/ folder. --- diff --git a/src/boot/bcd.c b/src/boot/bcd.c index 9b5596b23aa..4533d479c14 100644 --- a/src/boot/bcd.c +++ b/src/boot/bcd.c @@ -2,7 +2,6 @@ #include -#include "assert-fundamental.h" #include "bcd.h" #include "efi-string.h" diff --git a/src/boot/boot.c b/src/boot/boot.c index 967b9db1dc6..bf8f5a1a34d 100644 --- a/src/boot/boot.c +++ b/src/boot/boot.c @@ -1,7 +1,5 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include - #include "bcd.h" #include "bootspec-fundamental.h" #include "console.h" @@ -9,19 +7,18 @@ #include "devicetree.h" #include "drivers.h" #include "efi-efivars.h" +#include "efi-log.h" #include "efi-string-table.h" #include "efivars-fundamental.h" #include "export-vars.h" #include "graphics.h" #include "initrd.h" #include "line-edit.h" -#include "linux.h" #include "measure.h" #include "memory-util-fundamental.h" #include "part-discovery.h" #include "pe.h" #include "proto/block-io.h" -#include "proto/device-path.h" #include "proto/load-file.h" #include "proto/simple-text-io.h" #include "random-seed.h" diff --git a/src/boot/chid.c b/src/boot/chid.c index 24739e956cc..a5a90a3b63e 100644 --- a/src/boot/chid.c +++ b/src/boot/chid.c @@ -17,8 +17,8 @@ #include "chid.h" #include "chid-fundamental.h" #include "edid.h" -#include "efi.h" -#include "sha1-fundamental.h" +#include "efi-log.h" +#include "efi-string.h" #include "smbios.h" #include "util.h" diff --git a/src/boot/chid.h b/src/boot/chid.h index ba594a291d6..fcc4464539f 100644 --- a/src/boot/chid.h +++ b/src/boot/chid.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: BSD-3-Clause */ #pragma once -#include "chid-fundamental.h" +#include "chid-fundamental.h" /* IWYU pragma: export */ #include "efi.h" /* A .hwids PE section consists of a series of 'Device' structures. A 'Device' structure binds a CHID to some diff --git a/src/boot/console.c b/src/boot/console.c index 5e11ba54249..9ed5ccef09a 100644 --- a/src/boot/console.c +++ b/src/boot/console.c @@ -1,8 +1,8 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #include "console.h" +#include "efi-log.h" #include "proto/graphics-output.h" -#include "util.h" #define SYSTEM_FONT_WIDTH 8 #define SYSTEM_FONT_HEIGHT 19 diff --git a/src/boot/cpio.c b/src/boot/cpio.c index fc5e303d7e6..8a15253deda 100644 --- a/src/boot/cpio.c +++ b/src/boot/cpio.c @@ -1,9 +1,10 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #include "cpio.h" -#include "device-path-util.h" +#include "efi-log.h" +#include "iovec-util-fundamental.h" #include "measure.h" -#include "proto/device-path.h" +#include "string-util-fundamental.h" #include "util.h" static char *write_cpio_word(char *p, uint32_t v) { diff --git a/src/boot/cpio.h b/src/boot/cpio.h index 660372c0b71..bb741278fdc 100644 --- a/src/boot/cpio.h +++ b/src/boot/cpio.h @@ -2,7 +2,6 @@ #pragma once #include "efi.h" -#include "iovec-util-fundamental.h" #include "proto/loaded-image.h" EFI_STATUS pack_cpio( diff --git a/src/boot/device-path-util.c b/src/boot/device-path-util.c index 0e991f941f5..2764373d94a 100644 --- a/src/boot/device-path-util.c +++ b/src/boot/device-path-util.c @@ -2,6 +2,7 @@ #include "device-path-util.h" #include "efi-string.h" +#include "string-util-fundamental.h" #include "util.h" EFI_STATUS make_file_device_path(EFI_HANDLE device, const char16_t *file, EFI_DEVICE_PATH **ret_dp) { @@ -178,3 +179,7 @@ size_t device_path_size(const EFI_DEVICE_PATH *dp) { return (const uint8_t*) i - (const uint8_t*) dp + sizeof(EFI_DEVICE_PATH); } + +EFI_DEVICE_PATH *device_path_dup(const EFI_DEVICE_PATH *dp) { + return xmemdup(ASSERT_PTR(dp), device_path_size(dp)); +} diff --git a/src/boot/device-path-util.h b/src/boot/device-path-util.h index c33669a866b..b02cf3146a9 100644 --- a/src/boot/device-path-util.h +++ b/src/boot/device-path-util.h @@ -1,8 +1,8 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once +#include "efi.h" #include "proto/device-path.h" -#include "util.h" EFI_STATUS make_file_device_path(EFI_HANDLE device, const char16_t *file, EFI_DEVICE_PATH **ret_dp); EFI_STATUS make_url_device_path(const char16_t *url, EFI_DEVICE_PATH **ret); @@ -30,6 +30,4 @@ static inline bool device_path_is_end(const EFI_DEVICE_PATH *dp) { size_t device_path_size(const EFI_DEVICE_PATH *dp); -static inline EFI_DEVICE_PATH *device_path_dup(const EFI_DEVICE_PATH *dp) { - return xmemdup(ASSERT_PTR(dp), device_path_size(dp)); -} +EFI_DEVICE_PATH *device_path_dup(const EFI_DEVICE_PATH *dp); diff --git a/src/boot/drivers.c b/src/boot/drivers.c index 414e27a0f40..a44957b4e44 100644 --- a/src/boot/drivers.c +++ b/src/boot/drivers.c @@ -2,6 +2,8 @@ #include "device-path-util.h" #include "drivers.h" +#include "efi-log.h" +#include "string-util-fundamental.h" #include "util.h" static EFI_STATUS load_one_driver( diff --git a/src/boot/edid.c b/src/boot/edid.c index a1a41cc2891..f740d8671f9 100644 --- a/src/boot/edid.c +++ b/src/boot/edid.c @@ -1,8 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #include "edid.h" -#include "edid-fundamental.h" -#include "efi-log.h" #include "proto/edid-discovered.h" #include "util.h" diff --git a/src/boot/edid.h b/src/boot/edid.h index 9832dadaab4..74649658d93 100644 --- a/src/boot/edid.h +++ b/src/boot/edid.h @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once +#include "edid-fundamental.h" /* IWYU pragma: export */ #include "efi.h" EFI_STATUS edid_get_discovered_panel_id(char16_t **ret_panel); diff --git a/src/boot/efi-efivars.h b/src/boot/efi-efivars.h index 61e27d6b33b..1e74d6483cf 100644 --- a/src/boot/efi-efivars.h +++ b/src/boot/efi-efivars.h @@ -2,6 +2,7 @@ #pragma once #include "efi.h" +#include "efivars-fundamental.h" /* IWYU pragma: export */ /* * Allocated random UUID, intended to be shared across tools that implement diff --git a/src/boot/efi-firmware.c b/src/boot/efi-firmware.c index 01bb2c2c715..1296c5069ac 100644 --- a/src/boot/efi-firmware.c +++ b/src/boot/efi-firmware.c @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #include "efi-firmware.h" -#include "util.h" +#include "efi-string.h" static bool efifw_validate_header( const void *blob, diff --git a/src/boot/efi-log.h b/src/boot/efi-log.h index 64664f77c3d..06954b06f0a 100644 --- a/src/boot/efi-log.h +++ b/src/boot/efi-log.h @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once +#include "efi.h" #include "efi-string.h" #include "proto/simple-text-io.h" diff --git a/src/boot/efi-string.c b/src/boot/efi-string.c index 59cb0fa9f54..8e2c73d84d6 100644 --- a/src/boot/efi-string.c +++ b/src/boot/efi-string.c @@ -1,7 +1,5 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include - #include "efi-string.h" #if SD_BOOT diff --git a/src/boot/efi-string.h b/src/boot/efi-string.h index fa1f63324aa..b1554727387 100644 --- a/src/boot/efi-string.h +++ b/src/boot/efi-string.h @@ -2,7 +2,6 @@ #pragma once #include "efi.h" -#include "macro-fundamental.h" size_t strnlen8(const char *s, size_t n); size_t strnlen16(const char16_t *s, size_t n); diff --git a/src/boot/efi.h b/src/boot/efi.h index f35d0692bf8..1832df980c3 100644 --- a/src/boot/efi.h +++ b/src/boot/efi.h @@ -1,13 +1,18 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include -#include -#include +/* IWYU pragma: always_keep */ -#include "efi-fundamental.h" -#include "macro-fundamental.h" +#include /* IWYU pragma: export */ +#include /* IWYU pragma: export */ +#include /* IWYU pragma: export */ +#include /* IWYU pragma: export */ +#include /* IWYU pragma: export */ + +#include "assert-fundamental.h" /* IWYU pragma: export */ +#include "cleanup-fundamental.h" /* IWYU pragma: export */ +#include "efi-fundamental.h" /* IWYU pragma: export */ +#include "macro-fundamental.h" /* IWYU pragma: export */ #if SD_BOOT /* uchar.h/wchar.h are not suitable for freestanding environments. */ @@ -45,6 +50,8 @@ assert_cc(alignof(char32_t) == 4); # include #endif +struct iovec; + /* We use size_t/ssize_t to represent UEFI UINTN/INTN. */ typedef size_t EFI_STATUS; typedef intptr_t ssize_t; diff --git a/src/boot/fuzz-efi-printf.c b/src/boot/fuzz-efi-printf.c index 6dee830c14c..2857b389a22 100644 --- a/src/boot/fuzz-efi-printf.c +++ b/src/boot/fuzz-efi-printf.c @@ -3,7 +3,6 @@ #include "alloc-util.h" #include "efi-string.h" #include "fuzz.h" -#include "utf8.h" typedef struct { EFI_STATUS status; diff --git a/src/boot/fuzz-efi-string.c b/src/boot/fuzz-efi-string.c index 36ecaf90ae8..2b854b3782a 100644 --- a/src/boot/fuzz-efi-string.c +++ b/src/boot/fuzz-efi-string.c @@ -3,7 +3,6 @@ #include "alloc-util.h" #include "efi-string.h" #include "fuzz.h" -#include "utf8.h" static char16_t *memdup_str16(const uint8_t *data, size_t size) { char16_t *ret = memdup(data, size); diff --git a/src/boot/graphics.c b/src/boot/graphics.c index 496fc691899..3f2a06bea2f 100644 --- a/src/boot/graphics.c +++ b/src/boot/graphics.c @@ -4,10 +4,10 @@ * Authored by Joonas Lahtinen */ +#include "efi-log.h" #include "graphics.h" #include "proto/console-control.h" #include "proto/simple-text-io.h" -#include "util.h" EFI_STATUS graphics_mode(bool on) { EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl = NULL; diff --git a/src/boot/initrd.c b/src/boot/initrd.c index 527b05f5dbd..1de4fcfa054 100644 --- a/src/boot/initrd.c +++ b/src/boot/initrd.c @@ -1,7 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #include "initrd.h" -#include "macro-fundamental.h" #include "proto/device-path.h" #include "proto/load-file.h" #include "util.h" diff --git a/src/boot/line-edit.c b/src/boot/line-edit.c index ca9dc067a5d..1e6128e1eff 100644 --- a/src/boot/line-edit.c +++ b/src/boot/line-edit.c @@ -2,6 +2,7 @@ #include "console.h" #include "line-edit.h" +#include "string-util-fundamental.h" #include "util.h" static void cursor_left(size_t *cursor, size_t *first) { diff --git a/src/boot/linux.c b/src/boot/linux.c index 54f52645d24..00bdf8c1ce4 100644 --- a/src/boot/linux.c +++ b/src/boot/linux.c @@ -8,6 +8,7 @@ * This method works for Linux 5.8 and newer on ARM/Aarch64, x86/x68_64 and RISC-V. */ +#include "efi-log.h" #include "initrd.h" #include "linux.h" #include "pe.h" diff --git a/src/boot/linux_x86.c b/src/boot/linux_x86.c index ddae4d160a1..cf9707a6cfd 100644 --- a/src/boot/linux_x86.c +++ b/src/boot/linux_x86.c @@ -10,7 +10,7 @@ * see https://docs.kernel.org/arch/x86/boot.html */ -#include "initrd.h" +#include "efi-log.h" #include "linux.h" #include "macro-fundamental.h" #include "memory-util-fundamental.h" diff --git a/src/boot/measure.c b/src/boot/measure.c index 48e9fb5fc50..590fed8ec27 100644 --- a/src/boot/measure.c +++ b/src/boot/measure.c @@ -2,9 +2,8 @@ #if ENABLE_TPM -#include "macro-fundamental.h" +#include "efi-log.h" #include "measure.h" -#include "memory-util-fundamental.h" #include "proto/cc-measurement.h" #include "proto/tcg.h" #include "tpm2-pcr.h" diff --git a/src/boot/pe.c b/src/boot/pe.c index c5cd6a57cab..9ce978a48b7 100644 --- a/src/boot/pe.c +++ b/src/boot/pe.c @@ -1,10 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include - #include "chid.h" #include "devicetree.h" #include "efi-firmware.h" +#include "efi-log.h" #include "pe.h" #include "util.h" diff --git a/src/boot/random-seed.c b/src/boot/random-seed.c index a4d7f5ba265..59ed782060a 100644 --- a/src/boot/random-seed.c +++ b/src/boot/random-seed.c @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #include "efi-efivars.h" +#include "efi-log.h" #include "memory-util-fundamental.h" #include "proto/rng.h" #include "random-seed.h" diff --git a/src/boot/secure-boot.c b/src/boot/secure-boot.c index 5781669a4c2..84c86fe4249 100644 --- a/src/boot/secure-boot.c +++ b/src/boot/secure-boot.c @@ -2,6 +2,7 @@ #include "console.h" #include "efi-efivars.h" +#include "efi-log.h" #include "efi-string-table.h" #include "proto/security-arch.h" #include "secure-boot.h" diff --git a/src/boot/smbios.c b/src/boot/smbios.c index e2674f6cd34..0bbcf30123d 100644 --- a/src/boot/smbios.c +++ b/src/boot/smbios.c @@ -1,10 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include "efi-efivars.h" #include "efi-string.h" -#include "proto/device-path.h" #include "smbios.h" -#include "string-util-fundamental.h" #include "util.h" #define SMBIOS_TABLE_GUID \ diff --git a/src/boot/stub.c b/src/boot/stub.c index a117d113321..301d7a1cc9f 100644 --- a/src/boot/stub.c +++ b/src/boot/stub.c @@ -1,11 +1,10 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include - #include "cpio.h" #include "device-path-util.h" #include "devicetree.h" #include "efi-efivars.h" +#include "efi-log.h" #include "export-vars.h" #include "graphics.h" #include "iovec-util-fundamental.h" diff --git a/src/boot/sysfail.h b/src/boot/sysfail.h index aafdf790be3..cc0d45f6177 100644 --- a/src/boot/sysfail.h +++ b/src/boot/sysfail.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include "efivars-fundamental.h" +#include "efi.h" typedef enum SysFailType { SYSFAIL_NO_FAILURE, diff --git a/src/boot/test-bcd.c b/src/boot/test-bcd.c index 3f93ca05c58..0924c94fa07 100644 --- a/src/boot/test-bcd.c +++ b/src/boot/test-bcd.c @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #include "alloc-util.h" +#include "argv-util.h" #include "bcd.h" #include "compress.h" #include "fileio.h" diff --git a/src/boot/test-chid-match.c b/src/boot/test-chid-match.c index 5a22db70e39..400c8fc1bd3 100644 --- a/src/boot/test-chid-match.c +++ b/src/boot/test-chid-match.c @@ -1,8 +1,5 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include -#include - #include "chid.h" #include "edid.h" #include "efi-string.h" diff --git a/src/boot/test-efi-string.c b/src/boot/test-efi-string.c index 3278ac2c30d..4d8300aa911 100644 --- a/src/boot/test-efi-string.c +++ b/src/boot/test-efi-string.c @@ -2,6 +2,8 @@ #include +#include "alloc-util.h" +#include "argv-util.h" #include "efi-string.h" #include "fileio.h" #include "tests.h" diff --git a/src/boot/ticks.c b/src/boot/ticks.c index 873b9fe9e6d..bd79aed0822 100644 --- a/src/boot/ticks.c +++ b/src/boot/ticks.c @@ -1,7 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #include "ticks.h" -#include "util.h" #include "vmm.h" #if defined(__i386__) || defined(__x86_64__) diff --git a/src/boot/ticks.h b/src/boot/ticks.h index fec3764dd42..d32c0ffc0a7 100644 --- a/src/boot/ticks.h +++ b/src/boot/ticks.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include +#include "efi.h" uint64_t time_usec(void); diff --git a/src/boot/util.c b/src/boot/util.c index 20db520654b..5d439430b8d 100644 --- a/src/boot/util.c +++ b/src/boot/util.c @@ -1,12 +1,13 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #include "device-path-util.h" -#include "efi-efivars.h" + +#include "efi-log.h" #include "efi-string.h" #include "memory-util-fundamental.h" #include "proto/device-path.h" #include "proto/simple-text-io.h" -#include "ticks.h" +#include "string-util-fundamental.h" #include "util.h" #include "version.h" diff --git a/src/boot/util.h b/src/boot/util.h index 4f0fe431498..98e9ae576ee 100644 --- a/src/boot/util.h +++ b/src/boot/util.h @@ -2,13 +2,10 @@ #pragma once #include "efi.h" -#include "efi-string.h" #include "memory-util-fundamental.h" -#include "string-util-fundamental.h" #if SD_BOOT -#include "efi-log.h" #include "proto/file-io.h" /* This is provided by the linker. */ diff --git a/src/boot/vmm.c b/src/boot/vmm.c index babe581073e..da17e4584aa 100644 --- a/src/boot/vmm.c +++ b/src/boot/vmm.c @@ -11,7 +11,6 @@ #include "efi-efivars.h" #include "proto/device-path.h" #include "smbios.h" -#include "string-util-fundamental.h" #include "util.h" #include "vmm.h"