Allow print_size to print in GB
PATCH 1/1 Allow print_size to print in GB
Signed-off-by Becky Bruce <[email protected]>
---
This patch supersedes Stefan's recent patch to allow the printing of thousands of MB. We use GB instead.
-Becky
lib_generic/display_options.c | 32 ++++++++++++++++++++------------ 1 files changed, 20 insertions(+), 12 deletions(-)
lib_generic/display_options.c +21 -13
@@ -39,27 +39,35 @@ int display_options (void) }/* -* print sizes as "xxx kB", "xxx.y kB", "xxx MB" or "xxx.y MB" as needed; -* allow for optional trailing string (like "\n") +* print sizes as "xxx kB", "xxx.y kB", "xxx MB", "xxx.y MB", +* xxx GB, or xxx.y GB as needed; allow for optional trailing string +* (like "\n") */ void print_size (phys_size_t size,const char *s) { -ulong m, n; -ulong d =1 <<20 ;/* 1 MB */ -char c ='M' ; - -if (size < d) {/* print in kB */ - c ='k' ; - d =1 <<10 ; +ulong m =0 , n; +phys_size_t d =1 <<30 ;/* 1 GB */ +char c ='G' ; + +if (size < d) {/* try MB */ + c ='M' ; + d =1 <<20 ; +if (size < d) {/* print in kB */ + c ='k' ; + d =1 <<10 ; + } } n = size / d; - m = (10 * (size - (n * d)) + (d /2 ) ) / d; +/* If there's a remainder, deal with it */ +if (size % d) { + m = (10 * (size - (n * d)) + (d /2 ) ) / d; -if (m >=10 ) { - m -=10 ; - n +=1 ; +if (m >=10 ) { + m -=10 ; + n +=1 ; + } }printf ("%2ld" , n);
Signature · 1 line
1.5.4.1
Wolfgang Denk
AppliedPATCH 1/1 Allow print_size to print in GB
Quoted 9 lines · In message <[email protected]> you…
Signed-off-by Becky Bruce <[email protected]>---
This patch supersedes Stefan's recent patch to allow the printing of thousands of MB. We use GB instead.-Becky
lib_generic/display_options.c | 32 ++++++++++++++++++++------------ 1 files changed, 20 insertions(+), 12 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de "Maintain an awareness for contribution -- to your schedule, your project, our company." - A Group of Employees