diff options
author | Tomohiro Kusumi <[email protected]> | 2018-04-13 02:50:39 +0900 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2018-04-12 10:50:39 -0700 |
commit | 8111eb4abc96a173845a553dc7d65382398f0683 (patch) | |
tree | eca13f7bad728d865cffe4131dac3962f52b29ef | |
parent | 7403d0743e2b75b7f5412a14007ba159efb67a7d (diff) |
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 <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Tomohiro Kusumi <[email protected]>
Closes #7405
-rw-r--r-- | lib/libefi/rdwr_efi.c | 6 | ||||
-rw-r--r-- | lib/libshare/libshare.c | 8 | ||||
-rw-r--r-- | lib/libspl/mkdirp.c | 2 | ||||
-rw-r--r-- | lib/libzfs/libzfs_dataset.c | 10 | ||||
-rw-r--r-- | lib/libzfs/libzfs_import.c | 2 | ||||
-rw-r--r-- | tests/zfs-tests/cmd/mkfile/mkfile.c | 2 |
6 files changed, 15 insertions, 15 deletions
diff --git a/lib/libefi/rdwr_efi.c b/lib/libefi/rdwr_efi.c index 7935047eb..e8a5ddd31 100644 --- a/lib/libefi/rdwr_efi.c +++ b/lib/libefi/rdwr_efi.c @@ -218,7 +218,7 @@ efi_get_info(int fd, struct dk_cinfo *dki_info) memset(dki_info, 0, sizeof (*dki_info)); - path = calloc(PATH_MAX, 1); + path = calloc(1, PATH_MAX); if (path == NULL) goto error; @@ -403,7 +403,7 @@ efi_alloc_and_init(int fd, uint32_t nparts, struct dk_gpt **vtoc) length = sizeof (struct dk_gpt) + sizeof (struct dk_part) * (nparts - 1); - if ((*vtoc = calloc(length, 1)) == NULL) + if ((*vtoc = calloc(1, length)) == NULL) return (-1); 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); length = (int) sizeof (struct dk_gpt) + (int) sizeof (struct dk_part) * (nparts - 1); - if ((*vtoc = calloc(length, 1)) == NULL) + if ((*vtoc = calloc(1, length)) == NULL) return (VT_ERROR); (*vtoc)->efi_nparts = nparts; diff --git a/lib/libshare/libshare.c b/lib/libshare/libshare.c index 022df016f..0965911cf 100644 --- a/lib/libshare/libshare.c +++ b/lib/libshare/libshare.c @@ -61,7 +61,7 @@ register_fstype(const char *name, const sa_share_ops_t *ops) { sa_fstype_t *fstype; - fstype = calloc(sizeof (sa_fstype_t), 1); + fstype = calloc(1, sizeof (sa_fstype_t)); if (fstype == NULL) return (NULL); @@ -83,7 +83,7 @@ sa_init(int init_service) { 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) return (NULL); @@ -713,7 +713,7 @@ alloc_share(const char *sharepath) { 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) return (NULL); @@ -725,7 +725,7 @@ alloc_share(const char *sharepath) 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) { free(impl_share->sharepath); diff --git a/lib/libspl/mkdirp.c b/lib/libspl/mkdirp.c index 2f091883a..541741752 100644 --- a/lib/libspl/mkdirp.c +++ b/lib/libspl/mkdirp.c @@ -166,7 +166,7 @@ simplify(const char *str) mbPathlen = strlen(mbPath); - if ((wcPath = calloc(sizeof (wchar_t), mbPathlen+1)) == NULL) { + if ((wcPath = calloc(mbPathlen+1, sizeof (wchar_t))) == NULL) { free(mbPath); return (NULL); } diff --git a/lib/libzfs/libzfs_dataset.c b/lib/libzfs/libzfs_dataset.c index acfcb7491..65834b6d1 100644 --- a/lib/libzfs/libzfs_dataset.c +++ b/lib/libzfs/libzfs_dataset.c @@ -466,7 +466,7 @@ make_dataset_handle(libzfs_handle_t *hdl, const char *path) { 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) return (NULL); @@ -493,7 +493,7 @@ make_dataset_handle(libzfs_handle_t *hdl, const char *path) zfs_handle_t * 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) return (NULL); @@ -510,7 +510,7 @@ make_dataset_handle_zc(libzfs_handle_t *hdl, zfs_cmd_t *zc) zfs_handle_t * 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) return (NULL); @@ -527,7 +527,7 @@ make_dataset_simple_handle_zc(zfs_handle_t *pzhp, zfs_cmd_t *zc) zfs_handle_t * 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) return (NULL); @@ -607,7 +607,7 @@ zfs_handle_t * make_bookmark_handle(zfs_handle_t *parent, const char *path, 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) return (NULL); diff --git a/lib/libzfs/libzfs_import.c b/lib/libzfs/libzfs_import.c index 67bf9b0be..cc9a52a3e 100644 --- a/lib/libzfs/libzfs_import.c +++ b/lib/libzfs/libzfs_import.c @@ -1673,7 +1673,7 @@ zpool_clear_label(int fd) return (0); 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); for (l = 0; l < VDEV_LABELS; l++) { diff --git a/tests/zfs-tests/cmd/mkfile/mkfile.c b/tests/zfs-tests/cmd/mkfile/mkfile.c index 000249f11..7ebf7bbcf 100644 --- a/tests/zfs-tests/cmd/mkfile/mkfile.c +++ b/tests/zfs-tests/cmd/mkfile/mkfile.c @@ -194,7 +194,7 @@ main(int argc, char **argv) if (buf) free(buf); bufsz = (size_t)st.st_blksize; - buf = calloc(bufsz, 1); + buf = calloc(1, bufsz); if (buf == NULL) { (void) fprintf(stderr, gettext( "Could not allocate buffer of" |