Fix calloc(3) arguments order
calloc(3) takes `nelem` (or `nmemb` in glibc) first, and then size of elements. No difference expected for having these in reverse order, however should follow the standard. http://pubs.opengroup.org/onlinepubs/009695399/functions/calloc.html Reviewed-by: Tony Hutter <hutter2@llnl.gov> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@osnexus.com> Closes #7405
This commit is contained in:
parent
7403d0743e
commit
8111eb4abc
|
@ -218,7 +218,7 @@ efi_get_info(int fd, struct dk_cinfo *dki_info)
|
||||||
|
|
||||||
memset(dki_info, 0, sizeof (*dki_info));
|
memset(dki_info, 0, sizeof (*dki_info));
|
||||||
|
|
||||||
path = calloc(PATH_MAX, 1);
|
path = calloc(1, PATH_MAX);
|
||||||
if (path == NULL)
|
if (path == NULL)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
@ -403,7 +403,7 @@ efi_alloc_and_init(int fd, uint32_t nparts, struct dk_gpt **vtoc)
|
||||||
length = sizeof (struct dk_gpt) +
|
length = sizeof (struct dk_gpt) +
|
||||||
sizeof (struct dk_part) * (nparts - 1);
|
sizeof (struct dk_part) * (nparts - 1);
|
||||||
|
|
||||||
if ((*vtoc = calloc(length, 1)) == NULL)
|
if ((*vtoc = calloc(1, length)) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
vptr = *vtoc;
|
vptr = *vtoc;
|
||||||
|
@ -440,7 +440,7 @@ efi_alloc_and_read(int fd, struct dk_gpt **vtoc)
|
||||||
nparts = EFI_MIN_ARRAY_SIZE / sizeof (efi_gpe_t);
|
nparts = EFI_MIN_ARRAY_SIZE / sizeof (efi_gpe_t);
|
||||||
length = (int) sizeof (struct dk_gpt) +
|
length = (int) sizeof (struct dk_gpt) +
|
||||||
(int) sizeof (struct dk_part) * (nparts - 1);
|
(int) sizeof (struct dk_part) * (nparts - 1);
|
||||||
if ((*vtoc = calloc(length, 1)) == NULL)
|
if ((*vtoc = calloc(1, length)) == NULL)
|
||||||
return (VT_ERROR);
|
return (VT_ERROR);
|
||||||
|
|
||||||
(*vtoc)->efi_nparts = nparts;
|
(*vtoc)->efi_nparts = nparts;
|
||||||
|
|
|
@ -61,7 +61,7 @@ register_fstype(const char *name, const sa_share_ops_t *ops)
|
||||||
{
|
{
|
||||||
sa_fstype_t *fstype;
|
sa_fstype_t *fstype;
|
||||||
|
|
||||||
fstype = calloc(sizeof (sa_fstype_t), 1);
|
fstype = calloc(1, sizeof (sa_fstype_t));
|
||||||
|
|
||||||
if (fstype == NULL)
|
if (fstype == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
@ -83,7 +83,7 @@ sa_init(int init_service)
|
||||||
{
|
{
|
||||||
sa_handle_impl_t impl_handle;
|
sa_handle_impl_t impl_handle;
|
||||||
|
|
||||||
impl_handle = calloc(sizeof (struct sa_handle_impl), 1);
|
impl_handle = calloc(1, sizeof (struct sa_handle_impl));
|
||||||
|
|
||||||
if (impl_handle == NULL)
|
if (impl_handle == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
@ -713,7 +713,7 @@ alloc_share(const char *sharepath)
|
||||||
{
|
{
|
||||||
sa_share_impl_t impl_share;
|
sa_share_impl_t impl_share;
|
||||||
|
|
||||||
impl_share = calloc(sizeof (struct sa_share_impl), 1);
|
impl_share = calloc(1, sizeof (struct sa_share_impl));
|
||||||
|
|
||||||
if (impl_share == NULL)
|
if (impl_share == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
@ -725,7 +725,7 @@ alloc_share(const char *sharepath)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl_share->fsinfo = calloc(sizeof (sa_share_fsinfo_t), fstypes_count);
|
impl_share->fsinfo = calloc(fstypes_count, sizeof (sa_share_fsinfo_t));
|
||||||
|
|
||||||
if (impl_share->fsinfo == NULL) {
|
if (impl_share->fsinfo == NULL) {
|
||||||
free(impl_share->sharepath);
|
free(impl_share->sharepath);
|
||||||
|
|
|
@ -166,7 +166,7 @@ simplify(const char *str)
|
||||||
|
|
||||||
mbPathlen = strlen(mbPath);
|
mbPathlen = strlen(mbPath);
|
||||||
|
|
||||||
if ((wcPath = calloc(sizeof (wchar_t), mbPathlen+1)) == NULL) {
|
if ((wcPath = calloc(mbPathlen+1, sizeof (wchar_t))) == NULL) {
|
||||||
free(mbPath);
|
free(mbPath);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -466,7 +466,7 @@ make_dataset_handle(libzfs_handle_t *hdl, const char *path)
|
||||||
{
|
{
|
||||||
zfs_cmd_t zc = {"\0"};
|
zfs_cmd_t zc = {"\0"};
|
||||||
|
|
||||||
zfs_handle_t *zhp = calloc(sizeof (zfs_handle_t), 1);
|
zfs_handle_t *zhp = calloc(1, sizeof (zfs_handle_t));
|
||||||
|
|
||||||
if (zhp == NULL)
|
if (zhp == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
@ -493,7 +493,7 @@ make_dataset_handle(libzfs_handle_t *hdl, const char *path)
|
||||||
zfs_handle_t *
|
zfs_handle_t *
|
||||||
make_dataset_handle_zc(libzfs_handle_t *hdl, zfs_cmd_t *zc)
|
make_dataset_handle_zc(libzfs_handle_t *hdl, zfs_cmd_t *zc)
|
||||||
{
|
{
|
||||||
zfs_handle_t *zhp = calloc(sizeof (zfs_handle_t), 1);
|
zfs_handle_t *zhp = calloc(1, sizeof (zfs_handle_t));
|
||||||
|
|
||||||
if (zhp == NULL)
|
if (zhp == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
@ -510,7 +510,7 @@ make_dataset_handle_zc(libzfs_handle_t *hdl, zfs_cmd_t *zc)
|
||||||
zfs_handle_t *
|
zfs_handle_t *
|
||||||
make_dataset_simple_handle_zc(zfs_handle_t *pzhp, zfs_cmd_t *zc)
|
make_dataset_simple_handle_zc(zfs_handle_t *pzhp, zfs_cmd_t *zc)
|
||||||
{
|
{
|
||||||
zfs_handle_t *zhp = calloc(sizeof (zfs_handle_t), 1);
|
zfs_handle_t *zhp = calloc(1, sizeof (zfs_handle_t));
|
||||||
|
|
||||||
if (zhp == NULL)
|
if (zhp == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
@ -527,7 +527,7 @@ make_dataset_simple_handle_zc(zfs_handle_t *pzhp, zfs_cmd_t *zc)
|
||||||
zfs_handle_t *
|
zfs_handle_t *
|
||||||
zfs_handle_dup(zfs_handle_t *zhp_orig)
|
zfs_handle_dup(zfs_handle_t *zhp_orig)
|
||||||
{
|
{
|
||||||
zfs_handle_t *zhp = calloc(sizeof (zfs_handle_t), 1);
|
zfs_handle_t *zhp = calloc(1, sizeof (zfs_handle_t));
|
||||||
|
|
||||||
if (zhp == NULL)
|
if (zhp == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
@ -607,7 +607,7 @@ zfs_handle_t *
|
||||||
make_bookmark_handle(zfs_handle_t *parent, const char *path,
|
make_bookmark_handle(zfs_handle_t *parent, const char *path,
|
||||||
nvlist_t *bmark_props)
|
nvlist_t *bmark_props)
|
||||||
{
|
{
|
||||||
zfs_handle_t *zhp = calloc(sizeof (zfs_handle_t), 1);
|
zfs_handle_t *zhp = calloc(1, sizeof (zfs_handle_t));
|
||||||
|
|
||||||
if (zhp == NULL)
|
if (zhp == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
|
@ -1673,7 +1673,7 @@ zpool_clear_label(int fd)
|
||||||
return (0);
|
return (0);
|
||||||
size = P2ALIGN_TYPED(statbuf.st_size, sizeof (vdev_label_t), uint64_t);
|
size = P2ALIGN_TYPED(statbuf.st_size, sizeof (vdev_label_t), uint64_t);
|
||||||
|
|
||||||
if ((label = calloc(sizeof (vdev_label_t), 1)) == NULL)
|
if ((label = calloc(1, sizeof (vdev_label_t))) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
for (l = 0; l < VDEV_LABELS; l++) {
|
for (l = 0; l < VDEV_LABELS; l++) {
|
||||||
|
|
|
@ -194,7 +194,7 @@ main(int argc, char **argv)
|
||||||
if (buf)
|
if (buf)
|
||||||
free(buf);
|
free(buf);
|
||||||
bufsz = (size_t)st.st_blksize;
|
bufsz = (size_t)st.st_blksize;
|
||||||
buf = calloc(bufsz, 1);
|
buf = calloc(1, bufsz);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
(void) fprintf(stderr, gettext(
|
(void) fprintf(stderr, gettext(
|
||||||
"Could not allocate buffer of"
|
"Could not allocate buffer of"
|
||||||
|
|
Loading…
Reference in New Issue