]> granicus.if.org Git - procps-ng/commitdiff
free: fix scaling on 32-bit systems _______ (catch up)
authorJim Warner <james.warner@comcast.net>
Wed, 11 Apr 2018 05:00:00 +0000 (00:00 -0500)
committerCraig Small <csmall@enc.com.au>
Sat, 5 May 2018 21:19:38 +0000 (07:19 +1000)
--------------- Original Master Branch Commit Message:
Systems that have a 32-bit long would give incorrect results in free.

References:
 Issue #89
 https://www.freelists.org/post/procps/frees-scale-size-broken-with-32bit-long

Signed-off-by: Jim Warner <james.warner@comcast.net>
NEWS
free.c

diff --git a/NEWS b/NEWS
index f9ee69a79ed800b6df061ee16d3fa888b875f625..822a88bebfbc4cec9af80399da4103512e376b27 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,7 @@ procps-ng-3.3.14
 ----------------
   * pgrep: Don't segfault on non match                     Debian #894917
   * pgrep/pkill: Revert so matches all namespaces          issue #91
+  * free: Fix scaling on 32-bit systems                    issue #89
 
 procps-ng-3.3.13
 ----------------
diff --git a/free.c b/free.c
index d3071df200692e6e2e98a34f6291102d5ab169c0..d10ec6c876d593d56ee3ef949259224d988cea77 100644 (file)
--- a/free.c
+++ b/free.c
@@ -133,7 +133,7 @@ static const char *scale_size(unsigned long size, int flags, struct commandline_
                if (args.exponent > 1) {
                        /* In desired scale. */
                        snprintf(buf, sizeof(buf), "%ld",
-                 (long int)((size * 1024) / power(base, args.exponent-1))
+                 (long int)((size * 1024.0) / power(base, args.exponent-1))
                            );
                        return buf;
                }