summaryrefslogtreecommitdiffstats
path: root/usr.bin/vmstat
diff options
context:
space:
mode:
authorru <ru@FreeBSD.org>2006-11-20 16:04:41 +0000
committerru <ru@FreeBSD.org>2006-11-20 16:04:41 +0000
commit1ea77e90a7ba6eb03ef9b3fc9b7d651d068676a2 (patch)
tree4492f0248b0817ad7a3f6e447b1c16b1f57bfac9 /usr.bin/vmstat
parentb38795bee6d9520e36b7e2161f05eeaeb5a0f719 (diff)
downloadFreeBSD-src-1ea77e90a7ba6eb03ef9b3fc9b7d651d068676a2.zip
FreeBSD-src-1ea77e90a7ba6eb03ef9b3fc9b7d651d068676a2.tar.gz
- Fix types of "struct vmmeter" members so they are unsigned.
- Fix overflow bugs in sysctl(8), systat(1), and vmstat(8) when printing values of "struct vmmeter" in kilobytes as they don't necessarily fit into 32 bits. (Fix sysctl(8) reporting of a total virtual memory; it's in pages too.)
Diffstat (limited to 'usr.bin/vmstat')
-rw-r--r--usr.bin/vmstat/vmstat.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/usr.bin/vmstat/vmstat.c b/usr.bin/vmstat/vmstat.c
index 24d6622..36be718 100644
--- a/usr.bin/vmstat/vmstat.c
+++ b/usr.bin/vmstat/vmstat.c
@@ -65,6 +65,7 @@ __FBSDID("$FreeBSD$");
#include <devstat.h>
#include <err.h>
#include <errno.h>
+#include <inttypes.h>
#include <kvm.h>
#include <limits.h>
#include <memstat.h>
@@ -574,12 +575,13 @@ dovmstat(unsigned int interval, int reps)
fill_vmmeter(&sum);
fill_vmtotal(&total);
- (void)printf("%2d %1d %1d",
+ (void)printf("%2u %1u %1u",
total.t_rq - 1, total.t_dw + total.t_pw, total.t_sw);
-#define vmstat_pgtok(a) ((a) * (sum.v_page_size >> 10))
+#define vmstat_pgtok(a) ((uintmax_t)(a) * (sum.v_page_size >> 10))
#define rate(x) (((x) + halfuptime) / uptime) /* round */
- (void)printf(" %7ld %6ld ", (long)vmstat_pgtok(total.t_avm),
- (long)vmstat_pgtok(total.t_free));
+ (void)printf(" %7zu %6zu ",
+ vmstat_pgtok(total.t_avm),
+ vmstat_pgtok(total.t_free));
(void)printf("%5lu ",
(unsigned long)rate(sum.v_vm_faults - osum.v_vm_faults));
(void)printf("%3lu ",
OpenPOWER on IntegriCloud