aboutsummaryrefslogtreecommitdiff
path: root/sbin/sysctl
diff options
context:
space:
mode:
authorUlrich Spörlein <uqs@FreeBSD.org>2010-02-15 14:08:06 +0000
committerUlrich Spörlein <uqs@FreeBSD.org>2010-02-15 14:08:06 +0000
commit6d7a8f6cba698e03d4bfb954395dea8812c7f1bb (patch)
tree84deda6e9f582a7ea934c12d5ac300f96692fd62 /sbin/sysctl
parent2b6974bf616e86c205c4c43628cdc4bb91b8ac84 (diff)
downloadsrc-6d7a8f6cba698e03d4bfb954395dea8812c7f1bb.tar.gz
src-6d7a8f6cba698e03d4bfb954395dea8812c7f1bb.zip
sysctl(8): make WARNS=3 clean
Fixes inspired by work done in DragonflyBSD. PR: bin/140016 Approved by: ed (Co-mentor)
Notes
Notes: svn path=/head/; revision=203917
Diffstat (limited to 'sbin/sysctl')
-rw-r--r--sbin/sysctl/Makefile2
-rw-r--r--sbin/sysctl/sysctl.c28
2 files changed, 18 insertions, 12 deletions
diff --git a/sbin/sysctl/Makefile b/sbin/sysctl/Makefile
index 381f19918be3..06ff9b482d69 100644
--- a/sbin/sysctl/Makefile
+++ b/sbin/sysctl/Makefile
@@ -2,7 +2,7 @@
# $FreeBSD$
PROG= sysctl
-WARNS?= 0
+WARNS?= 3
MAN= sysctl.8
.include <bsd.prog.mk>
diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c
index b450f2d267ae..5d0025bbcb1c 100644
--- a/sbin/sysctl/sysctl.c
+++ b/sbin/sysctl/sysctl.c
@@ -279,7 +279,10 @@ parse(char *string)
case CTLTYPE_STRING:
break;
case CTLTYPE_QUAD:
- sscanf(newval, "%qd", &quadval);
+ quadval = strtoq(newval, &endptr, 0);
+ if (endptr == newval || *endptr != '\0')
+ errx(1, "invalid quad integer"
+ " '%s'", (char *)newval);
newval = &quadval;
newsize = sizeof(quadval);
break;
@@ -334,7 +337,7 @@ S_clockinfo(int l2, void *p)
struct clockinfo *ci = (struct clockinfo*)p;
if (l2 != sizeof(*ci)) {
- warnx("S_clockinfo %d != %d", l2, sizeof(*ci));
+ warnx("S_clockinfo %d != %zu", l2, sizeof(*ci));
return (1);
}
printf(hflag ? "{ hz = %'d, tick = %'d, profhz = %'d, stathz = %'d }" :
@@ -349,7 +352,7 @@ S_loadavg(int l2, void *p)
struct loadavg *tv = (struct loadavg*)p;
if (l2 != sizeof(*tv)) {
- warnx("S_loadavg %d != %d", l2, sizeof(*tv));
+ warnx("S_loadavg %d != %zu", l2, sizeof(*tv));
return (1);
}
printf(hflag ? "{ %'.2f %'.2f %'.2f }" : "{ %.2f %.2f %.2f }",
@@ -367,7 +370,7 @@ S_timeval(int l2, void *p)
char *p1, *p2;
if (l2 != sizeof(*tv)) {
- warnx("S_timeval %d != %d", l2, sizeof(*tv));
+ warnx("S_timeval %d != %zu", l2, sizeof(*tv));
return (1);
}
printf(hflag ? "{ sec = %'jd, usec = %'ld } " :
@@ -389,7 +392,7 @@ S_vmtotal(int l2, void *p)
int pageKilo = getpagesize() / 1024;
if (l2 != sizeof(*v)) {
- warnx("S_vmtotal %d != %d", l2, sizeof(*v));
+ warnx("S_vmtotal %d != %zu", l2, sizeof(*v));
return (1);
}
@@ -421,7 +424,7 @@ T_dev_t(int l2, void *p)
dev_t *d = (dev_t *)p;
if (l2 != sizeof(*d)) {
- warnx("T_dev_T %d != %d", l2, sizeof(*d));
+ warnx("T_dev_T %d != %zu", l2, sizeof(*d));
return (1);
}
printf("%s", devname(*d, S_IFCHR));
@@ -518,7 +521,7 @@ oidfmt(int *oid, int len, char *fmt, u_int *kind)
j = sizeof(buf);
i = sysctl(qoid, len + 2, buf, &j, 0, 0);
if (i)
- err(1, "sysctl fmt %d %d %d", i, j, errno);
+ err(1, "sysctl fmt %d %zu %d", i, j, errno);
if (kind)
*kind = *(u_int *)buf;
@@ -551,6 +554,9 @@ show_var(int *oid, int nlen)
u_int kind;
int (*func)(int, void *);
+ /* Silence GCC. */
+ umv = mv = intlen = 0;
+
bzero(buf, BUFSIZ);
bzero(name, BUFSIZ);
qoid[0] = 0;
@@ -560,7 +566,7 @@ show_var(int *oid, int nlen)
j = sizeof(name);
i = sysctl(qoid, nlen + 2, name, &j, 0, 0);
if (i || !j)
- err(1, "sysctl name %d %d %d", i, j, errno);
+ err(1, "sysctl name %d %zu %d", i, j, errno);
if (Nflag) {
printf("%s", name);
@@ -611,7 +617,7 @@ show_var(int *oid, int nlen)
case 'A':
if (!nflag)
printf("%s%s", name, sep);
- printf("%.*s", len, p);
+ printf("%.*s", (int)len, p);
free(oval);
return (0);
@@ -698,7 +704,7 @@ show_var(int *oid, int nlen)
}
if (!nflag)
printf("%s%s", name, sep);
- printf("Format:%s Length:%d Dump:0x", fmt, len);
+ printf("Format:%s Length:%zu Dump:0x", fmt, len);
while (len-- && (xflag || p < val + 16))
printf("%02x", *p++);
if (!xflag && len > 16)
@@ -734,7 +740,7 @@ sysctl_all(int *oid, int len)
if (errno == ENOENT)
return (0);
else
- err(1, "sysctl(getnext) %d %d", j, l2);
+ err(1, "sysctl(getnext) %d %zu", j, l2);
}
l2 /= sizeof(int);