diff options
author | araujo <araujo@FreeBSD.org> | 2016-10-21 03:10:05 +0000 |
---|---|---|
committer | araujo <araujo@FreeBSD.org> | 2016-10-21 03:10:05 +0000 |
commit | 13d5943eb1c48958acff57c5b739063af9033b4d (patch) | |
tree | 5f7a76897f4c6e25429c89bcd196e8dee33a922b /usr.bin | |
parent | b5d55a96cbc8a6e7f907443e2ded5383320ae62c (diff) | |
download | FreeBSD-src-13d5943eb1c48958acff57c5b739063af9033b4d.zip FreeBSD-src-13d5943eb1c48958acff57c5b739063af9033b4d.tar.gz |
MFC r303541, r303542, r303543, r303545, r303546, r303547, r304225, r304226, r304605, r304676, r305212, r305863:
r303541:
Use nitems() from sys/param.h.
Sponsored by: gandi.net (BSD Day Taiwan)
MFC after: 2 weeks.
r303542:
Use nitems() from sys/param.h.
MFC after: 2 weeks.
Sponsored by: gandi.net (BSD Day Taiwan)
r303543:
Use nitems() from sys/param.h.
MFC after: 2 weeks.
Sponsored by: gandi.net (BSD Day Taiwan)
r303545:
Use nitems() from sys/param.h.
MFC after: 2 weeks.
Sponsored by: gandi.net (BSD Day Taiwan)
r303546:
Use nitems() from sys/param.h.
MFC after: 2 weeks.
Sponsored by: gandi.net (BSD Day Taiwan)
r303547:
Use nitems() from sys/param.h.
MFC after: 2 weeks.
Sponsored by: gandi.net (BSD Day Taiwan)
r304225:
Use nitems() from sys/param.h.
MFC after: 2 weeks.
r304226:
Use nitems() from sys/param.h.
MFC after: 2 weeks.
r304605:
Fix calloc(3) argument order.
Reviewed by: trasz
MFC after: 4 weeks.
Differential Revision: https://reviews.freebsd.org/D7532
r304676:
Fix calloc(3) argument order.
MFC after: 4 weeks.
r305212:
- Invert calloc(3) argument order.
MFC after: 4 weeks
r305863:
Invert calloc(3) argument order.
Reviewed by: ed.
MFC after: 4 weeks.
Differential Revision: https://reviews.freebsd.org/D7902
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/calendar/io.c | 2 | ||||
-rw-r--r-- | usr.bin/gzip/gzip.c | 2 | ||||
-rw-r--r-- | usr.bin/indent/indent.c | 2 | ||||
-rw-r--r-- | usr.bin/locale/locale.c | 4 | ||||
-rw-r--r-- | usr.bin/localedef/collate.c | 12 | ||||
-rw-r--r-- | usr.bin/netstat/pfkey.c | 3 | ||||
-rw-r--r-- | usr.bin/procstat/procstat_files.c | 3 | ||||
-rw-r--r-- | usr.bin/rpcgen/rpc_main.c | 4 | ||||
-rw-r--r-- | usr.bin/systat/main.c | 6 |
9 files changed, 18 insertions, 20 deletions
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(); |