From: guenther Date: Sun, 14 Aug 2016 22:54:56 +0000 (+0000) Subject: Use int64_t and %ll for CTLTYPE_QUAD nodes. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=ece71943d7d726a1c2b329496cf818a9835100c3;p=openbsd Use int64_t and %ll for CTLTYPE_QUAD nodes. Use memcpy() instead of up-casting from char* to long long* ok krw@ --- 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;