diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-06-11 12:23:24 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-06-15 22:01:42 +0200 |
commit | e6f055cbc42f7bdeb80b39315ce7d7019fe5b77e (patch) | |
tree | eb708f5d7f58fb68c93407c9db5731445117d065 /src/core/efi-random.c | |
parent | 7c7683f36ccaf6080fb7cb10b52de4ae2791ea32 (diff) | |
download | systemd-e6f055cbc42f7bdeb80b39315ce7d7019fe5b77e.tar.gz |
basic/efivars: replace dynanamic creation of efivar names with static strings
Creating those string dynamically at runtime is slow and unnecessary.
Let's use static strings with a bit of macro magic and the let the compiler
coalesce as much as possible.
$ size build/src/shared/libsystemd-shared-248.so{.old,}
text data bss dec hex filename
2813453 94572 4584 2912609 2c7161 build/src/shared/libsystemd-shared-248.so.old
2812309 94564 4584 2911457 2c6ce1 build/src/shared/libsystemd-shared-248.so
A nice side-effect is that the same form is used everywhere, so it's easier to
figure out all variables that are used, and where each specific variable is
used.
C.f. 2b0445262ad9be2a9bf49956ab8e886ea2e48a0a.
Note: 'const char *foo = alloca(…);' seems OK. Our coding style document and
alloca(3) only warn against using alloca() in function invocations. Declaring
both stack variable and alloca at the same time should be fine: no matter in
which order they happen, i.e. if the pointer variable is above the contents,
or the contents are above the pointer, or even if the pointer is elided by the
compiler, everything should be fine.
Diffstat (limited to 'src/core/efi-random.c')
-rw-r--r-- | src/core/efi-random.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/core/efi-random.c b/src/core/efi-random.c index 94e138b35b..a0b89d1379 100644 --- a/src/core/efi-random.c +++ b/src/core/efi-random.c @@ -27,8 +27,8 @@ static void lock_down_efi_variables(void) { * identify the system or gain too much insight into what we might have credited to the entropy * pool. */ FOREACH_STRING(p, - "/sys/firmware/efi/efivars/LoaderRandomSeed-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f", - "/sys/firmware/efi/efivars/LoaderSystemToken-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f") { + EFIVAR_PATH(EFI_LOADER_VARIABLE(LoaderRandomSeed)), + EFIVAR_PATH(EFI_LOADER_VARIABLE(LoaderSystemToken))) { r = chattr_path(p, 0, FS_IMMUTABLE_FL, NULL); if (r == -ENOENT) @@ -61,7 +61,7 @@ int efi_take_random_seed(void) { return 0; } - r = efi_get_variable(EFI_VENDOR_LOADER, "LoaderRandomSeed", NULL, &value, &size); + r = efi_get_variable(EFI_LOADER_VARIABLE(LoaderRandomSeed), NULL, &value, &size); if (r == -EOPNOTSUPP) { log_debug_errno(r, "System lacks EFI support, not initializing random seed from EFI variable."); return 0; |