summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorpfg <pfg@FreeBSD.org>2017-03-20 00:55:24 +0000
committerpfg <pfg@FreeBSD.org>2017-03-20 00:55:24 +0000
commitc379bafe8e628aeb66e3f754026ad30559fffbec (patch)
treeab5d8333080bd5161cb5f1048ba2f0a19547251b /usr.sbin
parent0146a12ade54eae4dfcf1e8eedbb46f356c65acf (diff)
downloadFreeBSD-src-c379bafe8e628aeb66e3f754026ad30559fffbec.zip
FreeBSD-src-c379bafe8e628aeb66e3f754026ad30559fffbec.tar.gz
MFC r315212, r315213, r315214, r315215:
mkimg(1): let calloc(3) do the multiplication. nscd(8): let calloc(3) do the multiplying. mpsutil(8): let calloc(3) do the multiplying. ypbind(8): let calloc(3) do the multiplying. MFC after: 1 week
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/mpsutil/mps_cmd.c2
-rw-r--r--usr.sbin/nscd/cachelib.c12
-rw-r--r--usr.sbin/nscd/config.c10
-rw-r--r--usr.sbin/nscd/hashtable.h4
-rw-r--r--usr.sbin/nscd/nscd.c4
-rw-r--r--usr.sbin/ypbind/yp_ping.c2
6 files changed, 16 insertions, 18 deletions
diff --git a/usr.sbin/mpsutil/mps_cmd.c b/usr.sbin/mpsutil/mps_cmd.c
index 24ed74e..7cef93d 100644
--- a/usr.sbin/mpsutil/mps_cmd.c
+++ b/usr.sbin/mpsutil/mps_cmd.c
@@ -486,7 +486,7 @@ mps_firmware_get(int fd, unsigned char **firmware, bool bios)
}
size = reply.ActualImageSize;
- *firmware = calloc(1, sizeof(unsigned char) * size);
+ *firmware = calloc(size, sizeof(unsigned char));
if (*firmware == NULL) {
warn("calloc");
return (-1);
diff --git a/usr.sbin/nscd/cachelib.c b/usr.sbin/nscd/cachelib.c
index ab95b29..ff3e8cb 100644
--- a/usr.sbin/nscd/cachelib.c
+++ b/usr.sbin/nscd/cachelib.c
@@ -487,8 +487,8 @@ init_cache(struct cache_params const *params)
assert(params != NULL);
memcpy(&retval->params, params, sizeof(struct cache_params));
- retval->entries = calloc(1,
- sizeof(*retval->entries) * INITIAL_ENTRIES_CAPACITY);
+ retval->entries = calloc(INITIAL_ENTRIES_CAPACITY,
+ sizeof(*retval->entries));
assert(retval->entries != NULL);
retval->entries_capacity = INITIAL_ENTRIES_CAPACITY;
@@ -540,8 +540,8 @@ register_cache_entry(struct cache_ *the_cache,
new_capacity = the_cache->entries_capacity +
ENTRIES_CAPACITY_STEP;
- new_entries = calloc(1,
- sizeof(*new_entries) * new_capacity);
+ new_entries = calloc(new_capacity,
+ sizeof(*new_entries));
assert(new_entries != NULL);
memcpy(new_entries, the_cache->entries,
@@ -582,8 +582,8 @@ register_cache_entry(struct cache_ *the_cache,
else
policies_size = 2;
- new_common_entry->policies = calloc(1,
- sizeof(*new_common_entry->policies) * policies_size);
+ new_common_entry->policies = calloc(policies_size,
+ sizeof(*new_common_entry->policies));
assert(new_common_entry->policies != NULL);
new_common_entry->policies_size = policies_size;
diff --git a/usr.sbin/nscd/config.c b/usr.sbin/nscd/config.c
index f44e986..74a5cdd 100644
--- a/usr.sbin/nscd/config.c
+++ b/usr.sbin/nscd/config.c
@@ -274,9 +274,8 @@ add_configuration_entry(struct configuration *config,
struct configuration_entry **new_entries;
config->entries_capacity *= 2;
- new_entries = calloc(1,
- sizeof(*new_entries) *
- config->entries_capacity);
+ new_entries = calloc(config->entries_capacity,
+ sizeof(*new_entries));
assert(new_entries != NULL);
memcpy(new_entries, config->entries,
sizeof(struct configuration_entry *) *
@@ -522,9 +521,8 @@ init_configuration(void)
assert(retval != NULL);
retval->entries_capacity = INITIAL_ENTRIES_CAPACITY;
- retval->entries = calloc(1,
- sizeof(*retval->entries) *
- retval->entries_capacity);
+ retval->entries = calloc(retval->entries_capacity,
+ sizeof(*retval->entries));
assert(retval->entries != NULL);
pthread_rwlock_init(&retval->rwlock, NULL);
diff --git a/usr.sbin/nscd/hashtable.h b/usr.sbin/nscd/hashtable.h
index 26e6eb9..cbbf6bb 100644
--- a/usr.sbin/nscd/hashtable.h
+++ b/usr.sbin/nscd/hashtable.h
@@ -75,8 +75,8 @@ typedef unsigned int hashtable_index_t;
#define HASHTABLE_INIT(table, type, field, _entries_size) \
do { \
hashtable_index_t var; \
- (table)->entries = calloc(1, \
- sizeof(*(table)->entries) * (_entries_size)); \
+ (table)->entries = calloc(_entries_size, \
+ sizeof(*(table)->entries)); \
(table)->entries_size = (_entries_size); \
for (var = 0; var < HASHTABLE_ENTRIES_COUNT(table); ++var) {\
(table)->entries[var].field.capacity = \
diff --git a/usr.sbin/nscd/nscd.c b/usr.sbin/nscd/nscd.c
index 6b5af94..cd5cbf1 100644
--- a/usr.sbin/nscd/nscd.c
+++ b/usr.sbin/nscd/nscd.c
@@ -828,8 +828,8 @@ main(int argc, char *argv[])
}
if (s_configuration->threads_num > 1) {
- threads = calloc(1, sizeof(*threads) *
- s_configuration->threads_num);
+ threads = calloc(s_configuration->threads_num,
+ sizeof(*threads));
for (i = 0; i < s_configuration->threads_num; ++i) {
thread_args = malloc(
sizeof(*thread_args));
diff --git a/usr.sbin/ypbind/yp_ping.c b/usr.sbin/ypbind/yp_ping.c
index 4e445ea..2efc7a2 100644
--- a/usr.sbin/ypbind/yp_ping.c
+++ b/usr.sbin/ypbind/yp_ping.c
@@ -226,7 +226,7 @@ __yp_ping(struct in_addr *restricted_addrs, int cnt, char *dom, short *port)
int validsrvs = 0;
/* Set up handles. */
- reqs = calloc(1, sizeof(struct ping_req *) * cnt);
+ reqs = calloc(cnt, sizeof(struct ping_req *));
xid_seed = time(NULL) ^ getpid();
for (i = 0; i < cnt; i++) {
OpenPOWER on IntegriCloud