Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 29 Aug 2015 19:47:21 +0000 (UTC)
From:      Craig Rodrigues <rodrigc@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r287297 - in head/tools: regression/lib/msun regression/p1003_1b tools/ath/athaggrstats tools/ath/athdebug tools/ath/athrd tools/ath/athstats tools/ath/common tools/crypto tools/cxgbeto...
Message-ID:  <201508291947.t7TJlLvY085117@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rodrigc
Date: Sat Aug 29 19:47:20 2015
New Revision: 287297
URL: https://svnweb.freebsd.org/changeset/base/287297

Log:
  - 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

Modified:
  head/tools/regression/lib/msun/test-cexp.c
  head/tools/regression/lib/msun/test-csqrt.c
  head/tools/regression/lib/msun/test-invtrig.c
  head/tools/regression/lib/msun/test-trig.c
  head/tools/regression/p1003_1b/main.c
  head/tools/tools/ath/athaggrstats/athaggrstats.c
  head/tools/tools/ath/athaggrstats/main.c
  head/tools/tools/ath/athdebug/athdebug.c
  head/tools/tools/ath/athrd/athrd.c
  head/tools/tools/ath/athstats/athstats.c
  head/tools/tools/ath/athstats/main.c
  head/tools/tools/ath/common/ah_osdep.h
  head/tools/tools/ath/common/dumpregs_5210.c
  head/tools/tools/ath/common/dumpregs_5211.c
  head/tools/tools/ath/common/dumpregs_5212.c
  head/tools/tools/ath/common/dumpregs_5416.c
  head/tools/tools/crypto/cryptostats.c
  head/tools/tools/crypto/cryptotest.c
  head/tools/tools/crypto/hifnstats.c
  head/tools/tools/crypto/ipsecstats.c
  head/tools/tools/crypto/safestats.c
  head/tools/tools/crypto/ubsecstats.c
  head/tools/tools/cxgbetool/cxgbetool.c
  head/tools/tools/mwl/mwldebug/mwldebug.c
  head/tools/tools/mwl/mwlstats/mwlstats.c
  head/tools/tools/net80211/wlanstats/main.c
  head/tools/tools/net80211/wlanstats/wlanstats.c
  head/tools/tools/net80211/wlantxtime/wlantxtime.c
  head/tools/tools/npe/npestats/main.c
  head/tools/tools/npe/npestats/npestats.c

Modified: head/tools/regression/lib/msun/test-cexp.c
==============================================================================
--- head/tools/regression/lib/msun/test-cexp.c	Sat Aug 29 19:41:47 2015	(r287296)
+++ head/tools/regression/lib/msun/test-cexp.c	Sat Aug 29 19:47:20 2015	(r287297)
@@ -31,6 +31,8 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
+#include <sys/param.h>
+
 #include <assert.h>
 #include <complex.h>
 #include <fenv.h>
@@ -40,8 +42,6 @@ __FBSDID("$FreeBSD$");
 
 #include "test-utils.h"
 
-#define	N(i)	(sizeof(i) / sizeof((i)[0]))
-
 #pragma STDC FENV_ACCESS	ON
 #pragma	STDC CX_LIMITED_RANGE	OFF
 
@@ -116,7 +116,7 @@ test_nan()
 
 	/* cexp(x + NaNi) = NaN + NaNi and optionally raises invalid */
 	/* cexp(NaN + yi) = NaN + NaNi and optionally raises invalid (|y|>0) */
