Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/ic Use NetBSD's own KASSERT() and KASSERTMSG() inste...
details: https://anonhg.NetBSD.org/src/rev/694454ba8ea5
branches: trunk
changeset: 782610:694454ba8ea5
user: dyoung <dyoung%NetBSD.org@localhost>
date: Thu Nov 08 20:43:55 2012 +0000
description:
Use NetBSD's own KASSERT() and KASSERTMSG() instead of #undef and re-#defining
KASSERT(), which is awkward at best.
diffstat:
sys/dev/ic/ath.c | 61 ++++++++++++++++++++++----------------------
sys/dev/ic/ath_netbsd.h | 9 ++----
sys/dev/ic/athrate-amrr.c | 14 +++++-----
sys/dev/ic/athrate-onoe.c | 14 +++++-----
sys/dev/ic/athrate-sample.c | 12 ++++----
sys/dev/ic/athrate-sample.h | 4 +-
6 files changed, 56 insertions(+), 58 deletions(-)
diffs (truncated from 407 to 300 lines):
diff -r 4090525b6750 -r 694454ba8ea5 sys/dev/ic/ath.c
--- a/sys/dev/ic/ath.c Thu Nov 08 20:36:16 2012 +0000
+++ b/sys/dev/ic/ath.c Thu Nov 08 20:43:55 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ath.c,v 1.113 2011/11/28 00:30:17 jmcneill Exp $ */
+/* $NetBSD: ath.c,v 1.114 2012/11/08 20:43:55 dyoung Exp $ */
/*-
* Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
@@ -41,7 +41,7 @@
__FBSDID("$FreeBSD: src/sys/dev/ath/if_ath.c,v 1.104 2005/09/16 10:09:23 ru Exp $");
#endif
#ifdef __NetBSD__
-__KERNEL_RCSID(0, "$NetBSD: ath.c,v 1.113 2011/11/28 00:30:17 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ath.c,v 1.114 2012/11/08 20:43:55 dyoung Exp $");
#endif
/*
@@ -878,8 +878,8 @@
struct ieee80211com *ic = &sc->sc_ic;
DPRINTF(sc, ATH_DEBUG_ANY, "%s: pending %u\n", __func__, pending);
- KASSERT(ic->ic_opmode == IEEE80211_M_STA,
- ("unexpect operating mode %u", ic->ic_opmode));
+ KASSERTMSG(ic->ic_opmode == IEEE80211_M_STA,
+ "unexpect operating mode %u", ic->ic_opmode);
if (ic->ic_state == IEEE80211_S_RUN) {
u_int64_t lastrx = sc->sc_lastrx;
u_int64_t tsf = ath_hal_gettsf64(sc->sc_ah);
@@ -940,8 +940,8 @@
};
enum ieee80211_phymode mode = ieee80211_chan2mode(ic, chan);
- KASSERT(mode < N(modeflags), ("unexpected phy mode %u", mode));
- KASSERT(modeflags[mode] != 0, ("mode %u undefined", mode));
+ KASSERTMSG(mode < N(modeflags), "unexpected phy mode %u", mode);
+ KASSERTMSG(modeflags[mode] != 0, "mode %u undefined", mode);
return modeflags[mode];
#undef N
}
@@ -1432,7 +1432,7 @@
if (next != NULL) {
m = next;
bf = STAILQ_FIRST(&frags);
- KASSERT(bf != NULL, ("no buf for txfrag"));
+ KASSERTMSG(bf != NULL, "no buf for txfrag");
STAILQ_REMOVE_HEAD(&frags, bf_list);
goto nextfrag;
}
@@ -1499,8 +1499,8 @@
static const u_int8_t zerobssid[IEEE80211_ADDR_LEN];
struct ath_hal *ah = sc->sc_ah;
- KASSERT(k->wk_cipher->ic_cipher == IEEE80211_CIPHER_TKIP,
- ("got a non-TKIP key, cipher %u", k->wk_cipher->ic_cipher));
+ KASSERTMSG(k->wk_cipher->ic_cipher == IEEE80211_CIPHER_TKIP,
+ "got a non-TKIP key, cipher %u", k->wk_cipher->ic_cipher);
if ((k->wk_flags & IEEE80211_KEY_XR) == IEEE80211_KEY_XR) {
if (sc->sc_splitmic) {
/*
@@ -1582,8 +1582,8 @@
* so that rx frames have an entry to match.
*/
if ((k->wk_flags & IEEE80211_KEY_SWCRYPT) == 0) {
- KASSERT(cip->ic_cipher < N(ciphermap),
- ("invalid cipher type %u", cip->ic_cipher));
+ KASSERTMSG(cip->ic_cipher < N(ciphermap),
+ "invalid cipher type %u", cip->ic_cipher);
hk.kv_type = ciphermap[cip->ic_cipher];
hk.kv_len = k->wk_keylen;
memcpy(hk.kv_val, k->wk_key, k->wk_keylen);
@@ -1623,7 +1623,7 @@
#define N(a) (sizeof(a)/sizeof(a[0]))
u_int i, keyix;
- KASSERT(sc->sc_splitmic, ("key cache !split"));
+ KASSERTMSG(sc->sc_splitmic, "key cache !split");
/* XXX could optimize */
for (i = 0; i < N(sc->sc_keymap)/4; i++) {
u_int8_t b = sc->sc_keymap[i];
@@ -1678,7 +1678,7 @@
#define N(a) (sizeof(a)/sizeof(a[0]))
u_int i, keyix;
- KASSERT(!sc->sc_splitmic, ("key cache split"));
+ KASSERTMSG(!sc->sc_splitmic, "key cache split");
/* XXX could optimize */
for (i = 0; i < N(sc->sc_keymap)/4; i++) {
uint8_t b = sc->sc_keymap[i];
@@ -2195,8 +2195,8 @@
antenna = sc->sc_txantenna;
}
- KASSERT(bf->bf_nseg == 1,
- ("multi-segment beacon frame; nseg %u", bf->bf_nseg));
+ KASSERTMSG(bf->bf_nseg == 1,
+ "multi-segment beacon frame; nseg %u", bf->bf_nseg);
ds->ds_data = bf->bf_segs[0].ds_addr;
/*
* Calculate rate code.
@@ -2850,8 +2850,8 @@
sc->sc_stats.ast_rx_busdma++;
return error;
}
- KASSERT(bf->bf_nseg == 1,
- ("multi-segment packet; nseg %u", bf->bf_nseg));
+ KASSERTMSG(bf->bf_nseg == 1,
+ "multi-segment packet; nseg %u", bf->bf_nseg);
}
bus_dmamap_sync(sc->sc_dmat, bf->bf_dmamap, 0,
bf->bf_dmamap->dm_mapsize, BUS_DMASYNC_PREREAD);
@@ -3484,8 +3484,8 @@
} else
m = n;
}
- KASSERT(maxfrags > 1,
- ("maxfrags %u, but normal collapse failed", maxfrags));
+ KASSERTMSG(maxfrags > 1,
+ "maxfrags %u, but normal collapse failed", maxfrags);
/*
* Collapse consecutive mbufs to a cluster.
*/
@@ -3679,8 +3679,8 @@
ath_freetx(m0);
return error;
}
- KASSERT(bf->bf_nseg <= ATH_TXDESC,
- ("too many segments after defrag; nseg %u", bf->bf_nseg));
+ KASSERTMSG(bf->bf_nseg <= ATH_TXDESC,
+ "too many segments after defrag; nseg %u", bf->bf_nseg);
} else if (bf->bf_nseg == 0) { /* null packet, discard */
sc->sc_stats.ast_tx_nodata++;
ath_freetx(m0);
@@ -3695,7 +3695,7 @@
/* setup descriptors */
ds = bf->bf_desc;
rt = sc->sc_currates;
- KASSERT(rt != NULL, ("no rate table, mode %u", sc->sc_curmode));
+ KASSERTMSG(rt != NULL, "no rate table, mode %u", sc->sc_curmode);
/*
* NB: the 802.11 layer marks whether or not we should
@@ -3862,7 +3862,7 @@
dur = rt->info[rix].lpAckDuration;
if (wh->i_fc[1] & IEEE80211_FC1_MORE_FRAG) {
dur += dur; /* additional SIFS+ACK */
- KASSERT(m0->m_nextpkt != NULL, ("no fragment"));
+ KASSERTMSG(m0->m_nextpkt != NULL, "no fragment");
/*
* Include the size of next fragment so NAV is
* updated properly. The last fragment uses only
@@ -3896,7 +3896,7 @@
* in whether or not a short preamble is to be used.
*/
/* NB: cix is set above where RTS/CTS is enabled */
- KASSERT(cix != 0xff, ("cix not setup"));
+ KASSERTMSG(cix != 0xff, "cix not setup");
ctsrate = rt->info[cix].rateCode;
/*
* Compute the transmit duration based on the frame
@@ -4640,8 +4640,9 @@
if (sc->sc_calinterval > ath_calinterval)
sc->sc_calinterval = ath_calinterval;
}
- KASSERT(0 < sc->sc_calinterval && sc->sc_calinterval <= ath_calinterval,
- ("bad calibration interval %u", sc->sc_calinterval));
+ KASSERTMSG(0 < sc->sc_calinterval &&
+ sc->sc_calinterval <= ath_calinterval,
+ "bad calibration interval %u", sc->sc_calinterval);
DPRINTF(sc, ATH_DEBUG_CALIBRATE,
"%s: next +%u (%siqCalDone tries %u)\n", __func__,
@@ -4864,9 +4865,9 @@
ath_rate_newassoc(sc, ATH_NODE(ni), isnew);
if (isnew &&
(ic->ic_flags & IEEE80211_F_PRIVACY) == 0 && sc->sc_hasclrkey) {
- KASSERT(ni->ni_ucastkey.wk_keyix == IEEE80211_KEYIX_NONE,
- ("new assoc with a unicast key already setup (keyix %u)",
- ni->ni_ucastkey.wk_keyix));
+ KASSERTMSG(ni->ni_ucastkey.wk_keyix == IEEE80211_KEYIX_NONE,
+ "new assoc with a unicast key already setup (keyix %u)",
+ ni->ni_ucastkey.wk_keyix);
ath_setup_stationkey(ni);
}
}
@@ -5107,7 +5108,7 @@
memset(sc->sc_rixmap, 0xff, sizeof(sc->sc_rixmap));
rt = sc->sc_rates[mode];
- KASSERT(rt != NULL, ("no h/w rate set for phy mode %u", mode));
+ KASSERTMSG(rt != NULL, "no h/w rate set for phy mode %u", mode);
for (i = 0; i < rt->rateCount; i++)
sc->sc_rixmap[rt->info[i].dot11Rate & IEEE80211_RATE_VAL] = i;
memset(sc->sc_hwmap, 0, sizeof(sc->sc_hwmap));
diff -r 4090525b6750 -r 694454ba8ea5 sys/dev/ic/ath_netbsd.h
--- a/sys/dev/ic/ath_netbsd.h Thu Nov 08 20:36:16 2012 +0000
+++ b/sys/dev/ic/ath_netbsd.h Thu Nov 08 20:43:55 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ath_netbsd.h,v 1.13 2012/06/02 21:36:44 dsl Exp $ */
+/* $NetBSD: ath_netbsd.h,v 1.14 2012/11/08 20:43:55 dyoung Exp $ */
/*-
* Copyright (c) 2003, 2004 David Young
@@ -29,9 +29,6 @@
#include <sys/sysctl.h>
-#undef KASSERT
-#define KASSERT(__cond, __complaint) if (!(__cond)) panic __complaint
-
typedef struct ath_task {
void (*t_func)(void*, int);
void *t_context;
@@ -53,14 +50,14 @@
#define ATH_TXQ_LOCK_DESTROY(_tq) mutex_destroy(&(_tq)->axq_lock)
#define ATH_TXQ_LOCK(_tq) mutex_enter(&(_tq)->axq_lock)
#define ATH_TXQ_UNLOCK(_tq) mutex_exit(&(_tq)->axq_lock)
-#define ATH_TXQ_LOCK_ASSERT(_tq) do { KASSERT(mutex_owned(&(_tq)->axq_lock), ("txq lock unheld")); } while (/*CONSTCOND*/true)
+#define ATH_TXQ_LOCK_ASSERT(_tq) do { KASSERTMSG(mutex_owned(&(_tq)->axq_lock), "txq lock unheld"); } while (/*CONSTCOND*/true)
typedef kmutex_t ath_txbuf_lock_t;
#define ATH_TXBUF_LOCK_INIT(_sc) mutex_init(&(_sc)->sc_txbuflock, MUTEX_DEFAULT, IPL_NET)
#define ATH_TXBUF_LOCK_DESTROY(_sc) mutex_destroy(&(_sc)->sc_txbuflock)
#define ATH_TXBUF_LOCK(_sc) mutex_enter(&(_sc)->sc_txbuflock)
#define ATH_TXBUF_UNLOCK(_sc) mutex_exit(&(_sc)->sc_txbuflock)
-#define ATH_TXBUF_LOCK_ASSERT(_sc) do { KASSERT(mutex_owned(&(_sc)->sc_txbuflock), ("txbuf lock unheld")); } while (/*CONSTCOND*/true)
+#define ATH_TXBUF_LOCK_ASSERT(_sc) do { KASSERTMSG(mutex_owned(&(_sc)->sc_txbuflock), "txbuf lock unheld"); } while (/*CONSTCOND*/true)
#define NET_LOCK_GIANT()
#define NET_UNLOCK_GIANT()
diff -r 4090525b6750 -r 694454ba8ea5 sys/dev/ic/athrate-amrr.c
--- a/sys/dev/ic/athrate-amrr.c Thu Nov 08 20:36:16 2012 +0000
+++ b/sys/dev/ic/athrate-amrr.c Thu Nov 08 20:43:55 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: athrate-amrr.c,v 1.11 2008/12/11 05:45:29 alc Exp $ */
+/* $NetBSD: athrate-amrr.c,v 1.12 2012/11/08 20:43:55 dyoung Exp $ */
/*-
* Copyright (c) 2004 INRIA
@@ -43,7 +43,7 @@
__FBSDID("$FreeBSD: src/sys/dev/ath/ath_rate/amrr/amrr.c,v 1.10 2005/08/09 10:19:43 rwatson Exp $");
#endif
#ifdef __NetBSD__
-__KERNEL_RCSID(0, "$NetBSD: athrate-amrr.c,v 1.11 2008/12/11 05:45:29 alc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: athrate-amrr.c,v 1.12 2012/11/08 20:43:55 dyoung Exp $");
#endif
/*
@@ -202,7 +202,7 @@
const HAL_RATE_TABLE *rt = sc->sc_currates;
u_int8_t rix;
- KASSERT(rt != NULL, ("no rate table, mode %u", sc->sc_curmode));
+ KASSERTMSG(rt != NULL, "no rate table, mode %u", sc->sc_curmode);
DPRINTF(sc, "%s: set xmit rate for %s to %dM\n",
__func__, ether_sprintf(ni->ni_macaddr),
@@ -280,7 +280,7 @@
struct ieee80211com *ic = &sc->sc_ic;
int srate;
- KASSERT(ni->ni_rates.rs_nrates > 0, ("no rates"));
+ KASSERTMSG(ni->ni_rates.rs_nrates > 0, "no rates");
if (ic->ic_fixed_rate == IEEE80211_FIXED_RATE_NONE) {
/*
* No fixed rate is requested. For 11b start with
@@ -296,7 +296,7 @@
/* NB: the rate set is assumed sorted */
for (; srate >= 0 && RATE(srate) > 72; srate--)
;
- KASSERT(srate >= 0, ("bogus rate set"));
+ KASSERTMSG(srate >= 0, "bogus rate set");
}
} else {
/*
@@ -313,8 +313,8 @@
srate = ni->ni_rates.rs_nrates - 1;
for (; srate >= 0 && RATE(srate) != r; srate--)
;
- KASSERT(srate >= 0,
- ("fixed rate %d not in rate set", ic->ic_fixed_rate));
+ KASSERTMSG(srate >= 0,
+ "fixed rate %d not in rate set", ic->ic_fixed_rate);
}
ath_rate_update(sc, ni, srate);
#undef RATE
diff -r 4090525b6750 -r 694454ba8ea5 sys/dev/ic/athrate-onoe.c
--- a/sys/dev/ic/athrate-onoe.c Thu Nov 08 20:36:16 2012 +0000
+++ b/sys/dev/ic/athrate-onoe.c Thu Nov 08 20:43:55 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: athrate-onoe.c,v 1.14 2009/03/27 16:10:50 dyoung Exp $ */
+/* $NetBSD: athrate-onoe.c,v 1.15 2012/11/08 20:43:55 dyoung Exp $ */
/*-
* Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
@@ -41,7 +41,7 @@
__FBSDID("$FreeBSD: src/sys/dev/ath/ath_rate/onoe/onoe.c,v 1.10 2005/08/09 10:19:43 rwatson Exp $");
#endif
#ifdef __NetBSD__
-__KERNEL_RCSID(0, "$NetBSD: athrate-onoe.c,v 1.14 2009/03/27 16:10:50 dyoung Exp $");
Home |
Main Index |
Thread Index |
Old Index