diff mbox

0001-flashcp-Use-llu-to-print-filestat.st_size.patch

Message ID 545B8FA4.5040801@jdsu.com
State Superseded
Headers show

Commit Message

Fabien Proriol Nov. 6, 2014, 3:13 p.m. UTC
Hello,

There is a display bug in flashcp.
In fact the problem is filestat.st_size can be 64 bits (in my case, Zynq 
ARM platform).

With command:
flashcp -v IMG.img /dev/mtd0

Results lines are:

Erasing blocks: 40/40 (100%)
Writing data: 1670k/0k (2544%)

......
and at the end:

Erasing blocks: 40/40 (100%)
Writing data: 2544k/0k (100%))   <----- double parenthesis
Verifying data: 2544k/0k (100%))


I wrote a patch to solve this problem...
But I have another question about "written" and "size" variables...
The size_t type is potentially not the good type to store 
filestat.st_size, off_t should be better...


Fabien Proriol
diff mbox

Patch

diff --git a/flashcp.c b/flashcp.c
index d58c81b..04495bd 100644
--- a/flashcp.c
+++ b/flashcp.c
@@ -296,7 +296,7 @@  int main (int argc,char *argv[])
          * write the entire file to flash *
          **********************************/

-       if (flags & FLAG_VERBOSE) log_printf (LOG_NORMAL,"Writing data: 
0k/%luk (0%%)",KB (filestat.st_size));
+       if (flags & FLAG_VERBOSE) log_printf (LOG_NORMAL,"Writing data: 
0k/%lluk (0%%)",KB ((unsigned long long)filestat.st_size));
         size = filestat.st_size;