summaryrefslogtreecommitdiffstats
path: root/sbin/sysctl/sysctl.c
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 /sbin/sysctl/sysctl.c
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 'sbin/sysctl/sysctl.c')
-rw-r--r--sbin/sysctl/sysctl.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c
index 7f442a7..3ee5658 100644
--- a/sbin/sysctl/sysctl.c
+++ b/sbin/sysctl/sysctl.c
@@ -54,7 +54,6 @@ static const char rcsid[] =
#include <ctype.h>
#include <err.h>
#include <errno.h>
-#include <inttypes.h>
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
@@ -392,22 +391,19 @@ S_vmtotal(int l2, void *p)
" (values in kilobytes)\n");
printf("===============================================\n");
printf(
- "Processes:\t\t(RUNQ: %hu Disk Wait: %hu Page Wait: "
- "%hu Sleep: %hu)\n",
+ "Processes:\t\t(RUNQ: %hd Disk Wait: %hd Page Wait: "
+ "%hd Sleep: %hd)\n",
v->t_rq, v->t_dw, v->t_pw, v->t_sl);
printf(
- "Virtual Memory:\t\t(Total: %juK, Active %juK)\n",
- (uintmax_t)v->t_vm * pageKilo,
- (uintmax_t)v->t_avm * pageKilo);
- printf("Real Memory:\t\t(Total: %juK Active %juK)\n",
- (uintmax_t)v->t_rm * pageKilo, (uintmax_t)v->t_arm * pageKilo);
- printf("Shared Virtual Memory:\t(Total: %juK Active: %juK)\n",
- (uintmax_t)v->t_vmshr * pageKilo,
- (uintmax_t)v->t_avmshr * pageKilo);
- printf("Shared Real Memory:\t(Total: %juK Active: %juK)\n",
- (uintmax_t)v->t_rmshr * pageKilo,
- (uintmax_t)v->t_armshr * pageKilo);
- printf("Free Memory Pages:\t%juK\n", (uintmax_t)v->t_free * pageKilo);
+ "Virtual Memory:\t\t(Total: %dK, Active %dK)\n",
+ v->t_vm * pageKilo, v->t_avm * pageKilo);
+ printf("Real Memory:\t\t(Total: %dK Active %dK)\n",
+ v->t_rm * pageKilo, v->t_arm * pageKilo);
+ printf("Shared Virtual Memory:\t(Total: %dK Active: %dK)\n",
+ v->t_vmshr * pageKilo, v->t_avmshr * pageKilo);
+ printf("Shared Real Memory:\t(Total: %dK Active: %dK)\n",
+ v->t_rmshr * pageKilo, v->t_armshr * pageKilo);
+ printf("Free Memory Pages:\t%dK\n", v->t_free * pageKilo);
return (0);
}
OpenPOWER on IntegriCloud