[PATCH] lib: Obsolete parameter of ebg_env_getglobalstate officially

4 views
Skip to first unread message

Jan Kiszka

unread,
Feb 19, 2025, 11:12:16 AMFeb 19
to EFI Boot Guard, Storm, Christian, Lisicki, Raphael, Kaufmann, Bjoern
From: Jan Kiszka <jan.k...@siemens.com>

ebg_env_getglobalstate neither used nor needs a concrete environment
for retrieving the effective state over all envs. The passed parameter
has always been ignored and was probably only introduced to have a
consistent signature compared to ebg_env_setglobalstate or other
functions.

At the same time, opening and closing an env via ebg_env_open_current
and ebg_env_close is unfortunately not side-effect free which can cause
surprises to users, see e.g. [1]. It is therefore better to avoid any
needless opening of envs by officially declaring the parameter as
reserved, just asking the user to pass NULL from now on.

This does not change our API practically, it just makes it official that
the parameter is unneeded. For that reason, we do not even enforce the
parameter to be actually NULL. Users can continue to pass valid envs
as well.

[1] https://groups.google.com/g/efibootguard-dev/c/hAFE-LQ5cvc

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
env/env_api.c | 2 +-
include/ebgenv.h | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/env/env_api.c b/env/env_api.c
index 0feb127..e11f8c3 100644
--- a/env/env_api.c
+++ b/env/env_api.c
@@ -176,7 +176,7 @@ uint32_t ebg_env_user_free(ebgenv_t *e)
return bgenv_user_free(((BGENV *)e->bgenv)->data->userdata);
}

-uint16_t ebg_env_getglobalstate(ebgenv_t __attribute__((unused)) *e)
+uint16_t ebg_env_getglobalstate(void __attribute__((unused)) *reserved)
{
BGENV *env;
int res = USTATE_UNKNOWN;
diff --git a/include/ebgenv.h b/include/ebgenv.h
index c62d271..60ba81c 100644
--- a/include/ebgenv.h
+++ b/include/ebgenv.h
@@ -136,10 +136,10 @@ int ebg_env_get_ex(ebgenv_t *e, char *key, uint64_t *datatype, uint8_t *buffer,
uint32_t ebg_env_user_free(ebgenv_t *e);

/** @brief Get global ustate value, accounting for all environments
- * @param e A pointer to an ebgenv_t context.
+ * @param reserved Historic parameter, must be NULL.
* @return ustate value
*/
-uint16_t ebg_env_getglobalstate(ebgenv_t *e);
+uint16_t ebg_env_getglobalstate(void *reserved);

/** @brief Set global ustate value, accounting for all environments
* if state is set to zero and updating only current environment if
--
2.43.0

Jan Kiszka

unread,
Feb 19, 2025, 1:02:13 PMFeb 19
to EFI Boot Guard, Storm, Christian, Lisicki, Raphael, Kaufmann, Bjoern
On 19.02.25 17:12, 'Jan Kiszka' via EFI Boot Guard wrote:
> From: Jan Kiszka <jan.k...@siemens.com>
>
> ebg_env_getglobalstate neither used nor needs a concrete environment
> for retrieving the effective state over all envs. The passed parameter
> has always been ignored and was probably only introduced to have a
> consistent signature compared to ebg_env_setglobalstate or other
> functions.

...but it does need a prior call to bgenv_init which is only officially
available via open or create. I'm considering to add bgenv_init to this
function here as well now.

Jan
Siemens AG, Foundational Technologies
Linux Expert Center
Reply all
Reply to author
Forward
0 new messages