Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F149407600
D3442.id8090.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
31 KB
Referenced Files
None
Subscribers
None
D3442.id8090.diff
View Options
Index: tools/regression/lib/msun/test-cexp.c
===================================================================
--- tools/regression/lib/msun/test-cexp.c
+++ tools/regression/lib/msun/test-cexp.c
@@ -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 @@
#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 @@
/* 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 @@
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 @@
{
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 @@
{
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 @@
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];
Index: tools/regression/lib/msun/test-csqrt.c
===================================================================
--- tools/regression/lib/msun/test-csqrt.c
+++ tools/regression/lib/msun/test-csqrt.c
@@ -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 @@
#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 @@
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 @@
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])));
Index: tools/regression/lib/msun/test-invtrig.c
===================================================================
--- tools/regression/lib/msun/test-invtrig.c
+++ tools/regression/lib/msun/test-invtrig.c
@@ -41,8 +41,6 @@
#include "test-utils.h"
-#define LEN(a) (sizeof(a) / sizeof((a)[0]))
-
#pragma STDC FENV_ACCESS ON
/*
Index: tools/regression/lib/msun/test-trig.c
===================================================================
--- tools/regression/lib/msun/test-trig.c
+++ tools/regression/lib/msun/test-trig.c
@@ -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 @@
#include "test-utils.h"
-#define LEN(a) (sizeof(a) / sizeof((a)[0]))
-
#pragma STDC FENV_ACCESS ON
/*
@@ -155,7 +155,7 @@
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 @@
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 @@
}
#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);
Index: tools/regression/p1003_1b/main.c
===================================================================
--- tools/regression/p1003_1b/main.c
+++ tools/regression/p1003_1b/main.c
@@ -1,4 +1,6 @@
/* $FreeBSD$ */
+#include <sys/param.h>
+
#include <stdio.h>
#include <string.h>
@@ -20,8 +22,6 @@
{ "yield", yield, 1 },
};
-#define N(T) (sizeof (T)/ sizeof(T[0]))
-
static int usage(int argc, char *argv[])
{
int i;
@@ -47,14 +47,14 @@
" (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 +70,7 @@
}
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);
}
Index: tools/tools/ath/ath_ee_v4k_print/v4k.c
===================================================================
--- tools/tools/ath/ath_ee_v4k_print/v4k.c
+++ tools/tools/ath/ath_ee_v4k_print/v4k.c
@@ -128,12 +128,7 @@
printf("| Modal Version: %.2x |\n", mh->version);
- printf("| futureModal: 0x%.2x 0x%.2x 0x%.2x 0x%.2x |\n",
- mh->futureModal[0],
- mh->futureModal[1],
- mh->futureModal[2],
- mh->futureModal[3]
- );
+ printf("| futureModal: 0x%.2x |\n", mh->futureModal[0]);
/* and now, spur channels */
for (i = 0; i < AR5416_EEPROM_MODAL_SPURS; i++) {
Index: tools/tools/ath/athaggrstats/athaggrstats.c
===================================================================
--- tools/tools/ath/athaggrstats/athaggrstats.c
+++ tools/tools/ath/athaggrstats/athaggrstats.c
@@ -29,6 +29,8 @@
* $FreeBSD$
*/
+#include <sys/param.h>
+
#include "opt_ah.h"
/*
@@ -368,13 +370,12 @@
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 @@
wf->base.setfmt(&wf->base, fmtstring);
}
return &wf->base;
-#undef N
}
Index: tools/tools/ath/athaggrstats/main.c
===================================================================
--- tools/tools/ath/athaggrstats/main.c
+++ tools/tools/ath/athaggrstats/main.c
@@ -42,6 +42,8 @@
* print a list of all possible statistics for use with the -o option.
*/
+#include <sys/param.h>
+
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
@@ -63,13 +65,11 @@
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;
Index: tools/tools/ath/athdebug/athdebug.c
===================================================================
--- tools/tools/ath/athdebug/athdebug.c
+++ tools/tools/ath/athdebug/athdebug.c
@@ -38,6 +38,7 @@
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/sysctl.h>
+#include <sys/param.h>
#include <stdio.h>
#include <ctype.h>
@@ -47,8 +48,6 @@
#include <strings.h>
#include <err.h>
-#define N(a) (sizeof(a)/sizeof(a[0]))
-
const char *progname;
/* XXX TODO: include if_ath_debug.h */
@@ -115,7 +114,7 @@
{
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 @@
{
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 @@
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 @@
} 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 = ",";
Index: tools/tools/ath/athrd/athrd.c
===================================================================
--- tools/tools/ath/athrd/athrd.c
+++ tools/tools/ath/athrd/athrd.c
@@ -32,6 +32,8 @@
#include "ah.h"
+#include <sys/param.h>
+
#include <net80211/_ieee80211.h>
#include <net80211/ieee80211_regdomain.h>
@@ -535,43 +537,37 @@
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 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 @@
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
Index: tools/tools/ath/athstats/athstats.c
===================================================================
--- tools/tools/ath/athstats/athstats.c
+++ tools/tools/ath/athstats/athstats.c
@@ -34,6 +34,7 @@
/*
* ath statistics class.
*/
+#include <sys/param.h>
#include <sys/types.h>
#include <sys/file.h>
#include <sys/sockio.h>
@@ -1058,12 +1059,12 @@
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 +1090,4 @@
wf->base.setfmt(&wf->base, fmtstring);
}
return &wf->base;
-#undef N
}
Index: tools/tools/ath/athstats/main.c
===================================================================
--- tools/tools/ath/athstats/main.c
+++ tools/tools/ath/athstats/main.c
@@ -41,6 +41,8 @@
* print a list of all possible statistics for use with the -o option.
*/
+#include <sys/param.h>
+
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
@@ -68,13 +70,11 @@
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;
Index: tools/tools/ath/common/dumpregs_5210.c
===================================================================
--- tools/tools/ath/common/dumpregs_5210.c
+++ tools/tools/ath/common/dumpregs_5210.c
@@ -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 @@
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);
Index: tools/tools/ath/common/dumpregs_5211.c
===================================================================
--- tools/tools/ath/common/dumpregs_5211.c
+++ tools/tools/ath/common/dumpregs_5211.c
@@ -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 @@
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);
Index: tools/tools/ath/common/dumpregs_5212.c
===================================================================
--- tools/tools/ath/common/dumpregs_5212.c
+++ tools/tools/ath/common/dumpregs_5212.c
@@ -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 __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);
Index: tools/tools/ath/common/dumpregs_5416.c
===================================================================
--- tools/tools/ath/common/dumpregs_5416.c
+++ tools/tools/ath/common/dumpregs_5416.c
@@ -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 __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);
Index: tools/tools/crypto/cryptostats.c
===================================================================
--- tools/tools/crypto/cryptostats.c
+++ tools/tools/crypto/cryptostats.c
@@ -30,8 +30,10 @@
* Little program to dump the crypto statistics block and, optionally,
* zero all the stats or just the timing stuff.
*/
+#include <err.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <strings.h>
#include <sys/types.h>
Index: tools/tools/crypto/cryptotest.c
===================================================================
--- tools/tools/crypto/cryptotest.c
+++ tools/tools/crypto/cryptotest.c
@@ -87,6 +87,7 @@
#include <sys/time.h>
#include <sys/ioctl.h>
#include <stdio.h>
+#include <err.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/wait.h>
@@ -100,7 +101,6 @@
#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 @@
{
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 @@
{
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 @@
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 @@
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 @@
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 @@
}
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++)
Index: tools/tools/crypto/hifnstats.c
===================================================================
--- tools/tools/crypto/hifnstats.c
+++ tools/tools/crypto/hifnstats.c
@@ -25,7 +25,9 @@
*
* $FreeBSD$
*/
+#include <err.h>
#include <stdio.h>
+#include <sys/sysctl.h>
#include <sys/types.h>
#include "../../../sys/dev/hifn/hifn7751var.h"
@@ -39,7 +41,7 @@
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",
Index: tools/tools/crypto/ipsecstats.c
===================================================================
--- tools/tools/crypto/ipsecstats.c
+++ tools/tools/crypto/ipsecstats.c
@@ -25,10 +25,14 @@
*
* $FreeBSD$
*/
+
+#include <sys/param.h>
+#include <sys/sysctl.h>
#include <sys/types.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 +66,6 @@
{ 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 +94,13 @@
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 +124,7 @@
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 +153,7 @@
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");
Index: tools/tools/crypto/safestats.c
===================================================================
--- tools/tools/crypto/safestats.c
+++ tools/tools/crypto/safestats.c
@@ -25,7 +25,9 @@
*
* $FreeBSD$
*/
+#include <err.h>
#include <stdio.h>
+#include <sys/sysctl.h>
#include <sys/types.h>
#include "../../../sys/dev/safe/safevar.h"
@@ -39,7 +41,7 @@
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",
Index: tools/tools/crypto/ubsecstats.c
===================================================================
--- tools/tools/crypto/ubsecstats.c
+++ tools/tools/crypto/ubsecstats.c
@@ -25,7 +25,9 @@
*
* $FreeBSD$
*/
+#include <err.h>
#include <stdio.h>
+#include <sys/sysctl.h>
#include <sys/types.h>
#include "../../../sys/dev/ubsec/ubsecvar.h"
@@ -39,7 +41,7 @@
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",
Index: tools/tools/cxgbetool/cxgbetool.c
===================================================================
--- tools/tools/cxgbetool/cxgbetool.c
+++ tools/tools/cxgbetool/cxgbetool.c
@@ -28,6 +28,8 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include <sys/param.h>
+
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
@@ -50,7 +52,6 @@
#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 @@
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));
}
#undef T4_MODREGS
@@ -360,8 +361,7 @@
{ "cim", t4vf_cim_regs },
};
- return dump_regs_table(argc, argv, regs, t4vf_mod,
- ARRAY_SIZE(t4vf_mod));
+ return dump_regs_table(argc, argv, regs, t4vf_mod, nitems(t4vf_mod));
}
#define T5_MODREGS(name) { #name, t5_##name##_regs }
@@ -398,7 +398,7 @@
{ "hma", t5_hma_t5_regs }
};
- return dump_regs_table(argc, argv, regs, t5_mod, ARRAY_SIZE(t5_mod));
+ return dump_regs_table(argc, argv, regs, t5_mod, nitems(t5_mod));
}
#undef T5_MODREGS
Index: tools/tools/mwl/mwldebug/mwldebug.c
===================================================================
--- tools/tools/mwl/mwldebug/mwldebug.c
+++ tools/tools/mwl/mwldebug/mwldebug.c
@@ -47,8 +47,6 @@
#include <string.h>
#include <err.h>
-#define N(a) (sizeof(a)/sizeof(a[0]))
-
const char *progname;
enum {
@@ -100,7 +98,7 @@
{
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 @@
{
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 @@
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 @@
} 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 = ",";
Index: tools/tools/mwl/mwlstats/mwlstats.c
===================================================================
--- tools/tools/mwl/mwlstats/mwlstats.c
+++ tools/tools/mwl/mwlstats/mwlstats.c
@@ -34,6 +34,7 @@
*/
#include <sys/types.h>
#include <sys/file.h>
+#include <sys/param.h>
#include <sys/sockio.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
@@ -544,12 +545,12 @@
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 +575,4 @@
wf->base.setfmt(&wf->base, fmtstring);
}
return &wf->base;
-#undef N
}
Index: tools/tools/net80211/wlanstats/main.c
===================================================================
--- tools/tools/net80211/wlanstats/main.c
+++ tools/tools/net80211/wlanstats/main.c
@@ -34,6 +34,7 @@
* (default interface is wlan0).
*/
+#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <net/ethernet.h>
@@ -65,13 +66,11 @@
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;
Index: tools/tools/net80211/wlanstats/wlanstats.c
===================================================================
--- tools/tools/net80211/wlanstats/wlanstats.c
+++ tools/tools/net80211/wlanstats/wlanstats.c
@@ -34,6 +34,7 @@
*/
#include <sys/types.h>
#include <sys/file.h>
+#include <sys/param.h>
#include <sys/sockio.h>
#include <sys/socket.h>
#include <net/if.h>
@@ -558,7 +559,6 @@
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 +584,15 @@
[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 +621,10 @@
[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 +996,12 @@
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 +1027,4 @@
wf->base.setfmt(&wf->base, fmtstring);
}
return &wf->base;
-#undef N
}
Index: tools/tools/net80211/wlantxtime/wlantxtime.c
===================================================================
--- tools/tools/net80211/wlantxtime/wlantxtime.c
+++ tools/tools/net80211/wlantxtime/wlantxtime.c
@@ -228,13 +228,12 @@
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 +266,12 @@
}
#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 +284,11 @@
&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
Index: tools/tools/npe/npestats/main.c
===================================================================
--- tools/tools/npe/npestats/main.c
+++ tools/tools/npe/npestats/main.c
@@ -29,6 +29,8 @@
* $FreeBSD$
*/
+#include <sys/param.h>
+
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
@@ -50,13 +52,11 @@
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;
Index: tools/tools/npe/npestats/npestats.c
===================================================================
--- tools/tools/npe/npestats/npestats.c
+++ tools/tools/npe/npestats/npestats.c
@@ -32,6 +32,7 @@
/*
* npe statistics class.
*/
+#include <sys/param.h>
#include <sys/types.h>
#include <sys/sysctl.h>
@@ -251,12 +252,12 @@
struct npestatfoo *
npestats_new(const char *ifname, const char *fmtstring)
{
-#define N(a) (sizeof(a) / sizeof(a[0]))
struct npestatfoo_p *wf;
wf = calloc(1, sizeof(struct npestatfoo_p));
if (wf != NULL) {
- bsdstat_init(&wf->base.base, "npestats", npestats, N(npestats));
+ bsdstat_init(&wf->base.base, "npestats", npestats,
+ nitems(npestats));
/* override base methods */
wf->base.base.collect_cur = npe_collect_cur;
wf->base.base.collect_tot = npe_collect_tot;
@@ -274,5 +275,4 @@
wf->base.setfmt(&wf->base, fmtstring);
}
return &wf->base;
-#undef N
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Mar 25, 6:39 AM (13 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
30304891
Default Alt Text
D3442.id8090.diff (31 KB)
Attached To
Mode
D3442: tools/* : use nitems instead of local N(a)/ARRAY_SIZE(a) definitions, fix some clang warnings
Attached
Detach File
Event Timeline
Log In to Comment