free: fix scaling on 32-bit systems

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
This commit is contained in:
Craig Small 2018-04-10 21:20:25 +10:00
parent 1982a79ba8
commit 58bff862fc
2 changed files with 2 additions and 1 deletions

1
NEWS
View File

@ -2,6 +2,7 @@ procps-ng-3.3.14
---------------- ----------------
* pgrep: Don't segfault on non match Debian #894917 * pgrep: Don't segfault on non match Debian #894917
* pgrep/pkill: Revert so matches all namespaces issue #91 * pgrep/pkill: Revert so matches all namespaces issue #91
* free: Fix scaling on 32-bit systems issue #89
procps-ng-3.3.13 procps-ng-3.3.13
---------------- ----------------

2
free.c
View File

@ -133,7 +133,7 @@ static const char *scale_size(unsigned long size, int flags, struct commandline_
if (args.exponent > 1) { if (args.exponent > 1) {
/* In desired scale. */ /* In desired scale. */
snprintf(buf, sizeof(buf), "%ld", 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; return buf;
} }