Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 20 Mar 2017 00:54:45 +0000 (UTC)
From:      "Pedro F. Giffuni" <pfg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r315599 - in stable/11: usr.bin/mkimg usr.sbin/mpsutil usr.sbin/nscd usr.sbin/ypbind
Message-ID:  <201703200054.v2K0sj1a025205@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pfg
Date: Mon Mar 20 00:54:45 2017
New Revision: 315599
URL: https://svnweb.freebsd.org/changeset/base/315599

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

Modified:
  stable/11/usr.bin/mkimg/qcow.c
  stable/11/usr.sbin/mpsutil/mps_cmd.c
  stable/11/usr.sbin/nscd/cachelib.c
  stable/11/usr.sbin/nscd/config.c
  stable/11/usr.sbin/nscd/hashtable.h
  stable/11/usr.sbin/nscd/nscd.c
  stable/11/usr.sbin/ypbind/yp_ping.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/usr.bin/mkimg/qcow.c
==============================================================================
--- stable/11/usr.bin/mkimg/qcow.c	Sun Mar 19 23:27:17 2017	(r315598)
+++ stable/11/usr.bin/mkimg/qcow.c	Mon Mar 20 00:54:45 2017	(r315599)
@@ -217,7 +217,7 @@ qcow_write(int fd, u_int version)
 	ofs = clstrsz * l2clno;
 	nclstrs = 1 + clstr_l1tblsz + clstr_rctblsz;
 
-	l1tbl = calloc(1, clstrsz * clstr_l1tblsz);
+	l1tbl = calloc(clstr_l1tblsz, clstrsz);
 	if (l1tbl == NULL) {
 		error = ENOMEM;
 		goto out;
@@ -248,7 +248,7 @@ qcow_write(int fd, u_int version)
 	} while (n < clstr_rcblks);
 
 	if (rcclno > 0) {
-		rctbl = calloc(1, clstrsz * clstr_rctblsz);
+		rctbl = calloc(clstr_rctblsz, clstrsz);
 		if (rctbl == NULL) {
 			error = ENOMEM;
 			goto out;
@@ -298,7 +298,7 @@ qcow_write(int fd, u_int version)
 	l1tbl = NULL;
 
 	if (rcclno > 0) {
-		rcblk = calloc(1, clstrsz * clstr_rcblks);
+		rcblk = calloc(clstr_rcblks, clstrsz);
 		if (rcblk == NULL) {
 			error = ENOMEM;
 			goto out;

Modified: stable/11/usr.sbin/mpsutil/mps_cmd.c
==============================================================================
--- stable/11/usr.sbin/mpsutil/mps_cmd.c	Sun Mar 19 23:27:17 2017	(r315598)
+++ stable/11/usr.sbin/mpsutil/mps_cmd.c	Mon Mar 20 00:54:45 2017	(r315599)
@@ -486,7 +486,7 @@ mps_firmware_get(int fd, unsigned char *
 	}
 
 	size = reply.ActualImageSize;
-	*firmware = calloc(1, sizeof(unsigned char) * size);
+	*firmware = calloc(size, sizeof(unsigned char));
 	if (*firmware == NULL) {
 		warn("calloc");
 		return (-1);

Modified: stable/11/usr.sbin/nscd/cachelib.c
==============================================================================
--- stable/11/usr.sbin/nscd/cachelib.c	Sun Mar 19 23:27:17 2017	(r315598)
+++ stable/11/usr.sbin/nscd/cachelib.c	Mon Mar 20 00:54:45 2017	(r315599)
@@ -487,8 +487,8 @@ init_cache(struct cache_params const *pa
 	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_
 
 		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_
 		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;

Modified: stable/11/usr.sbin/nscd/config.c
==============================================================================
--- stable/11/usr.sbin/nscd/config.c	Sun Mar 19 23:27:17 2017	(r315598)
+++ stable/11/usr.sbin/nscd/config.c	Mon Mar 20 00:54:45 2017	(r315599)
@@ -274,9 +274,8 @@ add_configuration_entry(struct configura
 		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);

Modified: stable/11/usr.sbin/nscd/hashtable.h
==============================================================================
--- stable/11/usr.sbin/nscd/hashtable.h	Sun Mar 19 23:27:17 2017	(r315598)
+++ stable/11/usr.sbin/nscd/hashtable.h	Mon Mar 20 00:54:45 2017	(r315599)
@@ -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 = 		\

Modified: stable/11/usr.sbin/nscd/nscd.c
==============================================================================
--- stable/11/usr.sbin/nscd/nscd.c	Sun Mar 19 23:27:17 2017	(r315598)
+++ stable/11/usr.sbin/nscd/nscd.c	Mon Mar 20 00:54:45 2017	(r315599)
@@ -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));

Modified: stable/11/usr.sbin/ypbind/yp_ping.c
==============================================================================
--- stable/11/usr.sbin/ypbind/yp_ping.c	Sun Mar 19 23:27:17 2017	(r315598)
+++ stable/11/usr.sbin/ypbind/yp_ping.c	Mon Mar 20 00:54:45 2017	(r315599)
@@ -226,7 +226,7 @@ __yp_ping(struct in_addr *restricted_add
 	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++) {



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