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

cchoux chou.cosmo at gmail.com
Sat Apr 22 00:31:15 PDT 2023


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>
---
 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);
-- 
2.25.1




More information about the linux-mtd mailing list