Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Kill another strict aliasing violation.
details: https://anonhg.NetBSD.org/src/rev/f6bf7dbfe656
branches: trunk
changeset: 345916:f6bf7dbfe656
user: riastradh <riastradh%NetBSD.org@localhost>
date: Wed Jun 15 13:47:26 2016 +0000
description:
Kill another strict aliasing violation.
diffstat:
doc/HACKS | 3 +--
usr.sbin/wiconfig/Makefile | 6 +-----
usr.sbin/wiconfig/wiconfig.c | 19 +++++++++++++------
3 files changed, 15 insertions(+), 13 deletions(-)
diffs (85 lines):
diff -r 205fcff56ef1 -r f6bf7dbfe656 doc/HACKS
--- a/doc/HACKS Wed Jun 15 13:29:30 2016 +0000
+++ b/doc/HACKS Wed Jun 15 13:47:26 2016 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: HACKS,v 1.171 2016/06/15 13:29:30 riastradh Exp $
+# $NetBSD: HACKS,v 1.172 2016/06/15 13:47:26 riastradh Exp $
#
# This file is intended to document workarounds for currently unsolved
# (mostly) compiler bugs.
@@ -278,7 +278,6 @@
file usr.sbin/rpc.pcnfsd/Makefile : 1.17
file usr.sbin/rtadvd/Makefile : 1.9
file usr.sbin/tcpdump/Makefile : 1.42
-file usr.sbin/wiconfig/Makefile : 1.3
descr
GCC 4.1 warns on pointer sign comparision/assignments and lots of
code does not conform. For now we use -Wno-pointer-sign and
diff -r 205fcff56ef1 -r f6bf7dbfe656 usr.sbin/wiconfig/Makefile
--- a/usr.sbin/wiconfig/Makefile Wed Jun 15 13:29:30 2016 +0000
+++ b/usr.sbin/wiconfig/Makefile Wed Jun 15 13:47:26 2016 +0000
@@ -1,10 +1,6 @@
-# $NetBSD: Makefile,v 1.6 2012/08/10 12:10:30 joerg Exp $
+# $NetBSD: Makefile,v 1.7 2016/06/15 13:47:26 riastradh Exp $
PROG= wiconfig
MAN= wiconfig.8
.include <bsd.prog.mk>
-
-.if defined(HAVE_GCC) || defined(HAVE_LLVM)
-COPTS+= -fno-strict-aliasing
-.endif
diff -r 205fcff56ef1 -r f6bf7dbfe656 usr.sbin/wiconfig/wiconfig.c
--- a/usr.sbin/wiconfig/wiconfig.c Wed Jun 15 13:29:30 2016 +0000
+++ b/usr.sbin/wiconfig/wiconfig.c Wed Jun 15 13:47:26 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wiconfig.c,v 1.44 2012/04/12 11:46:14 joerg Exp $ */
+/* $NetBSD: wiconfig.c,v 1.45 2016/06/15 13:47:26 riastradh Exp $ */
/*
* Copyright (c) 1997, 1998, 1999
* Bill Paul <wpaul%ctr.columbia.edu@localhost>. All rights reserved.
@@ -68,7 +68,7 @@
#if !defined(lint)
__COPYRIGHT("@(#) Copyright (c) 1997, 1998, 1999\
Bill Paul. All rights reserved.");
-__RCSID("$NetBSD: wiconfig.c,v 1.44 2012/04/12 11:46:14 joerg Exp $");
+__RCSID("$NetBSD: wiconfig.c,v 1.45 2016/06/15 13:47:26 riastradh Exp $");
#endif
struct wi_table {
@@ -156,7 +156,8 @@
int naps, rate;
int retries = 10;
int flags;
- struct wi_apinfo *w;
+ struct wi_apinfo aps[howmany(WI_MAX_DATALEN,
+ sizeof(struct wi_apinfo))];
int i, j;
if (iface == NULL)
@@ -212,15 +213,21 @@
err(1, "ioctl");
}
- naps = *(int *)wreq.wi_val;
+ memcpy(&naps, wreq.wi_val, sizeof(int));
if (naps > 0)
printf("\nAP Information\n");
else
printf("\nNo APs available\n");
- w = (struct wi_apinfo *)(((char *)&wreq.wi_val) + sizeof(int));
- for ( i = 0; i < naps; i++, w++) {
+ naps = MIN((unsigned)naps,
+ howmany(sizeof(wreq.wi_val) - sizeof(int), sizeof(*aps)));
+ memcpy(aps, (const char *)wreq.wi_val + sizeof(int),
+ (unsigned)naps * sizeof(*aps));
+
+ for (i = 0; i < naps; i++) {
+ const struct wi_apinfo *const w = &aps[i];
+
printf("ap[%d]:\n", i);
if (w->scanreason) {
static const char *scanm[] = {
Home |
Main Index |
Thread Index |
Old Index