diff mbox series

[v2,2/5] eficonfig: use u16_strsize() to get u16 string buffer size

Message ID 20221128124509.6939-3-masahisa.kojima@linaro.org
State Superseded
Headers show
Series miscellaneous fixes of eficonfig | expand

Commit Message

Masahisa Kojima Nov. 28, 2022, 12:45 p.m. UTC
Use u16_strsize() to simplify the u16 string buffer
size calculation.

Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
No update since v1.

 cmd/eficonfig.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Ilias Apalodimas Nov. 29, 2022, 7:14 a.m. UTC | #1
On Mon, Nov 28, 2022 at 09:45:06PM +0900, Masahisa Kojima wrote:
> Use u16_strsize() to simplify the u16 string buffer
> size calculation.
> 
> Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
> No update since v1.
> 
>  cmd/eficonfig.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c
> index 5529edc85e..88d507d04c 100644
> --- a/cmd/eficonfig.c
> +++ b/cmd/eficonfig.c
> @@ -452,8 +452,7 @@ struct efi_device_path *eficonfig_create_device_path(struct efi_device_path *dp_
>  	struct efi_device_path *dp;
>  	struct efi_device_path_file_path *fp;
>  
> -	fp_size = sizeof(struct efi_device_path) +
> -		  ((u16_strlen(current_path) + 1) * sizeof(u16));
> +	fp_size = sizeof(struct efi_device_path) + u16_strsize(current_path);
>  	buf = calloc(1, fp_size + sizeof(END));
>  	if (!buf)
>  		return NULL;
> -- 
> 2.17.1
> 

Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
diff mbox series

Patch

diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c
index 5529edc85e..88d507d04c 100644
--- a/cmd/eficonfig.c
+++ b/cmd/eficonfig.c
@@ -452,8 +452,7 @@  struct efi_device_path *eficonfig_create_device_path(struct efi_device_path *dp_
 	struct efi_device_path *dp;
 	struct efi_device_path_file_path *fp;
 
-	fp_size = sizeof(struct efi_device_path) +
-		  ((u16_strlen(current_path) + 1) * sizeof(u16));
+	fp_size = sizeof(struct efi_device_path) + u16_strsize(current_path);
 	buf = calloc(1, fp_size + sizeof(END));
 	if (!buf)
 		return NULL;