summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2016-08-14 22:54:57 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2016-08-14 22:54:57 +0000
commit4f33aa7de21c13cdb09e33af2967269b3ae73316 (patch)
tree5a3c9154bc466344bbb1ab05cc9b80421de41237
parent7625c1e802bc81757a697cd68d74ee269415207a (diff)
Use int64_t and %ll for CTLTYPE_QUAD nodes.
Use memcpy() instead of up-casting from char* to long long* ok krw@
-rw-r--r--sbin/sysctl/sysctl.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c
index 6e0d630b852..19da662b94f 100644
--- a/sbin/sysctl/sysctl.c
+++ b/sbin/sysctl/sysctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sysctl.c,v 1.216 2016/07/27 14:44:59 tedu Exp $ */
+/* $OpenBSD: sysctl.c,v 1.217 2016/08/14 22:54:56 guenther Exp $ */
/* $NetBSD: sysctl.c,v 1.9 1995/09/30 07:12:50 thorpej Exp $ */
/*
@@ -710,8 +710,7 @@ parse(char *string, int flags)
break;
case CTLTYPE_QUAD:
- /* XXX - assumes sizeof(long long) == sizeof(quad_t) */
- (void)sscanf(newval, "%lld", (long long *)&quadval);
+ (void)sscanf(newval, "%lld", &quadval);
newval = &quadval;
newsize = sizeof(quadval);
break;
@@ -940,20 +939,22 @@ parse(char *string, int flags)
case CTLTYPE_QUAD:
if (newsize == 0) {
- long long tmp = *(quad_t *)buf;
+ int64_t tmp;
+ memcpy(&tmp, buf, sizeof tmp);
if (!nflag)
(void)printf("%s%s", string, equ);
(void)printf("%lld\n", tmp);
} else {
- long long tmp = *(quad_t *)buf;
+ int64_t tmp;
+ memcpy(&tmp, buf, sizeof tmp);
if (!qflag) {
if (!nflag)
(void)printf("%s: %lld -> ",
string, tmp);
- tmp = *(quad_t *)newval;
- (void)printf("%qd\n", tmp);
+ memcpy(&tmp, newval, sizeof tmp);
+ (void)printf("%lld\n", tmp);
}
}
return;