Module Name: src
Committed By: riastradh
Date: Wed Jun 15 13:47:26 UTC 2016
Modified Files:
src/doc: HACKS
src/usr.sbin/wiconfig: Makefile wiconfig.c
Log Message:
Kill another strict aliasing violation.
To generate a diff of this commit:
cvs rdiff -u -r1.171 -r1.172 src/doc/HACKS
cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/wiconfig/Makefile
cvs rdiff -u -r1.44 -r1.45 src/usr.sbin/wiconfig/wiconfig.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/doc/HACKS
diff -u src/doc/HACKS:1.171 src/doc/HACKS:1.172
--- src/doc/HACKS:1.171 Wed Jun 15 13:29:30 2016
+++ src/doc/HACKS Wed Jun 15 13:47:26 2016
@@ -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/rbootd/Makefile : 1.10
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
Index: src/usr.sbin/wiconfig/Makefile
diff -u src/usr.sbin/wiconfig/Makefile:1.6 src/usr.sbin/wiconfig/Makefile:1.7
--- src/usr.sbin/wiconfig/Makefile:1.6 Fri Aug 10 12:10:30 2012
+++ src/usr.sbin/wiconfig/Makefile Wed Jun 15 13:47:26 2016
@@ -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
Index: src/usr.sbin/wiconfig/wiconfig.c
diff -u src/usr.sbin/wiconfig/wiconfig.c:1.44 src/usr.sbin/wiconfig/wiconfig.c:1.45
--- src/usr.sbin/wiconfig/wiconfig.c:1.44 Thu Apr 12 11:46:14 2012
+++ src/usr.sbin/wiconfig/wiconfig.c Wed Jun 15 13:47:26 2016
@@ -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 <[email protected]>. 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 @@ wi_apscan(char *iface)
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 @@ wi_apscan(char *iface)
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[] = {