From 4b974789799dab2c4f1aba6f028d9dfc518e291a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Wed, 17 Sep 2025 09:37:03 +0200 Subject: [PATCH] efivars: adjust location of variable attribute I also thought about converting efi_set_variable() to use writev, but we don't have loop_writev. I'm not sure if the loop around write here is important. Coinceivably, it could make a difference it we were writing a long value. The loop was introduced in b7749eb517ff5dd379cf61ee9fb50a0105ab2c0f, without much comment unfortunately. So it doesn't seem worth the risk of changing this to not use a loop, and writing loop_writev just for this also seems overkill. --- src/basic/efivars.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/basic/efivars.c b/src/basic/efivars.c index 8185a111d1..c30469d136 100644 --- a/src/basic/efivars.c +++ b/src/basic/efivars.c @@ -219,10 +219,10 @@ static int efi_verify_variable(const char *variable, uint32_t attr, const void * int efi_set_variable(const char *variable, const void *value, size_t size) { static const uint32_t attr = EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS; - struct var { + _cleanup_free_ struct var { uint32_t attr; char buf[]; - } _packed_ * _cleanup_free_ buf = NULL; + } _packed_ *buf = NULL; _cleanup_close_ int fd = -EBADF; bool saved_flags_valid = false; unsigned saved_flags;