]> git.ipfire.org Git - thirdparty/systemd.git/commit
basic/efivars: replace dynanamic creation of efivar names with static strings
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 11 Jun 2021 10:23:24 +0000 (12:23 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 15 Jun 2021 20:01:42 +0000 (22:01 +0200)
commite6f055cbc42f7bdeb80b39315ce7d7019fe5b77e
treeeb708f5d7f58fb68c93407c9db5731445117d065
parent7c7683f36ccaf6080fb7cb10b52de4ae2791ea32
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.
src/basic/efivars.c
src/basic/efivars.h
src/boot/bless-boot-generator.c
src/boot/bless-boot.c
src/boot/bootctl.c
src/core/efi-random.c
src/login/logind-dbus.c
src/partition/repart.c
src/shared/bootspec.c
src/shared/efi-loader.c