On 18.10.21 14:09, Michael Adler wrote:
> If verbosity is false, then dump_envs is mostly a no-op. In that case,
> do not even call the function. In other words, move the if-clause
> where it belongs.
> 
> Signed-off-by: Michael Adler <[email protected]>
> ---
>  tools/bg_setenv.c | 17 ++++++++---------
>  1 file changed, 8 insertions(+), 9 deletions(-)
> 
> diff --git a/tools/bg_setenv.c b/tools/bg_setenv.c
> index 071c9fc..7b9ce79 100644
> --- a/tools/bg_setenv.c
> +++ b/tools/bg_setenv.c
> @@ -549,10 +549,8 @@ static void update_environment(BGENV *env)
>  static void dump_envs(void)
>  {
>       for (int i = 0; i < ENV_NUM_CONFIG_PARTS; i++) {
> -             if (verbosity) {
> -                     fprintf(stdout, "\n----------------------------\n");
> -                     fprintf(stdout, " Config Partition #%d ", i);
> -             }
> +             fprintf(stdout, "\n----------------------------\n");
> +             fprintf(stdout, " Config Partition #%d ", i);
>               BGENV *env = bgenv_open_by_index(i);
>               if (!env) {
>                       fprintf(stderr, "Error, could not read environment "
> @@ -560,9 +558,7 @@ static void dump_envs(void)
>                               i);
>                       return;
>               }
> -             if (verbosity) {
> -                     dump_env(env->data);
> -             }
> +             dump_env(env->data);
>               bgenv_close(env);
>       }
>  }
> @@ -703,13 +699,16 @@ int main(int argc, char **argv)
>               return 1;
>       }
>  
> -     dump_envs();
> -
>       if (!write_mode) {
> +             dump_envs();

But this will now dump irrespective of "verbosity", no?

>               bgenv_finalize();
>               return 0;
>       }
>  
> +     if (verbosity) {
> +             dump_envs();
> +     }
> +

You rather need to pull this up an share it with the !write_mode case.

Jan

>       BGENV *env_new = NULL;
>       BGENV *env_current;
>  
> 

-- 
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux

-- 
You received this message because you are subscribed to the Google Groups "EFI 
Boot Guard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/efibootguard-dev/8e2425aa-8823-bb2d-e043-8689b34cae67%40siemens.com.

Reply via email to