cmd: env: print a message when setting UEFI variable failed
PATCH 1/1 cmd: env: print a message when setting UEFI variable failed
Error message will alert a user that setting/deleting a variable failed.
--- cmd/nvedit_efi.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
cmd/nvedit_efi.c +9 -1
@@ -373,6 +373,7 @@ int do_env_set_efi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])for ( ; argc >0 ; argc--, argv++)if (append_value (&value, &size, argv[0 ]) <0 ) { +printf ("## Failed to process arguments\n" ); ret =CMD_RET_FAILURE ; goto out; }
@@ -381,6 +382,7 @@ int do_env_set_efi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) len =utf8_utf16_strnlen (var_name,strlen (var_name)); var_name16 =malloc ((len +1 ) *2 );if (!var_name16) { +printf ("## Can't malloc %ld bytes\n" , (len +1 ) *2 ); ret =CMD_RET_FAILURE ; goto out; }
@@ -392,7 +394,13 @@ int do_env_set_efi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])EFI_VARIABLE_BOOTSERVICE_ACCESS |EFI_VARIABLE_RUNTIME_ACCESS , size, value)); - ret = (ret ==EFI_SUCCESS ?CMD_RET_SUCCESS :CMD_RET_FAILURE ); +if (ret ==EFI_SUCCESS ) { + ret =CMD_RET_SUCCESS ; + }else { +printf ("## Failed to set EFI variable (%ld)\n" , + ret & ~EFI_ERROR_MASK ); + ret =CMD_RET_FAILURE ; + } out:free (value);free (var_name16);
Signature · 1 line
2.21.0
PATCH 1/1 cmd: env: print a message when setting UEFI variable failed
Quoted 20 lines · AKASHI Takahiro
Error message will alert a user that setting/deleting a variable failed.
Signed-off-by AKASHI Takahiro <[email protected]>--- cmd/nvedit_efi.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)cmd/nvedit_efi.c +1
-0@@ -373,6 +373,7 @@ int do_env_set_efi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])for ( ; argc >0 ; argc--, argv++)if (append_value (&value, &size, argv[0 ]) <0 ) { +printf ("## Failed to process arguments\n" ); ret =CMD_RET_FAILURE ; goto out; }
cmd/nvedit_efi.c int do_env_set_efi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 385
Quoted 4 lines
cmd/nvedit_efi.c +1
-0@@ -381,6 +382,7 @@ int do_env_set_efi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) len =utf8_utf16_strnlen (var_name,strlen (var_name)); var_name16 =malloc ((len +1 ) *2 );if (!var_name16) { +printf ("## Can't malloc %ld bytes\n" , (len +1 ) *2 );
That message is much too technical. As a user I would not care about malloc(), calloc() or any other memory allocation call failing.
In other parts of our coding we use
printf("ERROR: Out of memory\n");
cmd/nvedit_efi.c int do_env_set_efi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 400
Quoted 12 lines
cmd/nvedit_efi.c +4
-1ret =CMD_RET_FAILURE ; goto out; }@@ -392,7 +394,13 @@ int do_env_set_efi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])EFI_VARIABLE_BOOTSERVICE_ACCESS |EFI_VARIABLE_RUNTIME_ACCESS , size, value)); - ret = (ret ==EFI_SUCCESS ?CMD_RET_SUCCESS :CMD_RET_FAILURE ); +if (ret ==EFI_SUCCESS ) { + ret =CMD_RET_SUCCESS ; + }else { + printf("## Failed to set EFI variable (%ld)\n",
efi_set_variable() is called from different places in U-Boot (e.g. efi_setup.c). On the other hand we want to make efi_set_variable() available at runtime in funture.
So may be we should replace all our EFI_CALL(efi_set_variable()) by an internal function which provides error output.
Regards
Heinrich
Quoted 7 lines
cmd/nvedit_efi.c +3
-0+ ret & ~EFI_ERROR_MASK); + ret =CMD_RET_FAILURE ; + } out:free (value);free (var_name16);
PATCH 1/1 cmd: env: print a message when setting UEFI variable failed
Quoted 29 lines · Heinrich Schuchardt
Quoted 20 lines · AKASHI Takahiro
Error message will alert a user that setting/deleting a variable failed.
Signed-off-by AKASHI Takahiro <[email protected]>--- cmd/nvedit_efi.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)cmd/nvedit_efi.c +1
-0@@ -373,6 +373,7 @@ int do_env_set_efi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])for ( ; argc >0 ; argc--, argv++)if (append_value (&value, &size, argv[0 ]) <0 ) { +printf ("## Failed to process arguments\n" ); ret =CMD_RET_FAILURE ; goto out; }cmd/nvedit_efi.c int do_env_set_efi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 385
Quoted 4 lines
cmd/nvedit_efi.c +1
-0@@ -381,6 +382,7 @@ int do_env_set_efi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) len =utf8_utf16_strnlen (var_name,strlen (var_name)); var_name16 =malloc ((len +1 ) *2 );if (!var_name16) { +printf ("## Can't malloc %ld bytes\n" , (len +1 ) *2 );That message is much too technical. As a user I would not care about
malloc(),calloc()or any other memory allocation call failing.
Quoted 3 lines
In other parts of our coding we use
printf("ERROR: Out of memory\n");
See _do_env_set() in cmd/nvedit.c.
My message above is consistent with that function.
Quoted 17 lines
cmd/nvedit_efi.c int do_env_set_efi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 400
Quoted 12 lines
cmd/nvedit_efi.c +4
-1ret =CMD_RET_FAILURE ; goto out; }@@ -392,7 +394,13 @@ int do_env_set_efi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])EFI_VARIABLE_BOOTSERVICE_ACCESS |EFI_VARIABLE_RUNTIME_ACCESS , size, value)); - ret = (ret ==EFI_SUCCESS ?CMD_RET_SUCCESS :CMD_RET_FAILURE ); +if (ret ==EFI_SUCCESS ) { + ret =CMD_RET_SUCCESS ; + }else { + printf("## Failed to set EFI variable (%ld)\n",
efi_set_variable()is called from different places in U-Boot (e.g.efi_setup.c). On the other hand we want to makeefi_set_variable()available at runtime in funture.
Quoted 2 lines
So may be we should replace all our EFI_CALL(efi_set_variable()) by an internal function which provides error output.
I don't think so.
Whether such a message be printed should deter to a caller (or application).
What message be appropriate will also depend on a context of caller.
-Takahiro Akashi
Quoted 12 lines
Regards
Heinrich
Quoted 7 lines
cmd/nvedit_efi.c +3
-0+ ret & ~EFI_ERROR_MASK); + ret =CMD_RET_FAILURE ; + } out:free (value);free (var_name16);
PATCH 1/1 cmd: env: print a message when setting UEFI variable failed
Quoted 30 lines · AKASHI Takahiro
Quoted 29 lines · Heinrich Schuchardt
Quoted 20 lines · AKASHI Takahiro
Error message will alert a user that setting/deleting a variable failed.
Signed-off-by AKASHI Takahiro <[email protected]>--- cmd/nvedit_efi.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)cmd/nvedit_efi.c +1
-0@@ -373,6 +373,7 @@ int do_env_set_efi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])for ( ; argc >0 ; argc--, argv++)if (append_value (&value, &size, argv[0 ]) <0 ) { +printf ("## Failed to process arguments\n" ); ret =CMD_RET_FAILURE ; goto out; }cmd/nvedit_efi.c int do_env_set_efi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 385
Quoted 4 lines
cmd/nvedit_efi.c +1
-0@@ -381,6 +382,7 @@ int do_env_set_efi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) len =utf8_utf16_strnlen (var_name,strlen (var_name)); var_name16 =malloc ((len +1 ) *2 );if (!var_name16) { +printf ("## Can't malloc %ld bytes\n" , (len +1 ) *2 );That message is much too technical. As a user I would not care about
malloc(),calloc()or any other memory allocation call failing.
Quoted 6 lines
Quoted 3 lines
In other parts of our coding we use
printf("ERROR: Out of memory\n");See
_do_env_set()incmd/nvedit.c.
My message above is consistent with that function.
Then that printf() should be changed too.
Best regards
Heinrich
Quoted 43 lines
Quoted 19 lines
Quoted 6 lines
cmd/nvedit_efi.c +0
-0ret =CMD_RET_FAILURE ; goto out; }cmd/nvedit_efi.c int do_env_set_efi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 400
Quoted 8 lines
cmd/nvedit_efi.c +4
-1@@ -392,7 +394,13 @@ int do_env_set_efi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])EFI_VARIABLE_BOOTSERVICE_ACCESS |EFI_VARIABLE_RUNTIME_ACCESS , size, value)); - ret = (ret ==EFI_SUCCESS ?CMD_RET_SUCCESS :CMD_RET_FAILURE ); +if (ret ==EFI_SUCCESS ) { + ret =CMD_RET_SUCCESS ; + }else { + printf("## Failed to set EFI variable (%ld)\n",
efi_set_variable()is called from different places in U-Boot (e.g.efi_setup.c). On the other hand we want to makeefi_set_variable()available at runtime in funture.Quoted 2 lines
So may be we should replace all our EFI_CALL(efi_set_variable()) by an internal function which provides error output.
I don't think so.
Whether such a message be printed should deter to a caller (or application).
What message be appropriate will also depend on a context of caller.-Takahiro Akashi
Quoted 12 lines
Regards
Heinrich
Quoted 7 lines
cmd/nvedit_efi.c +3
-0+ ret & ~EFI_ERROR_MASK); + ret =CMD_RET_FAILURE ; + } out:free (value);free (var_name16);