From 9701cd40b49f5758b027cc6e68c187fcb1ed7b9f Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Wed, 5 Jul 2000 07:46:41 +0000 Subject: Support for unsigned integer and long sysctl variables. Update the SYSCTL_LONG macro to be consistent with other integer sysctl variables and require an initial value instead of assuming 0. Update several sysctl variables to use the unsigned types. PR: 15251 Submitted by: Kelly Yancey --- sbin/sysctl/sysctl.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'sbin/sysctl/sysctl.c') diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c index 1c498568a53b..8ae3cbd8a74e 100644 --- a/sbin/sysctl/sysctl.c +++ b/sbin/sysctl/sysctl.c @@ -398,9 +398,13 @@ show_var(int *oid, int nlen) case 'I': if (!nflag) printf("%s: ", name); + fmt++; val = ""; while (len >= sizeof(int)) { - printf("%s%d", val, *(int *)p); + if(*fmt == 'U') + printf("%s%u", val, *(unsigned int *)p); + else + printf("%s%d", val, *(int *)p); val = " "; len -= sizeof (int); p += sizeof (int); @@ -410,7 +414,11 @@ show_var(int *oid, int nlen) case 'L': if (!nflag) printf("%s: ", name); - printf("%ld", *(long *)p); + fmt++; + if(*fmt == 'U') + printf("%lu", *(unsigned long *)p); + else + printf("%ld", *(long *)p); return (0); case 'P': -- cgit v1.3