-	for (i = 0; i < N(finites); i++) {
+	for (i = 0; i < nitems(finites); i++) {
 		printf("# Run %d..\n", i);
 		testall(CMPLXL(finites[i], NAN), CMPLXL(NAN, NAN),
 			ALL_STD_EXCEPT & ~FE_INVALID, 0, 0);
@@ -148,7 +148,7 @@ test_inf(void)
 	int i;
 
 	/* cexp(x + inf i) = NaN + NaNi and raises invalid */
-	for (i = 0; i < N(finites); i++) {
+	for (i = 0; i < nitems(finites); i++) {
 		printf("# Run %d..\n", i);
 		testall(CMPLXL(finites[i], INFINITY), CMPLXL(NAN, NAN),
 			ALL_STD_EXCEPT, FE_INVALID, 1);
@@ -189,7 +189,7 @@ test_reals(void)
 {
 	int i;
 
-	for (i = 0; i < N(finites); i++) {
+	for (i = 0; i < nitems(finites); i++) {
 		/* XXX could check exceptions more meticulously */
 		printf("# Run %d..\n", i);
 		test(cexp, CMPLXL(finites[i], 0.0),
@@ -212,7 +212,7 @@ test_imaginaries(void)
 {
 	int i;
 
-	for (i = 0; i < N(finites); i++) {
+	for (i = 0; i < nitems(finites); i++) {
 		printf("# Run %d..\n", i);
 		test(cexp, CMPLXL(0.0, finites[i]),
 		     CMPLXL(cos(finites[i]), sin(finites[i])),
@@ -244,7 +244,7 @@ test_small(void)
 	double x, y;
 	int i;
 
-	for (i = 0; i < N(tests); i += 4) {
+	for (i = 0; i < nitems(tests); i += 4) {
 		printf("# Run %d..\n", i);
 		a = tests[i];
 		b = tests[i + 1];

Modified: head/tools/regression/lib/msun/test-csqrt.c
==============================================================================
--- head/tools/regression/lib/msun/test-csqrt.c	Sat Aug 29 19:41:47 2015	(r287296)
+++ head/tools/regression/lib/msun/test-csqrt.c	Sat Aug 29 19:47:20 2015	(r287297)
@@ -31,6 +31,8 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
+#include <sys/param.h>
+
 #include <assert.h>
 #include <complex.h>
 #include <float.h>
@@ -39,8 +41,6 @@ __FBSDID("$FreeBSD$");
 
 #include "test-utils.h"
 
-#define	N(i)	(sizeof(i) / sizeof((i)[0]))
-
 /*
  * This is a test hook that can point to csqrtl(), _csqrt(), or to _csqrtf().
  * The latter two convert to float or double, respectively, and test csqrtf()
@@ -127,8 +127,8 @@ test_finite()
 	double x, y;
 	int i, j;
 
-	for (i = 0; i < N(tests); i += 4) {
-		for (j = 0; j < N(mults); j++) {
+	for (i = 0; i < nitems(tests); i += 4) {
+		for (j = 0; j < nitems(mults); j++) {
 			a = tests[i] * mults[j] * mults[j];
 			b = tests[i + 1] * mults[j] * mults[j];
 			x = tests[i + 2] * mults[j];
@@ -169,7 +169,7 @@ test_infinities()
 
 	int i;
 
-	for (i = 0; i < N(vals); i++) {
+	for (i = 0; i < nitems(vals); i++) {
 		if (isfinite(vals[i])) {
 			assert_equal(t_csqrt(CMPLXL(-INFINITY, vals[i])),
 			    CMPLXL(0.0, copysignl(INFINITY, vals[i])));

Modified: head/tools/regression/lib/msun/test-invtrig.c
==============================================================================
--- head/tools/regression/lib/msun/test-invtrig.c	Sat Aug 29 19:41:47 2015	(r287296)
+++ head/tools/regression/lib/msun/test-invtrig.c	Sat Aug 29 19:47:20 2015	(r287297)
@@ -41,8 +41,6 @@ __FBSDID("$FreeBSD$");
 
 #include "test-utils.h"
 
-#define	LEN(a)		(sizeof(a) / sizeof((a)[0]))
-
 #pragma STDC FENV_ACCESS ON
 
 /*

Modified: head/tools/regression/lib/msun/test-trig.c
==============================================================================
--- head/tools/regression/lib/msun/test-trig.c	Sat Aug 29 19:41:47 2015	(r287296)
+++ head/tools/regression/lib/msun/test-trig.c	Sat Aug 29 19:47:20 2015	(r287297)
@@ -36,6 +36,8 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
+#include <sys/param.h>
+
 #include <assert.h>
 #include <fenv.h>
 #include <float.h>
@@ -44,8 +46,6 @@ __FBSDID("$FreeBSD$");
 
 #include "test-utils.h"
 
-#define	LEN(a)		(sizeof(a) / sizeof((a)[0]))
-
 #pragma STDC FENV_ACCESS ON
 
 /*
@@ -155,7 +155,7 @@ run_reduction_tests(void)
 
 	int i;
 
-	for (i = 0; i < LEN(f_pi_odd); i++) {
+	for (i = 0; i < nitems(f_pi_odd); i++) {
 		assert(fabs(sinf(f_pi_odd[i])) < FLT_EPSILON);
 		assert(cosf(f_pi_odd[i]) == -1.0);
 		assert(fabs(tan(f_pi_odd[i])) < FLT_EPSILON);
@@ -173,7 +173,7 @@ run_reduction_tests(void)
 		assert(fabs(tanf(-f_pi_odd[i] * 2)) < FLT_EPSILON);
 	}
 
-	for (i = 0; i < LEN(d_pi_odd); i++) {
+	for (i = 0; i < nitems(d_pi_odd); i++) {
 		assert(fabs(sin(d_pi_odd[i])) < 2 * DBL_EPSILON);
 		assert(cos(d_pi_odd[i]) == -1.0);
 		assert(fabs(tan(d_pi_odd[i])) < 2 * DBL_EPSILON);
@@ -192,7 +192,7 @@ run_reduction_tests(void)
 	}
 
 #if LDBL_MANT_DIG > 53
-	for (i = 0; i < LEN(ld_pi_odd); i++) {
+	for (i = 0; i < nitems(ld_pi_odd); i++) {
 		assert(fabsl(sinl(ld_pi_odd[i])) < LDBL_EPSILON);
 		assert(cosl(ld_pi_odd[i]) == -1.0);
 		assert(fabsl(tanl(ld_pi_odd[i])) < LDBL_EPSILON);

Modified: head/tools/regression/p1003_1b/main.c
==============================================================================
--- head/tools/regression/p1003_1b/main.c	Sat Aug 29 19:41:47 2015	(r287296)
+++ head/tools/regression/p1003_1b/main.c	Sat Aug 29 19:47:20 2015	(r287297)
@@ -1,4 +1,7 @@
 /* $FreeBSD$ */
+
+#include <sys/param.h>
+
 #include <stdio.h>
 #include <string.h>
 
@@ -20,8 +23,6 @@ static struct {
 	{ "yield", yield, 1 },
 };
 
-#define N(T) (sizeof (T)/ sizeof(T[0]))
-
 static int usage(int argc, char *argv[])
 {
 	int i;
@@ -47,14 +48,14 @@ int main(int argc, char *argv[])
 			" (my notes say \"because things detach\");\n"
 			"meanwhile do these individual tests and look"
 			" for a non-zero exit code:\n");
-		for (i = 0; i < N(tab); i++)
+		for (i = 0; i < nitems(tab); i++)
 			if (tab[i].works)
 				fprintf(stderr, "p1003_1b %s\n", tab[i].t);
 		return -1;
 #else
 		{
 			int r;
-			for (i = 0; i < N(tab); i++) {
+			for (i = 0; i < nitems(tab); i++) {
 				if (tab[i].works) {
 					if ( (r =
 					(*tab[i].f)(argc - 1, argv + 1)) ) {
@@ -70,7 +71,7 @@ int main(int argc, char *argv[])
 	}
 	
 	if (argc > 1) {
-		for (i = 0; i < N(tab); i++)
+		for (i = 0; i < nitems(tab); i++)
 			if (strcmp(tab[i].t, argv[1]) == 0)
 				return (*tab[i].f)(argc - 1, argv + 1);
 	}

Modified: head/tools/tools/ath/athaggrstats/athaggrstats.c
==============================================================================
--- head/tools/tools/ath/athaggrstats/athaggrstats.c	Sat Aug 29 19:41:47 2015	(r287296)
+++ head/tools/tools/ath/athaggrstats/athaggrstats.c	Sat Aug 29 19:47:20 2015	(r287297)
@@ -29,6 +29,8 @@
  * $FreeBSD$
  */
 
+#include <sys/param.h>
+
 #include "opt_ah.h"
 
 /*
@@ -368,13 +370,12 @@ BSDSTAT_DEFINE_BOUNCE(athaggrstatfoo)
 struct athaggrstatfoo *
 athaggrstats_new(const char *ifname, const char *fmtstring)
 {
-#define	N(a)	(sizeof(a) / sizeof(a[0]))
 	struct athaggrstatfoo_p *wf;
 
 	wf = calloc(1, sizeof(struct athaggrstatfoo_p));
 	if (wf != NULL) {
 		bsdstat_init(&wf->base.base, "athaggrstats",
-		    athaggrstats, N(athaggrstats));
+		    athaggrstats, nitems(athaggrstats));
 		/* override base methods */
 		wf->base.base.collect_cur = ath_collect_cur;
 		wf->base.base.collect_tot = ath_collect_tot;
@@ -400,5 +401,4 @@ athaggrstats_new(const char *ifname, con
 		wf->base.setfmt(&wf->base, fmtstring);
 	}
 	return &wf->base;
-#undef N
 }

Modified: head/tools/tools/ath/athaggrstats/main.c
==============================================================================
--- head/tools/tools/ath/athaggrstats/main.c	Sat Aug 29 19:41:47 2015	(r287296)
+++ head/tools/tools/ath/athaggrstats/main.c	Sat Aug 29 19:47:20 2015	(r287297)
@@ -42,12 +42,14 @@
  * print a list of all possible statistics for use with the -o option.
  */
 
+#include <sys/param.h>
+
+#include <err.h>
+#include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <signal.h>
-#include <unistd.h>
 #include <string.h>
-#include <err.h>
+#include <unistd.h>
 
 #include "athaggrstats.h"
 
@@ -63,13 +65,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;

Modified: head/tools/tools/ath/athdebug/athdebug.c
==============================================================================
--- head/tools/tools/ath/athdebug/athdebug.c	Sat Aug 29 19:41:47 2015	(r287296)
+++ head/tools/tools/ath/athdebug/athdebug.c	Sat Aug 29 19:47:20 2015	(r287297)
@@ -33,21 +33,20 @@
  * athdebug [-i interface] flags
  * (default interface is ath0).
  */
-#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 <stdio.h>
 #include <ctype.h>
+#include <err.h>
 #include <getopt.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <strings.h>
-#include <err.h>
-
-#define	N(a)	(sizeof(a)/sizeof(a[0]))
 
 const char *progname;
 
@@ -115,7 +114,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;
@@ -126,7 +125,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 "???";
@@ -139,7 +138,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);
 }
@@ -221,7 +220,7 @@ main(int argc, char *argv[])
 	} else
 		printf("%s: 0x%llx", oid, (long long) 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 = ",";

Modified: head/tools/tools/ath/athrd/athrd.c
==============================================================================
--- head/tools/tools/ath/athrd/athrd.c	Sat Aug 29 19:41:47 2015	(r287296)
+++ head/tools/tools/ath/athrd/athrd.c	Sat Aug 29 19:47:20 2015	(r287297)
@@ -32,18 +32,20 @@
 
 #include "ah.h"
 
+#include <sys/param.h>
+
 #include <net80211/_ieee80211.h>
 #include <net80211/ieee80211_regdomain.h>
 
 #include "ah_internal.h"
 #include "ah_eeprom_v3.h"		/* XXX */
 
+#include <ctype.h>
+#include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <stdarg.h>
 #include <string.h>
 #include <unistd.h>
-#include <ctype.h>
 
 int		ath_hal_debug = 0;
 HAL_CTRY_CODE	cc = CTRY_DEFAULT;
@@ -535,43 +537,37 @@ static struct {
 static HAL_BOOL
 rdlookup(const char *name, HAL_REG_DOMAIN *rd)
 {
-#define	N(a)	(sizeof(a)/sizeof(a[0]))
 	int i;
 
-	for (i = 0; i < N(domains); i++)
+	for (i = 0; i < nitems(domains); i++)
 		if (strcasecmp(domains[i].name, name) == 0) {
 			*rd = domains[i].rd;
 			return AH_TRUE;
 		}
 	return AH_FALSE;
-#undef N
 }
 
 static const char *
 getrdname(HAL_REG_DOMAIN rd)
 {
-#define	N(a)	(sizeof(a)/sizeof(a[0]))
 	int i;
 
-	for (i = 0; i < N(domains); i++)
+	for (i = 0; i < nitems(domains); i++)
 		if (domains[i].rd == rd)
 			return domains[i].name;
 	return NULL;
-#undef N
 }
 
 static void
 rdlist()
 {
-#define	N(a)	(sizeof(a)/sizeof(a[0]))
 	int i;
 
 	printf("\nRegulatory domains:\n\n");
-	for (i = 0; i < N(domains); i++)
+	for (i = 0; i < nitems(domains); i++)
 		printf("%-15s%s", domains[i].name,
 			((i+1)%5) == 0 ? "\n" : "");
 	printf("\n");
-#undef N
 }
 
 typedef struct {
@@ -728,10 +724,9 @@ static COUNTRY_CODE_TO_ENUM_RD allCountr
 static HAL_BOOL
 cclookup(const char *name, HAL_REG_DOMAIN *rd, HAL_CTRY_CODE *cc)
 {
-#define	N(a)	(sizeof(a)/sizeof(a[0]))
 	int i;
 
-	for (i = 0; i < N(allCountries); i++)
+	for (i = 0; i < nitems(allCountries); i++)
 		if (strcasecmp(allCountries[i].isoName, name) == 0 ||
 		    strcasecmp(allCountries[i].name, name) == 0) {
 			*rd = allCountries[i].regDmnEnum;
@@ -739,49 +734,42 @@ cclookup(const char *name, HAL_REG_DOMAI
 			return AH_TRUE;
 		}
 	return AH_FALSE;
-#undef N
 }
 
 static const char *
 getccname(HAL_CTRY_CODE cc)
 {
-#define	N(a)	(sizeof(a)/sizeof(a[0]))
 	int i;
 
-	for (i = 0; i < N(allCountries); i++)
+	for (i = 0; i < nitems(allCountries); i++)
 		if (allCountries[i].countryCode == cc)
 			return allCountries[i].name;
 	return NULL;
-#undef N
 }
 
 static const char *
 getccisoname(HAL_CTRY_CODE cc)
 {
-#define	N(a)	(sizeof(a)/sizeof(a[0]))
 	int i;
 
-	for (i = 0; i < N(allCountries); i++)
+	for (i = 0; i < nitems(allCountries); i++)
 		if (allCountries[i].countryCode == cc)
 			return allCountries[i].isoName;
 	return NULL;
-#undef N
 }
 
 static void
 cclist()
 {
-#define	N(a)	(sizeof(a)/sizeof(a[0]))
 	int i;
 
 	printf("\nCountry codes:\n");
-	for (i = 0; i < N(allCountries); i++)
+	for (i = 0; i < nitems(allCountries); i++)
 		printf("%2s %-15.15s%s",
 			allCountries[i].isoName,
 			allCountries[i].name,
 			((i+1)%4) == 0 ? "\n" : " ");
 	printf("\n");
-#undef N
 }
 
 static HAL_BOOL

Modified: head/tools/tools/ath/athstats/athstats.c
==============================================================================
--- head/tools/tools/ath/athstats/athstats.c	Sat Aug 29 19:41:47 2015	(r287296)
+++ head/tools/tools/ath/athstats/athstats.c	Sat Aug 29 19:47:20 2015	(r287297)
@@ -34,20 +34,22 @@
 /*
  * ath 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_media.h>
 #include <net/if_var.h>
 
+#include <err.h>
+#include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <signal.h>
 #include <string.h>
 #include <unistd.h>
-#include <err.h>
 
 #include "ah.h"
 #include "ah_desc.h"
@@ -1058,12 +1060,12 @@ BSDSTAT_DEFINE_BOUNCE(athstatfoo)
 struct athstatfoo *
 athstats_new(const char *ifname, const char *fmtstring)
 {
-#define	N(a)	(sizeof(a) / sizeof(a[0]))
 	struct athstatfoo_p *wf;
 
 	wf = calloc(1, sizeof(struct athstatfoo_p));
 	if (wf != NULL) {
-		bsdstat_init(&wf->base.base, "athstats", athstats, N(athstats));
+		bsdstat_init(&wf->base.base, "athstats", athstats,
+		    nitems(athstats));
 		/* override base methods */
 		wf->base.base.collect_cur = ath_collect_cur;
 		wf->base.base.collect_tot = ath_collect_tot;
@@ -1089,5 +1091,4 @@ athstats_new(const char *ifname, const c
 		wf->base.setfmt(&wf->base, fmtstring);
 	}
 	return &wf->base;
-#undef N
 }

Modified: head/tools/tools/ath/athstats/main.c
==============================================================================
--- head/tools/tools/ath/athstats/main.c	Sat Aug 29 19:41:47 2015	(r287296)
+++ head/tools/tools/ath/athstats/main.c	Sat Aug 29 19:47:20 2015	(r287297)
@@ -41,12 +41,14 @@
  * print a list of all possible statistics for use with the -o option.
  */
 
+#include <sys/param.h>
+
+#include <err.h>
+#include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <signal.h>
-#include <unistd.h>
 #include <string.h>
-#include <err.h>
+#include <unistd.h>
 
 #include "athstats.h"
 
@@ -68,13 +70,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;

Modified: head/tools/tools/ath/common/ah_osdep.h
==============================================================================
--- head/tools/tools/ath/common/ah_osdep.h	Sat Aug 29 19:41:47 2015	(r287296)
+++ head/tools/tools/ath/common/ah_osdep.h	Sat Aug 29 19:47:20 2015	(r287297)
@@ -35,6 +35,8 @@
  */
 #include <sys/param.h>
 
+#include <strings.h>
+
 /*
  * Bus i/o type definitions.
  */

Modified: head/tools/tools/ath/common/dumpregs_5210.c
==============================================================================
--- head/tools/tools/ath/common/dumpregs_5210.c	Sat Aug 29 19:41:47 2015	(r287296)
+++ head/tools/tools/ath/common/dumpregs_5210.c	Sat Aug 29 19:47:20 2015	(r287297)
@@ -28,6 +28,9 @@
  *
  * $FreeBSD$
  */
+
+#include <sys/param.h>
+
 #include "diag.h"
 
 #include "ah.h"
@@ -37,8 +40,6 @@
 
 #include "dumpregs.h"
 
-#define	N(a)	(sizeof(a) / sizeof(a[0]))
-
 static struct dumpreg ar5210regs[] = {
     DEFBASIC(AR_TXDP0,		"TXDP0"),
     DEFBASIC(AR_TXDP1,		"TXDP1"),
@@ -118,7 +119,7 @@ static __constructor void
 ar5210_ctor(void)
 {
 #define	MAC5210	SREV(1,0), SREV(2,0)
-	register_regs(ar5210regs, N(ar5210regs), MAC5210, PHYANY);
+	register_regs(ar5210regs, nitems(ar5210regs), MAC5210, PHYANY);
 	register_keycache(64, MAC5210, PHYANY);
 
 	register_range(0x9800, 0x9840, DUMP_BASEBAND, MAC5210, PHYANY);

Modified: head/tools/tools/ath/common/dumpregs_5211.c
==============================================================================
--- head/tools/tools/ath/common/dumpregs_5211.c	Sat Aug 29 19:41:47 2015	(r287296)
+++ head/tools/tools/ath/common/dumpregs_5211.c	Sat Aug 29 19:47:20 2015	(r287297)
@@ -28,6 +28,9 @@
  *
  * $FreeBSD$
  */
+
+#include <sys/param.h>
+
 #include "diag.h"
 
 #include "ah.h"
@@ -37,8 +40,6 @@
 
 #include "dumpregs.h"
 
-#define	N(a)	(sizeof(a) / sizeof(a[0]))
-
 static struct dumpreg ar5211regs[] = {
     DEFBASICfmt(AR_CR,		"CR",		AR_CR_BITS),
     DEFBASIC(AR_RXDP,		"RXDP"),
@@ -284,7 +285,7 @@ static __constructor void
 ar5211_ctor(void)
 {
 #define	MAC5211	SREV(2,0), SREV(4,5)
-	register_regs(ar5211regs, N(ar5211regs), MAC5211, PHYANY);
+	register_regs(ar5211regs, nitems(ar5211regs), MAC5211, PHYANY);
 	register_keycache(128, MAC5211, PHYANY);
 
 	register_range(0x9800, 0x987c, DUMP_BASEBAND, MAC5211, PHYANY);

Modified: head/tools/tools/ath/common/dumpregs_5212.c
==============================================================================
--- head/tools/tools/ath/common/dumpregs_5212.c	Sat Aug 29 19:41:47 2015	(r287296)
+++ head/tools/tools/ath/common/dumpregs_5212.c	Sat Aug 29 19:47:20 2015	(r287297)
@@ -28,6 +28,9 @@
  *
  * $FreeBSD$
  */
+
+#include <sys/param.h>
+
 #include "diag.h"
 
 #include "ah.h"
@@ -37,8 +40,6 @@
 
 #include "dumpregs.h"
 
-#define	N(a)	(sizeof(a) / sizeof(a[0]))
-
 #define	MAC5212	SREV(4,5), SREV(16,0)
 #define	MAC5213	SREV(5,9), SREV(16,0)
 
@@ -421,7 +422,7 @@ static struct dumpreg ar5212regs[] = {
 static __constructor void
 ar5212_ctor(void)
 {
-	register_regs(ar5212regs, N(ar5212regs), MAC5212, PHYANY);
+	register_regs(ar5212regs, nitems(ar5212regs), MAC5212, PHYANY);
 	register_keycache(128, MAC5212, PHYANY);
 
 	register_range(0x9800, 0x987c, DUMP_BASEBAND, MAC5212, PHYANY);

Modified: head/tools/tools/ath/common/dumpregs_5416.c
==============================================================================
--- head/tools/tools/ath/common/dumpregs_5416.c	Sat Aug 29 19:41:47 2015	(r287296)
+++ head/tools/tools/ath/common/dumpregs_5416.c	Sat Aug 29 19:47:20 2015	(r287297)
@@ -28,6 +28,9 @@
  *
  * $FreeBSD$
  */
+
+#include <sys/param.h>
+
 #include "diag.h"
 
 #include "ah.h"
@@ -37,8 +40,6 @@
 
 #include "dumpregs.h"
 
-#define	N(a)	(sizeof(a) / sizeof(a[0]))
-
 #define	MAC5416	SREV(13,8), SREV(0xffff,0xffff)	/* XXX */
 
 static struct dumpreg ar5416regs[] = {
@@ -406,7 +407,7 @@ static struct dumpreg ar5416regs[] = {
 static __constructor void
 ar5416_ctor(void)
 {
-	register_regs(ar5416regs, N(ar5416regs), MAC5416, PHYANY);
+	register_regs(ar5416regs, nitems(ar5416regs), MAC5416, PHYANY);
 	register_keycache(128, MAC5416, PHYANY);
 
 	register_range(0x9800, 0x987c, DUMP_BASEBAND, MAC5416, PHYANY);

Modified: head/tools/tools/crypto/cryptostats.c
==============================================================================
--- head/tools/tools/crypto/cryptostats.c	Sat Aug 29 19:41:47 2015	(r287296)
+++ head/tools/tools/crypto/cryptostats.c	Sat Aug 29 19:47:20 2015	(r287297)
@@ -30,15 +30,19 @@
  * Little program to dump the crypto statistics block and, optionally,
  * zero all the stats or just the timing stuff.
  */
-#include <stdio.h>
-#include <stdlib.h>
-#include <strings.h>
 
 #include <sys/types.h>
 #include <sys/sysctl.h>
 #include <sys/time.h>
+
 #include <crypto/cryptodev.h>
 
+#include <err.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+
 static void
 printt(const char* tag, struct cryptotstat *ts)
 {

Modified: head/tools/tools/crypto/cryptotest.c
==============================================================================
--- head/tools/tools/crypto/cryptotest.c	Sat Aug 29 19:41:47 2015	(r287296)
+++ head/tools/tools/crypto/cryptotest.c	Sat Aug 29 19:47:20 2015	(r287297)
@@ -82,25 +82,25 @@
  * Expect ~400 Mb/s for a Broadcom 582x for 8K buffers on a reasonable CPU
  * (64-bit PCI helps).  Hifn 7811 parts top out at ~110 Mb/s.
  */
-#include <sys/types.h>
+
 #include <sys/param.h>
-#include <sys/time.h>
 #include <sys/ioctl.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <sys/wait.h>
 #include <sys/mman.h>
+#include <sys/sysctl.h>
+#include <sys/time.h>
+#include <sys/wait.h>
+
+#include <err.h>
+#include <fcntl.h>
 #include <paths.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
 
-#include <sys/sysctl.h>
-#include <sys/time.h>
 #include <crypto/cryptodev.h>
 
 #define	CHUNK	64	/* how much to display */
-#define	N(a)		(sizeof (a) / sizeof (a[0]))
 #define	streq(a,b)	(strcasecmp(a,b) == 0)
 
 void	hexdump(char *, int);
@@ -164,7 +164,7 @@ getalgbycode(int cipher)
 {
 	int i;
 
-	for (i = 0; i < N(algorithms); i++)
+	for (i = 0; i < nitems(algorithms); i++)
 		if (cipher == algorithms[i].code)
 			return &algorithms[i];
 	return NULL;
@@ -175,7 +175,7 @@ getalgbyname(const char* name)
 {
 	int i;
 
-	for (i = 0; i < N(algorithms); i++)
+	for (i = 0; i < nitems(algorithms); i++)
 		if (streq(name, algorithms[i].name))
 			return &algorithms[i];
 	return NULL;
@@ -239,7 +239,7 @@ rdigit(void)
 		0x10,0x54,0x11,0x48,0x45,0x12,0x4f,0x13,0x49,0x53,0x14,0x41,
 		0x15,0x16,0x4e,0x55,0x54,0x17,0x18,0x4a,0x4f,0x42,0x19,0x01
 	};
-	return 0x20+a[random()%N(a)];
+	return 0x20+a[random()%nitems(a)];
 }
 
 static void
@@ -298,7 +298,7 @@ runtest(struct alg *alg, int count, int 
 	for (i = 0; i < size; i++)
 		cleartext[i] = rdigit();
 	memcpy(originaltext, cleartext, size);
-	for (i = 0; i < N(iv); i++)
+	for (i = 0; i < nitems(iv); i++)
 		iv[i] = rdigit();
 
 	if (verbose) {
@@ -569,7 +569,7 @@ main(int argc, char **argv)
 		count = atoi(argv[0]);
 	while (argc > 1) {
 		int s = atoi(argv[1]);
-		if (nsizes < N(sizes)) {
+		if (nsizes < nitems(sizes)) {
 			sizes[nsizes++] = s;
 		} else {
 			printf("Too many sizes, ignoring %u\n", s);
@@ -590,7 +590,7 @@ main(int argc, char **argv)
 	}
 
 	if (testall) {
-		for (i = 0; i < N(algorithms); i++) {
+		for (i = 0; i < nitems(algorithms); i++) {
 			int j;
 			alg = &algorithms[i];
 			for (j = 0; j < nsizes; j++)

Modified: head/tools/tools/crypto/hifnstats.c
==============================================================================
--- head/tools/tools/crypto/hifnstats.c	Sat Aug 29 19:41:47 2015	(r287296)
+++ head/tools/tools/crypto/hifnstats.c	Sat Aug 29 19:47:20 2015	(r287297)
@@ -25,8 +25,13 @@
  *
  * $FreeBSD$
  */
-#include <stdio.h>
+
 #include <sys/types.h>
+#include <sys/sysctl.h>
+
+#include <err.h>
+#include <stdio.h>
+
 #include "../../../sys/dev/hifn/hifn7751var.h"
 
 /*
@@ -39,7 +44,7 @@ main(int argc, char *argv[])
 	size_t slen;
 
 	slen = sizeof (stats);
-	if (sysctlbyname("hw.hifn.stats", &stats, &slen, NULL, NULL) < 0)
+	if (sysctlbyname("hw.hifn.stats", &stats, &slen, NULL, 0) < 0)
 		err(1, "kern.hifn.stats");
 
 	printf("input %llu bytes %u packets\n",

Modified: head/tools/tools/crypto/ipsecstats.c
==============================================================================
--- head/tools/tools/crypto/ipsecstats.c	Sat Aug 29 19:41:47 2015	(r287296)
+++ head/tools/tools/crypto/ipsecstats.c	Sat Aug 29 19:47:20 2015	(r287297)
@@ -25,10 +25,15 @@
  *
  * $FreeBSD$
  */
-#include <sys/types.h>
+
+#include <sys/param.h>
+#include <sys/sysctl.h>
+
 #include <netipsec/ipsec.h>
 #include <netipsec/ah_var.h>
 #include <netipsec/esp_var.h>
+
+#include <err.h>
 #include <stdint.h>
 #include <stdio.h>
 
@@ -62,7 +67,6 @@ static const struct alg ipcompalgs[] = {
 	{ SADB_X_CALG_DEFLATE,	"deflate", },
 	{ SADB_X_CALG_LZS,	"lzs", },
 };
-#define	N(a)	(sizeof(a)/sizeof(a[0]))
 
 static const char*
 algname(int a, const struct alg algs[], int nalgs)
@@ -91,13 +95,13 @@ main(int argc, char *argv[])
 	int i;
 
 	slen = sizeof (ips);
-	if (sysctlbyname("net.inet.ipsec.ipsecstats", &ips, &slen, NULL, NULL) < 0)
+	if (sysctlbyname("net.inet.ipsec.ipsecstats", &ips, &slen, NULL, 0) < 0)
 		err(1, "net.inet.ipsec.ipsecstats");
 	slen = sizeof (ahs);
-	if (sysctlbyname("net.inet.ah.stats", &ahs, &slen, NULL, NULL) < 0)
+	if (sysctlbyname("net.inet.ah.stats", &ahs, &slen, NULL, 0) < 0)
 		err(1, "net.inet.ah.stats");
 	slen = sizeof (esps);
-	if (sysctlbyname("net.inet.esp.stats", &esps, &slen, NULL, NULL) < 0)
+	if (sysctlbyname("net.inet.esp.stats", &esps, &slen, NULL, 0) < 0)
 		err(1, "net.inet.esp.stats");
 
 #define	AHSTAT(x,fmt)	if (x) printf("ah " fmt ": %ju\n", (uintmax_t)x)
@@ -121,7 +125,7 @@ main(int argc, char *argv[])
 	for (i = 0; i < AH_ALG_MAX; i++)
 		if (ahs.ahs_hist[i])
 			printf("ah packets with %s: %ju\n"
-				, algname(i, aalgs, N(aalgs))
+				, algname(i, aalgs, nitems(aalgs))
 				, (uintmax_t)ahs.ahs_hist[i]
 			);
 	AHSTAT(ahs.ahs_ibytes, "bytes received");
@@ -150,7 +154,7 @@ main(int argc, char *argv[])
 	for (i = 0; i < ESP_ALG_MAX; i++)
 		if (esps.esps_hist[i])
 			printf("esp packets with %s: %ju\n"
-				, algname(i, espalgs, N(espalgs))
+				, algname(i, espalgs, nitems(espalgs))
 				, (uintmax_t)esps.esps_hist[i]
 			);
 	ESPSTAT(esps.esps_ibytes, "bytes received");

Modified: head/tools/tools/crypto/safestats.c
==============================================================================
--- head/tools/tools/crypto/safestats.c	Sat Aug 29 19:41:47 2015	(r287296)
+++ head/tools/tools/crypto/safestats.c	Sat Aug 29 19:47:20 2015	(r287297)
@@ -25,8 +25,13 @@
  *
  * $FreeBSD$
  */
-#include <stdio.h>
+
 #include <sys/types.h>
+#include <sys/sysctl.h>
+
+#include <err.h>
+#include <stdio.h>
+
 #include "../../../sys/dev/safe/safevar.h"
 
 /*
@@ -39,7 +44,7 @@ main(int argc, char *argv[])
 	size_t slen;
 
 	slen = sizeof (stats);
-	if (sysctlbyname("hw.safe.stats", &stats, &slen, NULL, NULL) < 0)
+	if (sysctlbyname("hw.safe.stats", &stats, &slen, NULL, 0) < 0)
 		err(1, "hw.safe.stats");
 
 	printf("input %llu bytes %u packets\n",

Modified: head/tools/tools/crypto/ubsecstats.c
==============================================================================
--- head/tools/tools/crypto/ubsecstats.c	Sat Aug 29 19:41:47 2015	(r287296)
+++ head/tools/tools/crypto/ubsecstats.c	Sat Aug 29 19:47:20 2015	(r287297)
@@ -25,8 +25,13 @@
  *
  * $FreeBSD$
  */
-#include <stdio.h>
+
 #include <sys/types.h>
+#include <sys/sysctl.h>
+
+#include <err.h>
+#include <stdio.h>
+
 #include "../../../sys/dev/ubsec/ubsecvar.h"
 
 /*
@@ -39,7 +44,7 @@ main(int argc, char *argv[])
 	size_t slen;
 
 	slen = sizeof (stats);
-	if (sysctlbyname("hw.ubsec.stats", &stats, &slen, NULL, NULL) < 0)
+	if (sysctlbyname("hw.ubsec.stats", &stats, &slen, NULL, 0) < 0)
 		err(1, "kern.ubsec_stats");
 
 	printf("input %llu bytes %u packets\n",

Modified: head/tools/tools/cxgbetool/cxgbetool.c
==============================================================================
--- head/tools/tools/cxgbetool/cxgbetool.c	Sat Aug 29 19:41:47 2015	(r287296)
+++ head/tools/tools/cxgbetool/cxgbetool.c	Sat Aug 29 19:47:20 2015	(r287297)
@@ -28,29 +28,30 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-#include <stdint.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <ctype.h>
-#include <errno.h>
-#include <err.h>
-#include <fcntl.h>
-#include <string.h>
-#include <stdio.h>
+#include <sys/param.h>
 #include <sys/ioctl.h>
-#include <limits.h>
 #include <sys/mman.h>
-#include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/stat.h>
-#include <net/ethernet.h>
-#include <netinet/in.h>
+
 #include <arpa/inet.h>
+#include <net/ethernet.h>
 #include <net/sff8472.h>
+#include <netinet/in.h>
+
+#include <ctype.h>
+#include <err.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
 
 #include "t4_ioctl.h"
 
-#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
 #define in_range(val, lo, hi) ( val < 0 || (val <= hi && val >= lo))
 #define	max(x, y) ((x) > (y) ? (x) : (y))
 
@@ -345,7 +346,7 @@ dump_regs_t4(int argc, const char *argv[
 		T4_MODREGS(xgmac)
 	};
 
-	return dump_regs_table(argc, argv, regs, t4_mod, ARRAY_SIZE(t4_mod));
+	return dump_regs_table(argc, argv, regs, t4_mod, nitems(t4_mod));

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201508291947.t7TJlLvY085117>