lib/libc/tests/nss: use calloc appropriately

The pattern used prior to this commit was `calloc(1, n * sizeof(type))`;
the pattern that should be used however is `calloc(n, sizeof(type))`.

MFC after:	3 days
Sponsored by:	Dell EMC Isilon
This commit is contained in:
Enji Cooper 2017-05-28 02:55:04 +00:00
parent b8504cc0a6
commit 3bdd6cf05d
5 changed files with 6 additions and 7 deletions

View File

@ -104,7 +104,7 @@ clone_group(struct group *dest, struct group const *src)
for (cp = src->gr_mem; *cp; ++cp)
++members_num;
dest->gr_mem = calloc(1, (members_num + 1) * sizeof(char *));
dest->gr_mem = calloc(members_num + 1, sizeof(char *));
ATF_REQUIRE(dest->gr_mem != NULL);
for (cp = src->gr_mem; *cp; ++cp) {

View File

@ -163,8 +163,7 @@ clone_hostent(struct hostent *dest, struct hostent const *src)
for (cp = src->h_aliases; *cp; ++cp)
++aliases_num;
dest->h_aliases = calloc(1, (aliases_num + 1) *
sizeof(char *));
dest->h_aliases = calloc(aliases_num + 1, sizeof(char *));
ATF_REQUIRE(dest->h_aliases != NULL);
for (cp = src->h_aliases; *cp; ++cp) {
@ -178,7 +177,7 @@ clone_hostent(struct hostent *dest, struct hostent const *src)
for (cp = src->h_addr_list; *cp; ++cp)
++addrs_num;
dest->h_addr_list = calloc(1, (addrs_num + 1) * sizeof(char *));
dest->h_addr_list = calloc(addrs_num + 1, sizeof(char *));
ATF_REQUIRE(dest->h_addr_list != NULL);
for (cp = src->h_addr_list; *cp; ++cp) {

View File

@ -99,7 +99,7 @@ clone_protoent(struct protoent *dest, struct protoent const *src)
for (cp = src->p_aliases; *cp; ++cp)
++aliases_num;
dest->p_aliases = calloc(1, (aliases_num+1) * sizeof(char *));
dest->p_aliases = calloc(aliases_num + 1, sizeof(char *));
assert(dest->p_aliases != NULL);
for (cp = src->p_aliases; *cp; ++cp) {

View File

@ -100,7 +100,7 @@ clone_rpcent(struct rpcent *dest, struct rpcent const *src)
for (cp = src->r_aliases; *cp; ++cp)
++aliases_num;
dest->r_aliases = calloc(1, (aliases_num + 1) * sizeof(char *));
dest->r_aliases = calloc(aliases_num + 1, sizeof(char *));
ATF_REQUIRE(dest->r_aliases != NULL);
for (cp = src->r_aliases; *cp; ++cp) {

View File

@ -102,7 +102,7 @@ clone_servent(struct servent *dest, struct servent const *src)
for (cp = src->s_aliases; *cp; ++cp)
++aliases_num;
dest->s_aliases = calloc(1, (aliases_num + 1) * sizeof(char *));
dest->s_aliases = calloc(aliases_num + 1, sizeof(char *));
ATF_REQUIRE(dest->s_aliases != NULL);
for (cp = src->s_aliases; *cp; ++cp) {