if (cpts == NULL) {
/* there is an NI which will exist on all CPTs */
if (net->net_cpts != NULL)
- LIBCFS_FREE(net->net_cpts, sizeof(*net->net_cpts) *
- net->net_ncpts);
+ CFS_FREE_PTR_ARRAY(net->net_cpts, net->net_ncpts);
net->net_cpts = NULL;
net->net_ncpts = LNET_CPT_NUMBER;
return 0;
}
if (net->net_cpts == NULL) {
- LIBCFS_ALLOC(net->net_cpts, sizeof(*net->net_cpts) * ncpts);
+ CFS_ALLOC_PTR_ARRAY(net->net_cpts, ncpts);
if (net->net_cpts == NULL)
return -ENOMEM;
memcpy(net->net_cpts, cpts, ncpts * sizeof(*net->net_cpts));
return 0;
}
- LIBCFS_ALLOC(added_cpts, sizeof(*added_cpts) * LNET_CPT_NUMBER);
+ CFS_ALLOC_PTR_ARRAY(added_cpts, LNET_CPT_NUMBER);
if (added_cpts == NULL)
return -ENOMEM;
__u32 *array = NULL, *loc;
__u32 total_entries = j + net->net_ncpts;
- LIBCFS_ALLOC(array, sizeof(*net->net_cpts) * total_entries);
+ CFS_ALLOC_PTR_ARRAY(array, total_entries);
if (array == NULL) {
rc = -ENOMEM;
goto failed;
loc = array + net->net_ncpts;
memcpy(loc, added_cpts, j * sizeof(*net->net_cpts));
- LIBCFS_FREE(net->net_cpts, sizeof(*net->net_cpts) *
- net->net_ncpts);
+ CFS_FREE_PTR_ARRAY(net->net_cpts, net->net_ncpts);
net->net_ncpts = total_entries;
net->net_cpts = array;
}
failed:
- LIBCFS_FREE(added_cpts, sizeof(*added_cpts) * LNET_CPT_NUMBER);
+ CFS_FREE_PTR_ARRAY(added_cpts, LNET_CPT_NUMBER);
return rc;
}
* CPTs which the remaining NIs are associated with.
*/
if (net->net_cpts != NULL) {
- LIBCFS_FREE(net->net_cpts,
- sizeof(*net->net_cpts) * net->net_ncpts);
+ CFS_FREE_PTR_ARRAY(net->net_cpts, net->net_ncpts);
net->net_cpts = NULL;
}
* accross CPT lines.
*/
if (net->net_cpts != NULL) {
- LIBCFS_FREE(net->net_cpts,
- sizeof(*net->net_cpts) *
- net->net_ncpts);
+ CFS_FREE_PTR_ARRAY(net->net_cpts,
+ net->net_ncpts);
net->net_cpts = NULL;
net->net_ncpts = LNET_CPT_NUMBER;
}
}
if (net->net_cpts != NULL)
- LIBCFS_FREE(net->net_cpts,
- sizeof(*net->net_cpts) * net->net_ncpts);
+ CFS_FREE_PTR_ARRAY(net->net_cpts, net->net_ncpts);
LIBCFS_FREE(net, sizeof(*net));
}
LASSERT(rc <= LNET_CPT_NUMBER);
if (rc == LNET_CPT_NUMBER) {
- LIBCFS_FREE(ni->ni_cpts, rc * sizeof(ni->ni_cpts[0]));
+ CFS_FREE_PTR_ARRAY(ni->ni_cpts, rc);
ni->ni_cpts = NULL;
}
ni->ni_ncpts = LNET_CPT_NUMBER;
} else {
size_t array_size = ncpts * sizeof(ni->ni_cpts[0]);
- LIBCFS_ALLOC(ni->ni_cpts, array_size);
+
+ CFS_ALLOC_PTR_ARRAY(ni->ni_cpts, ncpts);
if (ni->ni_cpts == NULL)
goto failed;
memcpy(ni->ni_cpts, cpts, array_size);
return nip;
}
- LIBCFS_ALLOC(ipaddrs, nip * sizeof(*ipaddrs));
+ CFS_ALLOC_PTR_ARRAY(ipaddrs, nip);
if (!ipaddrs) {
rc = -ENOMEM;
CERROR("lnet: Can't allocate ipaddrs[%d], rc = %d\n",
"any local IP interfaces\n");
rc = -ENOENT;
}
- LIBCFS_FREE(ipaddrs, nip * sizeof(*ipaddrs));
+ CFS_FREE_PTR_ARRAY(ipaddrs, nip);
out_free_addrs:
kfree(ifaces);
return rc > 0 ? 0 : rc;