Remove duplicate use of RV(), LE_* and other macros.

Submitted by:	Andriy Voskoboinyk <s3erios@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3705
This commit is contained in:
adrian 2015-09-22 02:25:52 +00:00
parent b71d742dc5
commit 238d4c1fe4
3 changed files with 10 additions and 21 deletions

View File

@ -434,13 +434,12 @@ mesh_rt_flush_invalid(struct ieee80211vap *vap)
MESH_RT_UNLOCK(ms);
}
#define N(a) (sizeof(a) / sizeof(a[0]))
int
ieee80211_mesh_register_proto_path(const struct ieee80211_mesh_proto_path *mpp)
{
int i, firstempty = -1;
for (i = 0; i < N(mesh_proto_paths); i++) {
for (i = 0; i < nitems(mesh_proto_paths); i++) {
if (strncmp(mpp->mpp_descr, mesh_proto_paths[i].mpp_descr,
IEEE80211_MESH_PROTO_DSZ) == 0)
return EEXIST;
@ -460,7 +459,7 @@ ieee80211_mesh_register_proto_metric(const struct
{
int i, firstempty = -1;
for (i = 0; i < N(mesh_proto_metrics); i++) {
for (i = 0; i < nitems(mesh_proto_metrics); i++) {
if (strncmp(mpm->mpm_descr, mesh_proto_metrics[i].mpm_descr,
IEEE80211_MESH_PROTO_DSZ) == 0)
return EEXIST;
@ -480,7 +479,7 @@ mesh_select_proto_path(struct ieee80211vap *vap, const char *name)
struct ieee80211_mesh_state *ms = vap->iv_mesh;
int i;
for (i = 0; i < N(mesh_proto_paths); i++) {
for (i = 0; i < nitems(mesh_proto_paths); i++) {
if (strcasecmp(mesh_proto_paths[i].mpp_descr, name) == 0) {
ms->ms_ppath = &mesh_proto_paths[i];
return 0;
@ -495,7 +494,7 @@ mesh_select_proto_metric(struct ieee80211vap *vap, const char *name)
struct ieee80211_mesh_state *ms = vap->iv_mesh;
int i;
for (i = 0; i < N(mesh_proto_metrics); i++) {
for (i = 0; i < nitems(mesh_proto_metrics); i++) {
if (strcasecmp(mesh_proto_metrics[i].mpm_descr, name) == 0) {
ms->ms_pmetric = &mesh_proto_metrics[i];
return 0;
@ -503,7 +502,6 @@ mesh_select_proto_metric(struct ieee80211vap *vap, const char *name)
}
return ENOENT;
}
#undef N
static void
mesh_gatemode_setup(struct ieee80211vap *vap)

View File

@ -491,7 +491,6 @@ int
ieee80211_fix_rate(struct ieee80211_node *ni,
struct ieee80211_rateset *nrs, int flags)
{
#define RV(v) ((v) & IEEE80211_RATE_VAL)
struct ieee80211vap *vap = ni->ni_vap;
struct ieee80211com *ic = ni->ni_ic;
int i, j, rix, error;
@ -545,7 +544,8 @@ ieee80211_fix_rate(struct ieee80211_node *ni,
* Sort rates.
*/
for (j = i + 1; j < nrs->rs_nrates; j++) {
if (RV(nrs->rs_rates[i]) > RV(nrs->rs_rates[j])) {
if (IEEE80211_RV(nrs->rs_rates[i]) >
IEEE80211_RV(nrs->rs_rates[j])) {
r = nrs->rs_rates[i];
nrs->rs_rates[i] = nrs->rs_rates[j];
nrs->rs_rates[j] = r;
@ -604,8 +604,7 @@ ieee80211_fix_rate(struct ieee80211_node *ni,
"ucastrate %x\n", __func__, fixedrate, ucastrate, flags);
return badrate | IEEE80211_RATE_BASIC;
} else
return RV(okrate);
#undef RV
return IEEE80211_RV(okrate);
}
/*

View File

@ -737,12 +737,6 @@ sta_cancel(struct ieee80211_scan_state *ss, struct ieee80211vap *vap)
return 0;
}
/* unaligned little endian access */
#define LE_READ_2(p) \
((uint16_t) \
((((const uint8_t *)(p))[0] ) | \
(((const uint8_t *)(p))[1] << 8)))
/*
* Demote any supplied 11g channel to 11b. There should
* always be an 11b channel but we check anyway...
@ -876,7 +870,6 @@ static int
check_rate(struct ieee80211vap *vap, const struct ieee80211_channel *chan,
const struct ieee80211_scan_entry *se)
{
#define RV(v) ((v) & IEEE80211_RATE_VAL)
const struct ieee80211_rateset *srs;
int i, j, nrs, r, okrate, badrate, fixedrate, ucastrate;
const uint8_t *rs;
@ -891,7 +884,7 @@ check_rate(struct ieee80211vap *vap, const struct ieee80211_channel *chan,
fixedrate = IEEE80211_FIXED_RATE_NONE;
again:
for (i = 0; i < nrs; i++) {
r = RV(rs[i]);
r = IEEE80211_RV(rs[i]);
badrate = r;
/*
* Check any fixed rate is included.
@ -902,7 +895,7 @@ again:
* Check against our supported rates.
*/
for (j = 0; j < srs->rs_nrates; j++)
if (r == RV(srs->rs_rates[j])) {
if (r == IEEE80211_RV(srs->rs_rates[j])) {
if (r > okrate) /* NB: track max */
okrate = r;
break;
@ -928,8 +921,7 @@ back:
if (okrate == 0 || ucastrate != fixedrate)
return badrate | IEEE80211_RATE_BASIC;
else
return RV(okrate);
#undef RV
return IEEE80211_RV(okrate);
}
static __inline int