diff options
author | Craig Rodrigues <rodrigc@FreeBSD.org> | 2015-08-29 19:47:20 +0000 |
---|---|---|
committer | Craig Rodrigues <rodrigc@FreeBSD.org> | 2015-08-29 19:47:20 +0000 |
commit | 60caf0c9c2848b8389cc3159bbc219dd408a2496 (patch) | |
tree | 47f014bd4403e669143ff8cf69b5d98b50e13b64 /tools/tools/net80211 | |
parent | 62c37116327ebd7322e455c4693571cbe76e7d96 (diff) | |
download | src-60caf0c9c2848b8389cc3159bbc219dd408a2496.tar.gz src-60caf0c9c2848b8389cc3159bbc219dd408a2496.zip |
- Replace N(a)/N(i)/N(T)/LEN(a)/ARRAY_SIZE(a) with nitems()
- Add missing <err.h> for err() and <sys/sysctl.h> for sysctlbyname()
- NULL -> 0 for 5th parameter of sysctlbyname()
Submitted by: Andriy Voskoboinyk <s3erios@gmail com>
Differential Revision: https://reviews.freebsd.org/D3442
Notes
Notes:
svn path=/head/; revision=287297
Diffstat (limited to 'tools/tools/net80211')
-rw-r--r-- | tools/tools/net80211/wlanstats/main.c | 15 | ||||
-rw-r--r-- | tools/tools/net80211/wlanstats/wlanstats.c | 23 | ||||
-rw-r--r-- | tools/tools/net80211/wlantxtime/wlantxtime.c | 11 |
3 files changed, 20 insertions, 29 deletions
diff --git a/tools/tools/net80211/wlanstats/main.c b/tools/tools/net80211/wlanstats/main.c index 1210fd1322fd..34d939f00e0c 100644 --- a/tools/tools/net80211/wlanstats/main.c +++ b/tools/tools/net80211/wlanstats/main.c @@ -34,17 +34,18 @@ * (default interface is wlan0). */ -#include <sys/types.h> +#include <sys/param.h> #include <sys/socket.h> + #include <net/ethernet.h> #include <net80211/_ieee80211.h> -#include <stdlib.h> -#include <stdio.h> -#include <signal.h> -#include <unistd.h> #include <err.h> +#include <signal.h> +#include <stdio.h> +#include <stdlib.h> #include <strings.h> +#include <unistd.h> #include "wlanstats.h" @@ -65,13 +66,11 @@ static struct { static const char * getfmt(const char *tag) { -#define N(a) (sizeof(a)/sizeof(a[0])) int i; - for (i = 0; i < N(tags); i++) + for (i = 0; i < nitems(tags); i++) if (strcasecmp(tags[i].tag, tag) == 0) return tags[i].fmt; return tag; -#undef N } static int signalled; diff --git a/tools/tools/net80211/wlanstats/wlanstats.c b/tools/tools/net80211/wlanstats/wlanstats.c index 9cee61aee04a..ef834705b6af 100644 --- a/tools/tools/net80211/wlanstats/wlanstats.c +++ b/tools/tools/net80211/wlanstats/wlanstats.c @@ -32,23 +32,25 @@ /* * net80211 statistics class. */ -#include <sys/types.h> + +#include <sys/param.h> #include <sys/file.h> #include <sys/sockio.h> #include <sys/socket.h> + #include <net/if.h> #include <net/if_dl.h> #include <net/if_media.h> #include <net/if_var.h> #include <net/ethernet.h> +#include <err.h> +#include <ifaddrs.h> +#include <signal.h> #include <stdio.h> #include <stdlib.h> -#include <signal.h> #include <string.h> #include <unistd.h> -#include <err.h> -#include <ifaddrs.h> #include "../../../../sys/net80211/ieee80211_ioctl.h" @@ -558,7 +560,6 @@ wlan_update_tot(struct bsdstat *sf) void setreason(char b[], size_t bs, int v) { -#define N(a) (sizeof(a)/sizeof(a[0])) static const char *reasons[] = { [IEEE80211_REASON_UNSPECIFIED] = "unspecified", [IEEE80211_REASON_AUTH_EXPIRE] = "auth expire", @@ -584,17 +585,15 @@ setreason(char b[], size_t bs, int v) [IEEE80211_REASON_802_1X_AUTH_FAILED] = "802.1x auth failed", [IEEE80211_REASON_CIPHER_SUITE_REJECTED]= "cipher suite rejected", }; - if (v < N(reasons) && reasons[v] != NULL) + if (v < nitems(reasons) && reasons[v] != NULL) snprintf(b, bs, "%s (%u)", reasons[v], v); else snprintf(b, bs, "%u", v); -#undef N } void setstatus(char b[], size_t bs, int v) { -#define N(a) (sizeof(a)/sizeof(a[0])) static const char *status[] = { [IEEE80211_STATUS_SUCCESS] = "success", [IEEE80211_STATUS_UNSPECIFIED] = "unspecified", @@ -623,11 +622,10 @@ setstatus(char b[], size_t bs, int v) [IEEE80211_STATUS_INVALID_RSN_IE_CAP] = "invalid rsn ie cap", [IEEE80211_STATUS_CIPHER_SUITE_REJECTED]= "cipher suite rejected", }; - if (v < N(status) && status[v] != NULL) + if (v < nitems(status) && status[v] != NULL) snprintf(b, bs, "%s (%u)", status[v], v); else snprintf(b, bs, "%u", v); -#undef N } static int @@ -999,12 +997,12 @@ BSDSTAT_DEFINE_BOUNCE(wlanstatfoo) struct wlanstatfoo * wlanstats_new(const char *ifname, const char *fmtstring) { -#define N(a) (sizeof(a) / sizeof(a[0])) struct wlanstatfoo_p *wf; wf = calloc(1, sizeof(struct wlanstatfoo_p)); if (wf != NULL) { - bsdstat_init(&wf->base.base, "wlanstats", wlanstats, N(wlanstats)); + bsdstat_init(&wf->base.base, "wlanstats", wlanstats, + nitems(wlanstats)); /* override base methods */ wf->base.base.collect_cur = wlan_collect_cur; wf->base.base.collect_tot = wlan_collect_tot; @@ -1030,5 +1028,4 @@ wlanstats_new(const char *ifname, const char *fmtstring) wf->base.setfmt(&wf->base, fmtstring); } return &wf->base; -#undef N } diff --git a/tools/tools/net80211/wlantxtime/wlantxtime.c b/tools/tools/net80211/wlantxtime/wlantxtime.c index 2db88d417cde..90c5c8f60769 100644 --- a/tools/tools/net80211/wlantxtime/wlantxtime.c +++ b/tools/tools/net80211/wlantxtime/wlantxtime.c @@ -31,7 +31,6 @@ __FBSDID("$FreeBSD$"); */ #include <sys/param.h> -#include <sys/types.h> #include <net/if_llc.h> @@ -228,13 +227,12 @@ static struct ieee80211_rate_table ieee80211_turboa_table = { static void ieee80211_setup_ratetable(struct ieee80211_rate_table *rt) { -#define N(a) (sizeof(a)/sizeof(a[0])) #define WLAN_CTRL_FRAME_SIZE \ (sizeof(struct ieee80211_frame_ack) + IEEE80211_CRC_LEN) int i; - for (i = 0; i < N(rt->rateCodeToIndex); i++) + for (i = 0; i < nitems(rt->rateCodeToIndex); i++) rt->rateCodeToIndex[i] = (uint8_t) -1; for (i = 0; i < rt->rateCount; i++) { uint8_t code = rt->info[i].dot11Rate; @@ -267,14 +265,12 @@ ieee80211_setup_ratetable(struct ieee80211_rate_table *rt) } #undef WLAN_CTRL_FRAME_SIZE -#undef N } /* Setup all rate tables */ static void ieee80211_phy_init(void) { -#define N(arr) (int)(sizeof(arr) / sizeof(arr[0])) static struct ieee80211_rate_table * const ratetables[] = { &ieee80211_half_table, &ieee80211_quarter_table, @@ -287,12 +283,11 @@ ieee80211_phy_init(void) &ieee80211_11g_table, &ieee80211_11b_table }; - int i; + unsigned int i; - for (i = 0; i < N(ratetables); ++i) + for (i = 0; i < nitems(ratetables); ++i) ieee80211_setup_ratetable(ratetables[i]); -#undef N } #define CCK_SIFS_TIME 10 #define CCK_PREAMBLE_BITS 144 |