[PATCH] misc-utils: flashcp: correct casting for percent display

Zhihao Cheng chengzhihao1 at huawei.com
Sun Apr 23 18:48:18 PDT 2023


在 2023/4/22 15:31, cchoux 写道:
> Add correct casting for written to prevent overflow that size_t is
> only 32 bits on a 32-bit platform.
> 
> Signed-off-by: cchoux <chou.cosmo at gmail.com>

Reviewed-by: Zhihao Cheng <chengzhihao1 at huawei.com>

> ---
>   misc-utils/flashcp.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/misc-utils/flashcp.c b/misc-utils/flashcp.c
> index 2e8d4c1..50f8c04 100644
> --- a/misc-utils/flashcp.c
> +++ b/misc-utils/flashcp.c
> @@ -371,7 +371,7 @@ int main (int argc,char *argv[])
>   		log_verbose ("\rWriting data: %dk/%lluk (%llu%%)",
>   				KB (written + i),
>   				KB ((unsigned long long)filestat.st_size),
> -				PERCENTAGE (written + i,(unsigned long long)filestat.st_size));
> +				PERCENTAGE ((unsigned long long)written + i,(unsigned long long)filestat.st_size));
>   
>   		/* read from filename */
>   		safe_read (fil_fd,filename,src,i);
> @@ -403,7 +403,7 @@ int main (int argc,char *argv[])
>   		log_verbose ("\rVerifying data: %luk/%lluk (%llu%%)",
>   				KB (written + i),
>   				KB ((unsigned long long)filestat.st_size),
> -				PERCENTAGE (written + i,(unsigned long long)filestat.st_size));
> +				PERCENTAGE ((unsigned long long)written + i,(unsigned long long)filestat.st_size));
>   
>   		/* read from filename */
>   		safe_read (fil_fd,filename,src,i);
> 




More information about the linux-mtd mailing list