summaryrefslogtreecommitdiffstats
path: root/usr.bin/systat
diff options
context:
space:
mode:
authorru <ru@FreeBSD.org>2006-11-28 12:46:02 +0000
committerru <ru@FreeBSD.org>2006-11-28 12:46:02 +0000
commit3b8270a3d54536f75863cb20eeed53f240d24ba5 (patch)
tree54a4571abbdb6a65f55daa94a9fdb8f8253b31fb /usr.bin/systat
parentdec1d110aeb2a55ab4ada2307d9fe7440425153d (diff)
downloadFreeBSD-src-3b8270a3d54536f75863cb20eeed53f240d24ba5.zip
FreeBSD-src-3b8270a3d54536f75863cb20eeed53f240d24ba5.tar.gz
- Revert signedness type changes to "struct vmtotal"; by making
them unsigned I made the possible overflows hard to detect, and it only saved 1 bit which isn't principal, even less now that the underlying issue with the total of virtual memory has been fixed. (For the record, it will overflow with >=2T of VM total, with 32-bit ints used to keep counters in pages.) - While here, fix printing of other "struct vmtotal" members such as t_rq, t_dw, t_pw, and t_sw as they are also signed. Reviewed by: bde MFC after: 3 days
Diffstat (limited to 'usr.bin/systat')
-rw-r--r--usr.bin/systat/vmstat.c105
1 files changed, 19 insertions, 86 deletions
diff --git a/usr.bin/systat/vmstat.c b/usr.bin/systat/vmstat.c
index 4aac01c..5aa28c1 100644
--- a/usr.bin/systat/vmstat.c
+++ b/usr.bin/systat/vmstat.c
@@ -58,7 +58,6 @@ static const char sccsid[] = "@(#)vmstat.c 8.2 (Berkeley) 1/12/94";
#include <ctype.h>
#include <err.h>
#include <errno.h>
-#include <inttypes.h>
#include <langinfo.h>
#include <nlist.h>
#include <paths.h>
@@ -137,8 +136,6 @@ static float cputime(int);
static void dinfo(int, int, struct statinfo *, struct statinfo *);
static void getinfo(struct Info *);
static void putint(int, int, int, int);
-static void putuint(unsigned, int, int, int);
-static void putuintmax(uintmax_t, int, int, int);
static void putfloat(double, int, int, int, int, int);
static void putlongdouble(long double, int, int, int, int, int);
static int ucount(void);
@@ -492,20 +489,20 @@ showkre()
putfloat(avenrun[2], STATROW, STATCOL + 32, 5, 2, 0);
mvaddstr(STATROW, STATCOL + 55, buf);
#define pgtokb(pg) ((pg) * (s.v_page_size / 1024))
- putuintmax(pgtokb(total.t_arm), MEMROW + 2, MEMCOL + 4, 7);
- putuintmax(pgtokb(total.t_armshr), MEMROW + 2, MEMCOL + 12, 7);
- putuintmax(pgtokb(total.t_avm), MEMROW + 2, MEMCOL + 20, 8);
- putuintmax(pgtokb(total.t_avmshr), MEMROW + 2, MEMCOL + 29, 8);
- putuintmax(pgtokb(total.t_rm), MEMROW + 3, MEMCOL + 4, 7);
- putuintmax(pgtokb(total.t_rmshr), MEMROW + 3, MEMCOL + 12, 7);
- putuintmax(pgtokb(total.t_vm), MEMROW + 3, MEMCOL + 20, 8);
- putuintmax(pgtokb(total.t_vmshr), MEMROW + 3, MEMCOL + 29, 8);
- putuintmax(pgtokb(total.t_free), MEMROW + 2, MEMCOL + 38, 7);
- putuint(total.t_rq - 1, PROCSROW + 2, PROCSCOL, 3);
- putuint(total.t_pw, PROCSROW + 2, PROCSCOL + 4, 3);
- putuint(total.t_dw, PROCSROW + 2, PROCSCOL + 8, 3);
- putuint(total.t_sl, PROCSROW + 2, PROCSCOL + 12, 3);
- putuint(total.t_sw, PROCSROW + 2, PROCSCOL + 16, 3);
+ putint(pgtokb(total.t_arm), MEMROW + 2, MEMCOL + 4, 7);
+ putint(pgtokb(total.t_armshr), MEMROW + 2, MEMCOL + 12, 7);
+ putint(pgtokb(total.t_avm), MEMROW + 2, MEMCOL + 20, 8);
+ putint(pgtokb(total.t_avmshr), MEMROW + 2, MEMCOL + 29, 8);
+ putint(pgtokb(total.t_rm), MEMROW + 3, MEMCOL + 4, 7);
+ putint(pgtokb(total.t_rmshr), MEMROW + 3, MEMCOL + 12, 7);
+ putint(pgtokb(total.t_vm), MEMROW + 3, MEMCOL + 20, 8);
+ putint(pgtokb(total.t_vmshr), MEMROW + 3, MEMCOL + 29, 8);
+ putint(pgtokb(total.t_free), MEMROW + 2, MEMCOL + 38, 7);
+ putint(total.t_rq - 1, PROCSROW + 2, PROCSCOL, 3);
+ putint(total.t_pw, PROCSROW + 2, PROCSCOL + 4, 3);
+ putint(total.t_dw, PROCSROW + 2, PROCSCOL + 8, 3);
+ putint(total.t_sl, PROCSROW + 2, PROCSCOL + 12, 3);
+ putint(total.t_sw, PROCSROW + 2, PROCSCOL + 16, 3);
PUTRATE(v_cow_faults, VMSTATROW, VMSTATCOL + 2, 8 - 2);
PUTRATE(v_zfod, VMSTATROW + 1, VMSTATCOL + 2, 8 - 2);
PUTRATE(v_ozfod, VMSTATROW + 2, VMSTATCOL, 8);
@@ -518,11 +515,11 @@ showkre()
PUTRATE(v_pdwakeups, VMSTATROW + 8, VMSTATCOL, 8);
PUTRATE(v_pdpages, VMSTATROW + 9, VMSTATCOL, 8);
PUTRATE(v_intrans, VMSTATROW + 10, VMSTATCOL, 8);
- putuintmax(pgtokb(s.v_wire_count), VMSTATROW + 11, VMSTATCOL, 8);
- putuintmax(pgtokb(s.v_active_count), VMSTATROW + 12, VMSTATCOL, 8);
- putuintmax(pgtokb(s.v_inactive_count), VMSTATROW + 13, VMSTATCOL, 8);
- putuintmax(pgtokb(s.v_cache_count), VMSTATROW + 14, VMSTATCOL, 8);
- putuintmax(pgtokb(s.v_free_count), VMSTATROW + 15, VMSTATCOL, 8);
+ putint(pgtokb(s.v_wire_count), VMSTATROW + 11, VMSTATCOL, 8);
+ putint(pgtokb(s.v_active_count), VMSTATROW + 12, VMSTATCOL, 8);
+ putint(pgtokb(s.v_inactive_count), VMSTATROW + 13, VMSTATCOL, 8);
+ putint(pgtokb(s.v_cache_count), VMSTATROW + 14, VMSTATCOL, 8);
+ putint(pgtokb(s.v_free_count), VMSTATROW + 15, VMSTATCOL, 8);
if (LINES - 1 > VMSTATROW + 16)
putint(s.bufspace / 1024, VMSTATROW + 16, VMSTATCOL, 8);
PUTRATE(v_vnodein, PAGEROW + 2, PAGECOL + 6, 5);
@@ -697,70 +694,6 @@ putint(n, l, lc, w)
}
static void
-putuint(n, l, lc, w)
- unsigned n;
- int l, lc, w;
-{
- int snr;
- char b[128];
-
- move(l, lc);
-#ifdef DEBUG
- while (w-- > 0)
- addch('*');
- return;
-#endif
- if (n == 0) {
- while (w-- > 0)
- addch(' ');
- return;
- }
- snr = snprintf(b, sizeof(b), "%*u", w, n);
- if (snr != w)
- snr = snprintf(b, sizeof(b), "%*uk", w - 1, n / 1000);
- if (snr != w)
- snr = snprintf(b, sizeof(b), "%*uM", w - 1, n / 1000000);
- if (snr != w) {
- while (w-- > 0)
- addch('*');
- return;
- }
- addstr(b);
-}
-
-static void
-putuintmax(n, l, lc, w)
- uintmax_t n;
- int l, lc, w;
-{
- int snr;
- char b[128];
-
- move(l, lc);
-#ifdef DEBUG
- while (w-- > 0)
- addch('*');
- return;
-#endif
- if (n == 0) {
- while (w-- > 0)
- addch(' ');
- return;
- }
- snr = snprintf(b, sizeof(b), "%*ju", w, n);
- if (snr != w)
- snr = snprintf(b, sizeof(b), "%*juk", w - 1, n / 1000);
- if (snr != w)
- snr = snprintf(b, sizeof(b), "%*juM", w - 1, n / 1000000);
- if (snr != w) {
- while (w-- > 0)
- addch('*');
- return;
- }
- addstr(b);
-}
-
-static void
putfloat(f, l, lc, w, d, nz)
double f;
int l, lc, w, d, nz;
OpenPOWER on IntegriCloud