From 7384ec65cd6b44511f0cdf54768bfe583ce14a27 Mon Sep 17 00:00:00 2001 From: Richard Yao Date: Tue, 10 Jan 2023 14:03:46 -0500 Subject: [PATCH] Cleanup: Remove unnecessary explicit casts of pointers from allocators The Linux 5.16.14 kernel's coccicheck caught these. The semantic patch that caught them was: ./scripts/coccinelle/api/alloc/alloc_cast.cocci Reviewed-by: Brian Behlendorf Signed-off-by: Richard Yao Closes #14372 --- module/icp/algs/aes/aes_impl.c | 2 +- module/icp/algs/modes/gcm.c | 4 ++-- module/icp/api/kcf_ctxops.c | 2 +- module/os/freebsd/spl/callb.c | 2 +- module/os/linux/spl/spl-kmem-cache.c | 2 +- module/zfs/zfs_chksum.c | 2 +- module/zfs/zfs_vnops.c | 2 +- module/zfs/zvol.c | 2 +- module/zstd/zfs_zstd.c | 4 ++-- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/module/icp/algs/aes/aes_impl.c b/module/icp/algs/aes/aes_impl.c index 9d90914aacfa..9daa975226fe 100644 --- a/module/icp/algs/aes/aes_impl.c +++ b/module/icp/algs/aes/aes_impl.c @@ -211,7 +211,7 @@ aes_alloc_keysched(size_t *size, int kmflag) { aes_key_t *keysched; - keysched = (aes_key_t *)kmem_alloc(sizeof (aes_key_t), kmflag); + keysched = kmem_alloc(sizeof (aes_key_t), kmflag); if (keysched != NULL) { *size = sizeof (aes_key_t); return (keysched); diff --git a/module/icp/algs/modes/gcm.c b/module/icp/algs/modes/gcm.c index 558a578090b2..a8792c4555e2 100644 --- a/module/icp/algs/modes/gcm.c +++ b/module/icp/algs/modes/gcm.c @@ -653,7 +653,7 @@ gcm_init_ctx(gcm_ctx_t *gcm_ctx, char *param, size_t block_size, } gcm_ctx->gcm_htab_len = htab_len; gcm_ctx->gcm_Htable = - (uint64_t *)kmem_alloc(htab_len, KM_SLEEP); + kmem_alloc(htab_len, KM_SLEEP); if (gcm_ctx->gcm_Htable == NULL) { return (CRYPTO_HOST_MEMORY); @@ -728,7 +728,7 @@ gmac_init_ctx(gcm_ctx_t *gcm_ctx, char *param, size_t block_size, } gcm_ctx->gcm_htab_len = htab_len; gcm_ctx->gcm_Htable = - (uint64_t *)kmem_alloc(htab_len, KM_SLEEP); + kmem_alloc(htab_len, KM_SLEEP); if (gcm_ctx->gcm_Htable == NULL) { return (CRYPTO_HOST_MEMORY); diff --git a/module/icp/api/kcf_ctxops.c b/module/icp/api/kcf_ctxops.c index 4fa281676b81..b8cd67ea7f67 100644 --- a/module/icp/api/kcf_ctxops.c +++ b/module/icp/api/kcf_ctxops.c @@ -88,7 +88,7 @@ crypto_create_ctx_template(crypto_mechanism_t *mech, crypto_key_t *key, if (error != CRYPTO_SUCCESS) return (error); - if ((ctx_tmpl = (kcf_ctx_template_t *)kmem_alloc( + if ((ctx_tmpl = kmem_alloc( sizeof (kcf_ctx_template_t), KM_SLEEP)) == NULL) { KCF_PROV_REFRELE(pd); return (CRYPTO_HOST_MEMORY); diff --git a/module/os/freebsd/spl/callb.c b/module/os/freebsd/spl/callb.c index 47f3ccc0c7fa..2bfd4ea169bb 100644 --- a/module/os/freebsd/spl/callb.c +++ b/module/os/freebsd/spl/callb.c @@ -146,7 +146,7 @@ callb_add_common(boolean_t (*func)(void *arg, int code), cv_wait(&ct->ct_busy_cv, &ct->ct_lock); if ((cp = ct->ct_freelist) == NULL) { ct->ct_ncallb++; - cp = (callb_t *)kmem_zalloc(sizeof (callb_t), KM_SLEEP); + cp = kmem_zalloc(sizeof (callb_t), KM_SLEEP); } ct->ct_freelist = cp->c_next; cp->c_thread = t; diff --git a/module/os/linux/spl/spl-kmem-cache.c b/module/os/linux/spl/spl-kmem-cache.c index edd04783b363..4cceeb8bdffd 100644 --- a/module/os/linux/spl/spl-kmem-cache.c +++ b/module/os/linux/spl/spl-kmem-cache.c @@ -701,7 +701,7 @@ spl_kmem_cache_create(const char *name, size_t size, size_t align, skc->skc_magic = SKC_MAGIC; skc->skc_name_size = strlen(name) + 1; - skc->skc_name = (char *)kmalloc(skc->skc_name_size, lflags); + skc->skc_name = kmalloc(skc->skc_name_size, lflags); if (skc->skc_name == NULL) { kfree(skc); return (NULL); diff --git a/module/zfs/zfs_chksum.c b/module/zfs/zfs_chksum.c index 4a9a36d87e66..91247f29278f 100644 --- a/module/zfs/zfs_chksum.c +++ b/module/zfs/zfs_chksum.c @@ -251,7 +251,7 @@ chksum_benchmark(void) /* space for the benchmark times */ chksum_stat_cnt = 4; chksum_stat_cnt += blake3_impl_getcnt(); - chksum_stat_data = (chksum_stat_t *)kmem_zalloc( + chksum_stat_data = kmem_zalloc( sizeof (chksum_stat_t) * chksum_stat_cnt, KM_SLEEP); /* edonr - needs to be the first one here (slow CPU check) */ diff --git a/module/zfs/zfs_vnops.c b/module/zfs/zfs_vnops.c index 45ecb0773260..0c392b9da0fb 100644 --- a/module/zfs/zfs_vnops.c +++ b/module/zfs/zfs_vnops.c @@ -876,7 +876,7 @@ zfs_get_data(void *arg, uint64_t gen, lr_write_t *lr, char *buf, return (SET_ERROR(ENOENT)); } - zgd = (zgd_t *)kmem_zalloc(sizeof (zgd_t), KM_SLEEP); + zgd = kmem_zalloc(sizeof (zgd_t), KM_SLEEP); zgd->zgd_lwb = lwb; zgd->zgd_private = zp; diff --git a/module/zfs/zvol.c b/module/zfs/zvol.c index 20578a8223b2..1371e5187516 100644 --- a/module/zfs/zvol.c +++ b/module/zfs/zvol.c @@ -646,7 +646,7 @@ zvol_get_data(void *arg, uint64_t arg2, lr_write_t *lr, char *buf, ASSERT3P(zio, !=, NULL); ASSERT3U(size, !=, 0); - zgd = (zgd_t *)kmem_zalloc(sizeof (zgd_t), KM_SLEEP); + zgd = kmem_zalloc(sizeof (zgd_t), KM_SLEEP); zgd->zgd_lwb = lwb; /* diff --git a/module/zstd/zfs_zstd.c b/module/zstd/zfs_zstd.c index 1bb95e460a81..ed0271a8d683 100644 --- a/module/zstd/zfs_zstd.c +++ b/module/zstd/zfs_zstd.c @@ -784,9 +784,9 @@ create_fallback_mem(struct zstd_fallback_mem *mem, size_t size) static void __init zstd_mempool_init(void) { - zstd_mempool_cctx = (struct zstd_pool *) + zstd_mempool_cctx = kmem_zalloc(ZSTD_POOL_MAX * sizeof (struct zstd_pool), KM_SLEEP); - zstd_mempool_dctx = (struct zstd_pool *) + zstd_mempool_dctx = kmem_zalloc(ZSTD_POOL_MAX * sizeof (struct zstd_pool), KM_SLEEP); for (int i = 0; i < ZSTD_POOL_MAX; i++) {