cmd: env: print a message when setting UEFI variable failed
PATCH v2 1/1 cmd: env: print a message when setting UEFI variable failed
Error message will alert a user that setting/deleting a variable failed.
---
Changes in v2 (May 24, 2019)
* change a message to "Out of memory"
* add more error messages
--- cmd/nvedit_efi.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
cmd/nvedit_efi.c +10 -1
@@ -373,6 +373,8 @@ 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 an argument, %s\n" , + argv[0 ]); ret =CMD_RET_FAILURE ; goto out; }
@@ -381,6 +383,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 ("## Out of memory (%ld bytes)\n" , (len +1 ) *2 ); ret =CMD_RET_FAILURE ; goto out; }
@@ -392,7 +395,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 v2 1/1 cmd: env: print a message when setting UEFI variable failed
Quoted 25 lines · AKASHI Takahiro
Error message will alert a user that setting/deleting a variable failed.
Signed-off-by AKASHI Takahiro <[email protected]>---
Changes in v2 (May 24, 2019)
* change a message to "Out of memory"
* add more error messages--- cmd/nvedit_efi.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)cmd/nvedit_efi.c +2
-0@@ -373,6 +373,8 @@ 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 an argument, %s\n" , + argv[0 ]); 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 386
Quoted 4 lines
cmd/nvedit_efi.c +1
-0@@ -381,6 +383,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 ("## Out of memory (%ld bytes)\n" , (len +1 ) *2 );
cmd/nvedit_efi.c: In function ‘do_env_set_efi’:cmd/nvedit_efi.c:386:31: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘size_t’ {aka ‘unsigned int’} [-Wformat=]
printf("## Out of memory (%ld bytes)\n", (len + 1) * 2);
~~^ ~~~~~~~~~~~~~
%dIf you want to print the number of bytes use %zu. But why should the user care if it is 10 bytes or 100 bytes that could not be assigned? If he is out of memory here anyway the system is messed up.
cmd/nvedit_efi.c int do_env_set_efi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 401
Quoted 12 lines
cmd/nvedit_efi.c +4
-1ret =CMD_RET_FAILURE ; goto out; }@@ -392,7 +395,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 has type size_t so this has to %zu.
Think of a non-developer user who bought a device with pre-installedö U-Boot. What would he do with the error code?
Best 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 v2 1/1 cmd: env: print a message when setting UEFI variable failed
Quoted 35 lines · Heinrich Schuchardt
Quoted 25 lines · AKASHI Takahiro
Error message will alert a user that setting/deleting a variable failed.
Signed-off-by AKASHI Takahiro <[email protected]>---
Changes in v2 (May 24, 2019)
* change a message to "Out of memory"
* add more error messages--- cmd/nvedit_efi.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)cmd/nvedit_efi.c +2
-0@@ -373,6 +373,8 @@ 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 an argument, %s\n" , + argv[0 ]); 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 386
Quoted 4 lines
cmd/nvedit_efi.c +1
-0@@ -381,6 +383,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 ("## Out of memory (%ld bytes)\n" , (len +1 ) *2 );
cmd/nvedit_efi.c: In function ‘do_env_set_efi’:cmd/nvedit_efi.c:386:31: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘size_t’ {aka ‘unsigned int’} [-Wformat=]
Quoted 7 lines
printf("## Out of memory (%ld bytes)\n", (len + 1) * 2); ~~^ ~~~~~~~~~~~~~ %dIf you want to print the number of bytes use %zu. But why should the user care if it is 10 bytes or 100 bytes that could not be assigned? If he is out of memory here anyway the system is messed up.
Can you please clarify what you want me to do?
Otherwise, I cannot submit a next version.
Quoted 15 lines
cmd/nvedit_efi.c int do_env_set_efi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 401
Quoted 12 lines
cmd/nvedit_efi.c +4
-1ret =CMD_RET_FAILURE ; goto out; }@@ -392,7 +395,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 has type
size_tso this has to %zu.
Quoted 2 lines
Think of a non-developer user who bought a device with pre-installedö U-Boot. What would he do with the error code?
Ditto.
Thanks,
-Takahiro Akashi
Quoted 12 lines
Best 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 v2 1/1 cmd: env: print a message when setting UEFI variable failed
Quoted 40 lines · AKASHI Takahiro
Quoted 39 lines · Heinrich Schuchardt
Quoted 25 lines · AKASHI Takahiro
Error message will alert a user that setting/deleting a variable failed.
Signed-off-by AKASHI Takahiro <[email protected]>---
Changes in v2 (May 24, 2019)
* change a message to "Out of memory"
* add more error messages--- cmd/nvedit_efi.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)cmd/nvedit_efi.c +2
-0@@ -373,6 +373,8 @@ 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 an argument, %s\n" , + argv[0 ]); 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 386
Quoted 4 lines
cmd/nvedit_efi.c +1
-0@@ -381,6 +383,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 ("## Out of memory (%ld bytes)\n" , (len +1 ) *2 );
cmd/nvedit_efi.c: In function ‘do_env_set_efi’:cmd/nvedit_efi.c:386:31: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘size_t’ {aka ‘unsigned int’} [-Wformat=]printf("## Out of memory (%ld bytes)\n", (len + 1) * 2); ~~^ ~~~~~~~~~~~~~ %d
Quoted 6 lines
Quoted 3 lines
If you want to print the number of bytes use %zu. But why should the user care if it is 10 bytes or 100 bytes that could not be assigned? If he is out of memory here anyway the system is messed up.
Can you please clarify what you want me to do?
Otherwise, I cannot submit a next version.
I would suggest to leave the size information away.
Quoted 16 lines
Quoted 16 lines
cmd/nvedit_efi.c int do_env_set_efi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 401
Quoted 13 lines
cmd/nvedit_efi.c +4
-1ret =CMD_RET_FAILURE ; goto out; }@@ -392,7 +395,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 has type
size_tso this has to %zu.
Quoted 4 lines
Quoted 2 lines
Think of a non-developer user who bought a device with pre-installedö U-Boot. What would he do with the error code?
Ditto.
I would suggest to leave the return code away.
Best regards
Heinrich
Quoted 17 lines
Thanks,
-Takahiro AkashiQuoted 12 lines
Best 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);