summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sbin/natd/natd.c2
-rw-r--r--usr.bin/calendar/io.c2
-rw-r--r--usr.bin/gzip/gzip.c2
-rw-r--r--usr.bin/indent/indent.c2
-rw-r--r--usr.bin/locale/locale.c4
-rw-r--r--usr.bin/localedef/collate.c12
-rw-r--r--usr.bin/netstat/pfkey.c3
-rw-r--r--usr.bin/procstat/procstat_files.c3
-rw-r--r--usr.bin/rpcgen/rpc_main.c4
-rw-r--r--usr.bin/systat/main.c6
-rw-r--r--usr.sbin/ctld/chap.c4
-rw-r--r--usr.sbin/ctld/keys.c2
-rw-r--r--usr.sbin/ctld/pdu.c4
-rw-r--r--usr.sbin/fifolog/lib/fifolog_int.c2
-rw-r--r--usr.sbin/fifolog/lib/fifolog_reader.c2
-rw-r--r--usr.sbin/iscsid/chap.c4
-rw-r--r--usr.sbin/iscsid/keys.c2
-rw-r--r--usr.sbin/iscsid/pdu.c4
18 files changed, 31 insertions, 33 deletions
diff --git a/sbin/natd/natd.c b/sbin/natd/natd.c
index aa1628a..268850c 100644
--- a/sbin/natd/natd.c
+++ b/sbin/natd/natd.c
@@ -2006,7 +2006,7 @@ NewInstance(const char *name)
}
}
ninstance++;
- ip = calloc(sizeof *ip, 1);
+ ip = calloc(1, sizeof(*ip));
ip->name = strdup(name);
ip->la = LibAliasInit (ip->la);
ip->assignAliasAddr = 0;
diff --git a/usr.bin/calendar/io.c b/usr.bin/calendar/io.c
index 0a5dd85..a8c1efd 100644
--- a/usr.bin/calendar/io.c
+++ b/usr.bin/calendar/io.c
@@ -118,7 +118,7 @@ cal_fopen(const char *file)
return (NULL);
}
- for (i = 0; i < sizeof(calendarHomes)/sizeof(calendarHomes[0]) ; i++) {
+ for (i = 0; i < nitems(calendarHomes); i++) {
if (chdir(calendarHomes[i]) != 0)
continue;
diff --git a/usr.bin/gzip/gzip.c b/usr.bin/gzip/gzip.c
index 8f22abc..4a649b8 100644
--- a/usr.bin/gzip/gzip.c
+++ b/usr.bin/gzip/gzip.c
@@ -155,7 +155,7 @@ static suffixes_t suffixes[] = {
#endif /* SMALL */
#undef SUFFIX
};
-#define NUM_SUFFIXES (sizeof suffixes / sizeof suffixes[0])
+#define NUM_SUFFIXES (nitems(suffixes))
#define SUFFIX_MAXLEN 30
static const char gzip_version[] = "FreeBSD gzip 20150413";
diff --git a/usr.bin/indent/indent.c b/usr.bin/indent/indent.c
index 3035faa..7c2cbea 100644
--- a/usr.bin/indent/indent.c
+++ b/usr.bin/indent/indent.c
@@ -1133,7 +1133,7 @@ check_type:
while ((c = getc(input)) == '\n');
ungetc(c, input);
}
- if ((size_t)ifdef_level < sizeof(state_stack)/sizeof(state_stack[0])) {
+ if ((size_t)ifdef_level < nitems(state_stack)) {
match_state[ifdef_level].tos = -1;
state_stack[ifdef_level++] = ps;
}
diff --git a/usr.bin/locale/locale.c b/usr.bin/locale/locale.c
index 8e1b03a..b295b17 100644
--- a/usr.bin/locale/locale.c
+++ b/usr.bin/locale/locale.c
@@ -220,10 +220,10 @@ struct _kwinfo {
"(POSIX legacy)" } /* compat */
};
-#define NKWINFO (sizeof(kwinfo)/sizeof(kwinfo[0]))
+#define NKWINFO (nitems(kwinfo))
const char *boguslocales[] = { "UTF-8" };
-#define NBOGUS (sizeof(boguslocales)/sizeof(boguslocales[0]))
+#define NBOGUS (nitems(boguslocales))
int
main(int argc, char *argv[])
diff --git a/usr.bin/localedef/collate.c b/usr.bin/localedef/collate.c
index 63dd4c7..7890538 100644
--- a/usr.bin/localedef/collate.c
+++ b/usr.bin/localedef/collate.c
@@ -490,7 +490,7 @@ define_collsym(char *name)
{
collsym_t *sym;
- if ((sym = calloc(sizeof (*sym), 1)) == NULL) {
+ if ((sym = calloc(1, sizeof(*sym))) == NULL) {
fprintf(stderr,"out of memory");
return;
}
@@ -536,7 +536,7 @@ get_collundef(char *name)
srch.name = name;
if ((ud = RB_FIND(collundefs, &collundefs, &srch)) == NULL) {
- if (((ud = calloc(sizeof (*ud), 1)) == NULL) ||
+ if (((ud = calloc(1, sizeof(*ud))) == NULL) ||
((ud->name = strdup(name)) == NULL)) {
fprintf(stderr,"out of memory");
free(ud);
@@ -561,7 +561,7 @@ get_collchar(wchar_t wc, int create)
srch.wc = wc;
cc = RB_FIND(collchars, &collchars, &srch);
if ((cc == NULL) && create) {
- if ((cc = calloc(sizeof (*cc), 1)) == NULL) {
+ if ((cc = calloc(1, sizeof(*cc))) == NULL) {
fprintf(stderr, "out of memory");
return (NULL);
}
@@ -793,7 +793,7 @@ define_collelem(char *name, wchar_t *wcs)
return;
}
- if ((e = calloc(sizeof (*e), 1)) == NULL) {
+ if ((e = calloc(1, sizeof(*e))) == NULL) {
fprintf(stderr, "out of memory");
return;
}
@@ -927,7 +927,7 @@ add_order_subst(void)
s = RB_FIND(substs_ref, &substs_ref[curr_weight], &srch);
if (s == NULL) {
- if ((s = calloc(sizeof (*s), 1)) == NULL) {
+ if ((s = calloc(1, sizeof(*s))) == NULL) {
fprintf(stderr,"out of memory");
return;
}
@@ -1035,7 +1035,7 @@ add_weight(int32_t ref, int pass)
if (RB_FIND(weights, &weights[pass], &srch) != NULL)
return;
- if ((w = calloc(sizeof (*w), 1)) == NULL) {
+ if ((w = calloc(1, sizeof(*w))) == NULL) {
fprintf(stderr, "out of memory");
return;
}
diff --git a/usr.bin/netstat/pfkey.c b/usr.bin/netstat/pfkey.c
index 1a60b48..e12181b 100644
--- a/usr.bin/netstat/pfkey.c
+++ b/usr.bin/netstat/pfkey.c
@@ -101,8 +101,7 @@ static const char *pfkey_msgtype_names (int);
static const char *
pfkey_msgtype_names(int x)
{
- const int max =
- sizeof(pfkey_msgtypenames)/sizeof(pfkey_msgtypenames[0]);
+ const int max = nitems(pfkey_msgtypenames);
static char buf[20];
if (x < max && pfkey_msgtypenames[x])
diff --git a/usr.bin/procstat/procstat_files.c b/usr.bin/procstat/procstat_files.c
index ae7928d..1626697 100644
--- a/usr.bin/procstat/procstat_files.c
+++ b/usr.bin/procstat/procstat_files.c
@@ -235,8 +235,7 @@ static struct cap_desc {
{ CAP_SOCK_CLIENT, "scl" },
{ CAP_SOCK_SERVER, "ssr" },
};
-static const u_int cap_desc_count = sizeof(cap_desc) /
- sizeof(cap_desc[0]);
+static const u_int cap_desc_count = nitems(cap_desc);
static u_int
width_capability(cap_rights_t *rightsp)
diff --git a/usr.bin/rpcgen/rpc_main.c b/usr.bin/rpcgen/rpc_main.c
index 32e47a0..78bc610 100644
--- a/usr.bin/rpcgen/rpc_main.c
+++ b/usr.bin/rpcgen/rpc_main.c
@@ -82,11 +82,11 @@ static char pathbuf[MAXPATHLEN + 1];
static const char *allv[] = {
"rpcgen", "-s", "udp", "-s", "tcp",
};
-static int allc = sizeof (allv)/sizeof (allv[0]);
+static int allc = nitems(allv);
static const char *allnv[] = {
"rpcgen", "-s", "netpath",
};
-static int allnc = sizeof (allnv)/sizeof (allnv[0]);
+static int allnc = nitems(allnv);
/*
* machinations for handling expanding argument list
diff --git a/usr.bin/systat/main.c b/usr.bin/systat/main.c
index 4c55ff4..74195f6 100644
--- a/usr.bin/systat/main.c
+++ b/usr.bin/systat/main.c
@@ -261,7 +261,7 @@ display(void)
int i, j;
/* Get the load average over the last minute. */
- (void) getloadavg(avenrun, sizeof(avenrun) / sizeof(avenrun[0]));
+ (void) getloadavg(avenrun, nitems(avenrun));
(*curcmd->c_fetch)();
if (curcmd->c_flags & CF_LOADAV) {
j = 5.0*avenrun[0] + 0.5;
@@ -293,7 +293,7 @@ display(void)
GETSYSCTL("kstat.zfs.misc.arcstats.l2_hdr_size", arc[5]);
GETSYSCTL("kstat.zfs.misc.arcstats.other_size", arc[6]);
wmove(wload, 0, 0); wclrtoeol(wload);
- for (i = 0 ; i < sizeof(arc) / sizeof(arc[0]) ; i++) {
+ for (i = 0 ; i < nitems(arc); i++) {
if (arc[i] > 10llu * 1024 * 1024 * 1024 ) {
wprintw(wload, "%7lluG", arc[i] >> 30);
}
@@ -318,7 +318,7 @@ void
load(void)
{
- (void) getloadavg(avenrun, sizeof(avenrun)/sizeof(avenrun[0]));
+ (void) getloadavg(avenrun, nitems(avenrun));
mvprintw(CMDLINE, 0, "%4.1f %4.1f %4.1f",
avenrun[0], avenrun[1], avenrun[2]);
clrtoeol();
diff --git a/usr.sbin/ctld/chap.c b/usr.sbin/ctld/chap.c
index 2120350..bf61f05 100644
--- a/usr.sbin/ctld/chap.c
+++ b/usr.sbin/ctld/chap.c
@@ -232,7 +232,7 @@ chap_new(void)
{
struct chap *chap;
- chap = calloc(sizeof(*chap), 1);
+ chap = calloc(1, sizeof(*chap));
if (chap == NULL)
log_err(1, "calloc");
@@ -333,7 +333,7 @@ rchap_new(const char *secret)
{
struct rchap *rchap;
- rchap = calloc(sizeof(*rchap), 1);
+ rchap = calloc(1, sizeof(*rchap));
if (rchap == NULL)
log_err(1, "calloc");
diff --git a/usr.sbin/ctld/keys.c b/usr.sbin/ctld/keys.c
index c2f1604..a3b12f0 100644
--- a/usr.sbin/ctld/keys.c
+++ b/usr.sbin/ctld/keys.c
@@ -43,7 +43,7 @@ keys_new(void)
{
struct keys *keys;
- keys = calloc(sizeof(*keys), 1);
+ keys = calloc(1, sizeof(*keys));
if (keys == NULL)
log_err(1, "calloc");
diff --git a/usr.sbin/ctld/pdu.c b/usr.sbin/ctld/pdu.c
index be3598e..2d4fcc6 100644
--- a/usr.sbin/ctld/pdu.c
+++ b/usr.sbin/ctld/pdu.c
@@ -81,11 +81,11 @@ pdu_new(struct connection *conn)
{
struct pdu *pdu;
- pdu = calloc(sizeof(*pdu), 1);
+ pdu = calloc(1, sizeof(*pdu));
if (pdu == NULL)
log_err(1, "calloc");
- pdu->pdu_bhs = calloc(sizeof(*pdu->pdu_bhs), 1);
+ pdu->pdu_bhs = calloc(1, sizeof(*pdu->pdu_bhs));
if (pdu->pdu_bhs == NULL)
log_err(1, "calloc");
diff --git a/usr.sbin/fifolog/lib/fifolog_int.c b/usr.sbin/fifolog/lib/fifolog_int.c
index 9d3b437..f8aabdc 100644
--- a/usr.sbin/fifolog/lib/fifolog_int.c
+++ b/usr.sbin/fifolog/lib/fifolog_int.c
@@ -125,7 +125,7 @@ fifolog_int_open_i(struct fifolog_file *f, const char *fname, int mode)
/* Initialize zlib handling */
- f->zs = calloc(sizeof *f->zs, 1);
+ f->zs = calloc(1, sizeof(*f->zs));
if (f->zs == NULL)
return ("cannot malloc");
diff --git a/usr.sbin/fifolog/lib/fifolog_reader.c b/usr.sbin/fifolog/lib/fifolog_reader.c
index 0dda672..e771f88 100644
--- a/usr.sbin/fifolog/lib/fifolog_reader.c
+++ b/usr.sbin/fifolog/lib/fifolog_reader.c
@@ -59,7 +59,7 @@ fifolog_reader_open(const char *fname)
struct fifolog_reader *fr;
int i;
- fr = calloc(sizeof *fr, 1);
+ fr = calloc(1, sizeof(*fr));
if (fr == NULL)
err(1, "Cannot malloc");
diff --git a/usr.sbin/iscsid/chap.c b/usr.sbin/iscsid/chap.c
index 30c1cd4..f6b51d7 100644
--- a/usr.sbin/iscsid/chap.c
+++ b/usr.sbin/iscsid/chap.c
@@ -232,7 +232,7 @@ chap_new(void)
{
struct chap *chap;
- chap = calloc(sizeof(*chap), 1);
+ chap = calloc(1, sizeof(*chap));
if (chap == NULL)
log_err(1, "calloc");
@@ -333,7 +333,7 @@ rchap_new(const char *secret)
{
struct rchap *rchap;
- rchap = calloc(sizeof(*rchap), 1);
+ rchap = calloc(1, sizeof(*rchap));
if (rchap == NULL)
log_err(1, "calloc");
diff --git a/usr.sbin/iscsid/keys.c b/usr.sbin/iscsid/keys.c
index 8ac4788..4126bee 100644
--- a/usr.sbin/iscsid/keys.c
+++ b/usr.sbin/iscsid/keys.c
@@ -43,7 +43,7 @@ keys_new(void)
{
struct keys *keys;
- keys = calloc(sizeof(*keys), 1);
+ keys = calloc(1, sizeof(*keys));
if (keys == NULL)
log_err(1, "calloc");
diff --git a/usr.sbin/iscsid/pdu.c b/usr.sbin/iscsid/pdu.c
index 78aa065..4222446 100644
--- a/usr.sbin/iscsid/pdu.c
+++ b/usr.sbin/iscsid/pdu.c
@@ -81,11 +81,11 @@ pdu_new(struct connection *conn)
{
struct pdu *pdu;
- pdu = calloc(sizeof(*pdu), 1);
+ pdu = calloc(1, sizeof(*pdu));
if (pdu == NULL)
log_err(1, "calloc");
- pdu->pdu_bhs = calloc(sizeof(*pdu->pdu_bhs), 1);
+ pdu->pdu_bhs = calloc(1, sizeof(*pdu->pdu_bhs));
if (pdu->pdu_bhs == NULL)
log_err(1, "calloc");
OpenPOWER on IntegriCloud