aboutsummaryrefslogtreecommitdiff
path: root/tools/tools/mwl
diff options
context:
space:
mode:
authorCraig Rodrigues <rodrigc@FreeBSD.org>2015-08-29 19:47:20 +0000
committerCraig Rodrigues <rodrigc@FreeBSD.org>2015-08-29 19:47:20 +0000
commit60caf0c9c2848b8389cc3159bbc219dd408a2496 (patch)
tree47f014bd4403e669143ff8cf69b5d98b50e13b64 /tools/tools/mwl
parent62c37116327ebd7322e455c4693571cbe76e7d96 (diff)
downloadsrc-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/mwl')
-rw-r--r--tools/tools/mwl/mwldebug/mwldebug.c18
-rw-r--r--tools/tools/mwl/mwlstats/mwlstats.c17
2 files changed, 17 insertions, 18 deletions
diff --git a/tools/tools/mwl/mwldebug/mwldebug.c b/tools/tools/mwl/mwldebug/mwldebug.c
index 4e97b6d8cdcc..4080053534ca 100644
--- a/tools/tools/mwl/mwldebug/mwldebug.c
+++ b/tools/tools/mwl/mwldebug/mwldebug.c
@@ -33,21 +33,19 @@
* mwldebug [-i interface] flags
* (default interface is mwl0).
*/
-#include <sys/types.h>
+
#include <sys/param.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/sysctl.h>
-#include <stdlib.h>
-#include <stdio.h>
#include <ctype.h>
+#include <err.h>
#include <getopt.h>
+#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
-#include <err.h>
-
-#define N(a) (sizeof(a)/sizeof(a[0]))
const char *progname;
@@ -100,7 +98,7 @@ getflag(const char *name, int len)
{
int i;
- for (i = 0; i < N(flags); i++)
+ for (i = 0; i < nitems(flags); i++)
if (strncasecmp(flags[i].name, name, len) == 0)
return flags[i].bit;
return 0;
@@ -112,7 +110,7 @@ getflagname(u_int flag)
{
int i;
- for (i = 0; i < N(flags); i++)
+ for (i = 0; i < nitems(flags); i++)
if (flags[i].bit == flag)
return flags[i].name;
return "???";
@@ -126,7 +124,7 @@ usage(void)
fprintf(stderr, "usage: %s [-i device] [flags]\n", progname);
fprintf(stderr, "where flags are:\n");
- for (i = 0; i < N(flags); i++)
+ for (i = 0; i < nitems(flags); i++)
printf("%s\n", flags[i].name);
exit(-1);
}
@@ -202,7 +200,7 @@ main(int argc, char *argv[])
} else
printf("%s: 0x%x", oid, debug);
sep = "<";
- for (i = 0; i < N(flags); i++)
+ for (i = 0; i < nitems(flags); i++)
if (debug & flags[i].bit) {
printf("%s%s", sep, flags[i].name);
sep = ",";
diff --git a/tools/tools/mwl/mwlstats/mwlstats.c b/tools/tools/mwl/mwlstats/mwlstats.c
index 50eb94f62916..00d0c75a2376 100644
--- a/tools/tools/mwl/mwlstats/mwlstats.c
+++ b/tools/tools/mwl/mwlstats/mwlstats.c
@@ -32,20 +32,22 @@
/*
* mwl statistics class.
*/
-#include <sys/types.h>
+
+#include <sys/param.h>
#include <sys/file.h>
+#include <sys/ioctl.h>
#include <sys/sockio.h>
#include <sys/socket.h>
-#include <sys/ioctl.h>
+
#include <net/if.h>
#include <net/if_media.h>
-#include <stdlib.h>
-#include <stdio.h>
+#include <err.h>
#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <err.h>
#include "../../../../sys/net80211/ieee80211_ioctl.h"
#include "../../../../sys/net80211/ieee80211_radiotap.h"
@@ -544,12 +546,12 @@ BSDSTAT_DEFINE_BOUNCE(mwlstatfoo)
struct mwlstatfoo *
mwlstats_new(const char *ifname, const char *fmtstring)
{
-#define N(a) (sizeof(a) / sizeof(a[0]))
struct mwlstatfoo_p *wf;
wf = calloc(1, sizeof(struct mwlstatfoo_p));
if (wf != NULL) {
- bsdstat_init(&wf->base.base, "mwlstats", mwlstats, N(mwlstats));
+ bsdstat_init(&wf->base.base, "mwlstats", mwlstats,
+ nitems(mwlstats));
/* override base methods */
wf->base.base.collect_cur = mwl_collect_cur;
wf->base.base.collect_tot = mwl_collect_tot;
@@ -574,5 +576,4 @@ mwlstats_new(const char *ifname, const char *fmtstring)
wf->base.setfmt(&wf->base, fmtstring);
}
return &wf->base;
-#undef N
}