diff options
author | rpaulo <rpaulo@FreeBSD.org> | 2013-08-14 04:24:25 +0000 |
---|---|---|
committer | rpaulo <rpaulo@FreeBSD.org> | 2013-08-14 04:24:25 +0000 |
commit | b66e5efc0f138709337bda97b97422177187cf60 (patch) | |
tree | aab84fc7202136670f336f52bd4cbf358edc91cf /sys/net80211/ieee80211_action.c | |
parent | cee1e037da7213db868bb6bfc99884926330de56 (diff) | |
download | FreeBSD-src-b66e5efc0f138709337bda97b97422177187cf60.zip FreeBSD-src-b66e5efc0f138709337bda97b97422177187cf60.tar.gz |
Replace the homegrown implementation of nitems() with calls to nitems()
(param.h).
Operating systems that don't have nitems() can easily define it on their own
net80211 OS-specific header file.
Discussed with: adrian
Diffstat (limited to 'sys/net80211/ieee80211_action.c')
-rw-r--r-- | sys/net80211/ieee80211_action.c | 48 |
1 files changed, 20 insertions, 28 deletions
diff --git a/sys/net80211/ieee80211_action.c b/sys/net80211/ieee80211_action.c index e3576d6..a36df7c 100644 --- a/sys/net80211/ieee80211_action.c +++ b/sys/net80211/ieee80211_action.c @@ -80,37 +80,35 @@ static ieee80211_send_action_func *vendor_send_action[8] = { int ieee80211_send_action_register(int cat, int act, ieee80211_send_action_func *f) { -#define N(a) (sizeof(a) / sizeof(a[0])) switch (cat) { case IEEE80211_ACTION_CAT_BA: - if (act >= N(ba_send_action)) + if (act >= nitems(ba_send_action)) break; ba_send_action[act] = f; return 0; case IEEE80211_ACTION_CAT_HT: - if (act >= N(ht_send_action)) + if (act >= nitems(ht_send_action)) break; ht_send_action[act] = f; return 0; case IEEE80211_ACTION_CAT_SELF_PROT: - if (act >= N(meshpl_send_action)) + if (act >= nitems(meshpl_send_action)) break; meshpl_send_action[act] = f; return 0; case IEEE80211_ACTION_CAT_MESH: - if (act >= N(meshaction_send_action)) + if (act >= nitems(meshaction_send_action)) break; meshaction_send_action[act] = f; return 0; break; case IEEE80211_ACTION_CAT_VENDOR: - if (act >= N(vendor_send_action)) + if (act >= nitems(vendor_send_action)) break; vendor_send_action[act] = f; return 0; } return EINVAL; -#undef N } void @@ -122,33 +120,31 @@ ieee80211_send_action_unregister(int cat, int act) int ieee80211_send_action(struct ieee80211_node *ni, int cat, int act, void *sa) { -#define N(a) (sizeof(a) / sizeof(a[0])) ieee80211_send_action_func *f = send_inval; switch (cat) { case IEEE80211_ACTION_CAT_BA: - if (act < N(ba_send_action)) + if (act < nitems(ba_send_action)) f = ba_send_action[act]; break; case IEEE80211_ACTION_CAT_HT: - if (act < N(ht_send_action)) + if (act < nitems(ht_send_action)) f = ht_send_action[act]; break; case IEEE80211_ACTION_CAT_SELF_PROT: - if (act < N(meshpl_send_action)) + if (act < nitems(meshpl_send_action)) f = meshpl_send_action[act]; break; case IEEE80211_ACTION_CAT_MESH: - if (act < N(meshaction_send_action)) + if (act < nitems(meshaction_send_action)) f = meshaction_send_action[act]; break; case IEEE80211_ACTION_CAT_VENDOR: - if (act < N(vendor_send_action)) + if (act < nitems(vendor_send_action)) f = vendor_send_action[act]; break; } return f(ni, cat, act, sa); -#undef N } static int @@ -183,36 +179,34 @@ static ieee80211_recv_action_func *vendor_recv_action[8] = { int ieee80211_recv_action_register(int cat, int act, ieee80211_recv_action_func *f) { -#define N(a) (sizeof(a) / sizeof(a[0])) switch (cat) { case IEEE80211_ACTION_CAT_BA: - if (act >= N(ba_recv_action)) + if (act >= nitems(ba_recv_action)) break; ba_recv_action[act] = f; return 0; case IEEE80211_ACTION_CAT_HT: - if (act >= N(ht_recv_action)) + if (act >= nitems(ht_recv_action)) break; ht_recv_action[act] = f; return 0; case IEEE80211_ACTION_CAT_SELF_PROT: - if (act >= N(meshpl_recv_action)) + if (act >= nitems(meshpl_recv_action)) break; meshpl_recv_action[act] = f; return 0; case IEEE80211_ACTION_CAT_MESH: - if (act >= N(meshaction_recv_action)) + if (act >= nitems(meshaction_recv_action)) break; meshaction_recv_action[act] = f; return 0; case IEEE80211_ACTION_CAT_VENDOR: - if (act >= N(vendor_recv_action)) + if (act >= nitems(vendor_recv_action)) break; vendor_recv_action[act] = f; return 0; } return EINVAL; -#undef N } void @@ -226,7 +220,6 @@ ieee80211_recv_action(struct ieee80211_node *ni, const struct ieee80211_frame *wh, const uint8_t *frm, const uint8_t *efrm) { -#define N(a) (sizeof(a) / sizeof(a[0])) ieee80211_recv_action_func *f = recv_inval; struct ieee80211vap *vap = ni->ni_vap; const struct ieee80211_action *ia = @@ -234,15 +227,15 @@ ieee80211_recv_action(struct ieee80211_node *ni, switch (ia->ia_category) { case IEEE80211_ACTION_CAT_BA: - if (ia->ia_action < N(ba_recv_action)) + if (ia->ia_action < nitems(ba_recv_action)) f = ba_recv_action[ia->ia_action]; break; case IEEE80211_ACTION_CAT_HT: - if (ia->ia_action < N(ht_recv_action)) + if (ia->ia_action < nitems(ht_recv_action)) f = ht_recv_action[ia->ia_action]; break; case IEEE80211_ACTION_CAT_SELF_PROT: - if (ia->ia_action < N(meshpl_recv_action)) + if (ia->ia_action < nitems(meshpl_recv_action)) f = meshpl_recv_action[ia->ia_action]; break; case IEEE80211_ACTION_CAT_MESH: @@ -255,14 +248,13 @@ ieee80211_recv_action(struct ieee80211_node *ni, vap->iv_stats.is_mesh_nolink++; break; } - if (ia->ia_action < N(meshaction_recv_action)) + if (ia->ia_action < nitems(meshaction_recv_action)) f = meshaction_recv_action[ia->ia_action]; break; case IEEE80211_ACTION_CAT_VENDOR: - if (ia->ia_action < N(vendor_recv_action)) + if (ia->ia_action < nitems(vendor_recv_action)) f = vendor_recv_action[ia->ia_action]; break; } return f(ni, wh, frm, efrm); -#undef N } |