| Lorenz Brun | 6ff6b45 | 2025-05-22 14:35:09 +0200 | [diff] [blame^] | 1 | From e14a6121d78dad23e3826499177353f9596ba0d7 Mon Sep 17 00:00:00 2001 |
| 2 | From: Lorenz Brun <lorenz@brun.one> |
| 3 | Date: Thu, 22 May 2025 18:22:18 +0200 |
| 4 | Subject: [PATCH 2/2] Use local uchar.h |
| 5 | |
| 6 | --- |
| 7 | src/boot/efi/bcd.h | 2 +- |
| 8 | src/boot/efi/cpio.c | 2 ++ |
| 9 | src/boot/efi/cpio.h | 2 +- |
| 10 | src/boot/efi/devicetree.h | 2 +- |
| 11 | src/boot/efi/disk.h | 2 +- |
| 12 | src/boot/efi/efi-string.h | 2 +- |
| 13 | src/boot/efi/linux.h | 3 ++- |
| 14 | src/boot/efi/measure.h | 2 +- |
| 15 | src/boot/efi/pe.h | 2 +- |
| 16 | src/boot/efi/secure-boot.c | 2 +- |
| 17 | src/boot/efi/stub.c | 1 + |
| 18 | src/boot/efi/uchar.h | 6 ++++++ |
| 19 | src/boot/efi/util.h | 2 +- |
| 20 | src/fundamental/efivars-fundamental.h | 3 +-- |
| 21 | 14 files changed, 21 insertions(+), 12 deletions(-) |
| 22 | create mode 100644 src/boot/efi/uchar.h |
| 23 | |
| 24 | diff --git a/src/boot/efi/bcd.h b/src/boot/efi/bcd.h |
| 25 | index c27af55c1e..17d79caf20 100644 |
| 26 | --- a/src/boot/efi/bcd.h |
| 27 | +++ b/src/boot/efi/bcd.h |
| 28 | @@ -2,6 +2,6 @@ |
| 29 | #pragma once |
| 30 | |
| 31 | #include <stdint.h> |
| 32 | -#include <uchar.h> |
| 33 | +#include "uchar.h" |
| 34 | |
| 35 | char16_t *get_bcd_title(uint8_t *bcd, size_t bcd_len); |
| 36 | diff --git a/src/boot/efi/cpio.c b/src/boot/efi/cpio.c |
| 37 | index 76e2cd7f4e..5c2f68c2dc 100644 |
| 38 | --- a/src/boot/efi/cpio.c |
| 39 | +++ b/src/boot/efi/cpio.c |
| 40 | @@ -1,5 +1,7 @@ |
| 41 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 42 | |
| 43 | +#include <stddef.h> |
| 44 | + |
| 45 | #include "cpio.h" |
| 46 | #include "measure.h" |
| 47 | #include "util.h" |
| 48 | diff --git a/src/boot/efi/cpio.h b/src/boot/efi/cpio.h |
| 49 | index beebef3d8b..90ed8cd025 100644 |
| 50 | --- a/src/boot/efi/cpio.h |
| 51 | +++ b/src/boot/efi/cpio.h |
| 52 | @@ -3,7 +3,7 @@ |
| 53 | |
| 54 | #include <efi.h> |
| 55 | #include <stdbool.h> |
| 56 | -#include <uchar.h> |
| 57 | +#include "uchar.h" |
| 58 | |
| 59 | EFI_STATUS pack_cpio( |
| 60 | EFI_LOADED_IMAGE_PROTOCOL *loaded_image, |
| 61 | diff --git a/src/boot/efi/devicetree.h b/src/boot/efi/devicetree.h |
| 62 | index d512cb5037..f3c6de78ba 100644 |
| 63 | --- a/src/boot/efi/devicetree.h |
| 64 | +++ b/src/boot/efi/devicetree.h |
| 65 | @@ -2,7 +2,7 @@ |
| 66 | #pragma once |
| 67 | |
| 68 | #include <efi.h> |
| 69 | -#include <uchar.h> |
| 70 | +#include "uchar.h" |
| 71 | |
| 72 | struct devicetree_state { |
| 73 | EFI_PHYSICAL_ADDRESS addr; |
| 74 | diff --git a/src/boot/efi/disk.h b/src/boot/efi/disk.h |
| 75 | index 1a5a18733e..6f6b517a16 100644 |
| 76 | --- a/src/boot/efi/disk.h |
| 77 | +++ b/src/boot/efi/disk.h |
| 78 | @@ -2,6 +2,6 @@ |
| 79 | #pragma once |
| 80 | |
| 81 | #include <efi.h> |
| 82 | -#include <uchar.h> |
| 83 | +#include "uchar.h" |
| 84 | |
| 85 | EFI_STATUS disk_get_part_uuid(EFI_HANDLE *handle, char16_t uuid[static 37]); |
| 86 | diff --git a/src/boot/efi/efi-string.h b/src/boot/efi/efi-string.h |
| 87 | index e12add0b19..a6c8b0c56a 100644 |
| 88 | --- a/src/boot/efi/efi-string.h |
| 89 | +++ b/src/boot/efi/efi-string.h |
| 90 | @@ -3,7 +3,7 @@ |
| 91 | |
| 92 | #include <stdbool.h> |
| 93 | #include <stddef.h> |
| 94 | -#include <uchar.h> |
| 95 | +#include "uchar.h" |
| 96 | |
| 97 | #include "macro-fundamental.h" |
| 98 | |
| 99 | diff --git a/src/boot/efi/linux.h b/src/boot/efi/linux.h |
| 100 | index f0a6a37ed1..f1b7ff851f 100644 |
| 101 | --- a/src/boot/efi/linux.h |
| 102 | +++ b/src/boot/efi/linux.h |
| 103 | @@ -2,7 +2,8 @@ |
| 104 | #pragma once |
| 105 | |
| 106 | #include <efi.h> |
| 107 | -#include <uchar.h> |
| 108 | +#include "uchar.h" |
| 109 | +#include <stddef.h> |
| 110 | |
| 111 | EFI_STATUS linux_exec( |
| 112 | EFI_HANDLE parent, |
| 113 | diff --git a/src/boot/efi/measure.h b/src/boot/efi/measure.h |
| 114 | index 19a50f47e7..9db41ab5ce 100644 |
| 115 | --- a/src/boot/efi/measure.h |
| 116 | +++ b/src/boot/efi/measure.h |
| 117 | @@ -3,7 +3,7 @@ |
| 118 | |
| 119 | #include <efi.h> |
| 120 | #include <stdbool.h> |
| 121 | -#include <uchar.h> |
| 122 | +#include "uchar.h" |
| 123 | |
| 124 | #if ENABLE_TPM |
| 125 | |
| 126 | diff --git a/src/boot/efi/pe.h b/src/boot/efi/pe.h |
| 127 | index ff7ff479ec..ef56cbbee9 100644 |
| 128 | --- a/src/boot/efi/pe.h |
| 129 | +++ b/src/boot/efi/pe.h |
| 130 | @@ -2,7 +2,7 @@ |
| 131 | #pragma once |
| 132 | |
| 133 | #include <efidef.h> |
| 134 | -#include <uchar.h> |
| 135 | +#include "uchar.h" |
| 136 | |
| 137 | EFI_STATUS pe_memory_locate_sections( |
| 138 | const void *base, |
| 139 | diff --git a/src/boot/efi/secure-boot.c b/src/boot/efi/secure-boot.c |
| 140 | index 65457bf423..f65330f396 100644 |
| 141 | --- a/src/boot/efi/secure-boot.c |
| 142 | +++ b/src/boot/efi/secure-boot.c |
| 143 | @@ -41,7 +41,7 @@ EFI_STATUS secure_boot_enroll_at(EFI_FILE *root_dir, const char16_t *path) { |
| 144 | |
| 145 | EFI_STATUS err; |
| 146 | |
| 147 | - clear_screen(COLOR_NORMAL); |
| 148 | + //clear_screen(COLOR_NORMAL); |
| 149 | |
| 150 | Print(L"Enrolling secure boot keys from directory: %s\n" |
| 151 | L"Warning: Enrolling custom Secure Boot keys might soft-brick your machine!\n", |
| 152 | diff --git a/src/boot/efi/stub.c b/src/boot/efi/stub.c |
| 153 | index af80f17f81..f6b4cf060c 100644 |
| 154 | --- a/src/boot/efi/stub.c |
| 155 | +++ b/src/boot/efi/stub.c |
| 156 | @@ -2,6 +2,7 @@ |
| 157 | |
| 158 | #include <efi.h> |
| 159 | #include <efilib.h> |
| 160 | +#include <stddef.h> |
| 161 | |
| 162 | #include "cpio.h" |
| 163 | #include "devicetree.h" |
| 164 | diff --git a/src/boot/efi/uchar.h b/src/boot/efi/uchar.h |
| 165 | new file mode 100644 |
| 166 | index 0000000000..e4c0e6836b |
| 167 | --- /dev/null |
| 168 | +++ b/src/boot/efi/uchar.h |
| 169 | @@ -0,0 +1,6 @@ |
| 170 | +#pragma once |
| 171 | + |
| 172 | +/** The UTF-16 character type. */ |
| 173 | +typedef __CHAR16_TYPE__ char16_t; |
| 174 | +/** The UTF-32 character type. */ |
| 175 | +typedef __CHAR32_TYPE__ char32_t; |
| 176 | diff --git a/src/boot/efi/util.h b/src/boot/efi/util.h |
| 177 | index 08f732f484..a10e74f569 100644 |
| 178 | --- a/src/boot/efi/util.h |
| 179 | +++ b/src/boot/efi/util.h |
| 180 | @@ -54,7 +54,7 @@ static inline void freep(void *p) { |
| 181 | |
| 182 | #define _cleanup_free_ _cleanup_(freep) |
| 183 | |
| 184 | -static __always_inline void erase_obj(void *p) { |
| 185 | +static __attribute__((always_inline)) void erase_obj(void *p) { |
| 186 | #ifdef __OPTIMIZE__ |
| 187 | size_t l; |
| 188 | assert_cl(p); |
| 189 | diff --git a/src/fundamental/efivars-fundamental.h b/src/fundamental/efivars-fundamental.h |
| 190 | index fe34e6c714..5d0fc701af 100644 |
| 191 | --- a/src/fundamental/efivars-fundamental.h |
| 192 | +++ b/src/fundamental/efivars-fundamental.h |
| 193 | @@ -1,7 +1,6 @@ |
| 194 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 195 | #pragma once |
| 196 | |
| 197 | -#include <errno.h> |
| 198 | #include "string-util-fundamental.h" |
| 199 | |
| 200 | /* Features of the loader, i.e. systemd-boot */ |
| 201 | @@ -32,7 +31,7 @@ typedef enum SecureBootMode { |
| 202 | SECURE_BOOT_SETUP, |
| 203 | SECURE_BOOT_USER, |
| 204 | _SECURE_BOOT_MAX, |
| 205 | - _SECURE_BOOT_INVALID = -EINVAL, |
| 206 | + _SECURE_BOOT_INVALID = -22, |
| 207 | } SecureBootMode; |
| 208 | |
| 209 | const sd_char *secure_boot_mode_to_string(SecureBootMode m); |
| 210 | -- |
| 211 | 2.47.2 |
| 212 | |