Skip to contentSkip to conversation

misc-utils: flashcp: correct casting for percent display

PATCH Applied cchoux 3 participants 3 messages Apr 22, 2023 – Apr 24, 2023 Memory technology devices (MTD)

lore
Share & tools
lore

cchoux

author
#0 lore raw

PATCH 1/1 misc-utils: flashcp: correct casting for percent display

Add correct casting for written to prevent overflow that size_t is only 32 bits on a 32-bit platform.

---
 misc-utils/flashcp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
misc-utils/flashcp.c +2 -2
index 2e8d4c1..50f8c04 100644
@@ -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);
Signature · 6 lines
2.25.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · cchoux

Add correct casting for written to prevent overflow that size_t is only 32 bits on a 32-bit platform.

Quoted 19 lines
---
  misc-utils/flashcp.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
misc-utils/flashcp.c +1 -1
index 2e8d4c1..50f8c04 100644
@@ -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);

misc-utils/flashcp.c int main (int argc,char *argv[]) · line 409

Quoted 8 lines
misc-utils/flashcp.c +1 -1
@@ -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);

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/