dm: fix use of sizeof() macro
authorHeinz Mauelshagen <heinzm@redhat.com>
Tue, 7 Feb 2023 21:16:53 +0000 (22:16 +0100)
committerMike Snitzer <snitzer@kernel.org>
Tue, 14 Feb 2023 19:23:07 +0000 (14:23 -0500)
Signed-off-by: Heinz Mauelshagen <heinzm@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
drivers/md/dm-bufio.c
drivers/md/dm-integrity.c
drivers/md/dm-kcopyd.c
drivers/md/dm-writecache.c

index 64b972f7d60ec887d0bc3d14810a007b08b53678..cf077f9b30c354176e638aa3fe7f28a850694996 100644 (file)
@@ -1815,7 +1815,7 @@ struct dm_bufio_client *dm_bufio_client_create(struct block_device *bdev, unsign
            (block_size < PAGE_SIZE || !is_power_of_2(block_size))) {
                unsigned int align = min(1U << __ffs(block_size), (unsigned int)PAGE_SIZE);
 
-               snprintf(slab_name, sizeof slab_name, "dm_bufio_cache-%u", block_size);
+               snprintf(slab_name, sizeof(slab_name), "dm_bufio_cache-%u", block_size);
                c->slab_cache = kmem_cache_create(slab_name, block_size, align,
                                                  SLAB_RECLAIM_ACCOUNT, NULL);
                if (!c->slab_cache) {
@@ -1824,9 +1824,9 @@ struct dm_bufio_client *dm_bufio_client_create(struct block_device *bdev, unsign
                }
        }
        if (aux_size)
-               snprintf(slab_name, sizeof slab_name, "dm_bufio_buffer-%u", aux_size);
+               snprintf(slab_name, sizeof(slab_name), "dm_bufio_buffer-%u", aux_size);
        else
-               snprintf(slab_name, sizeof slab_name, "dm_bufio_buffer");
+               snprintf(slab_name, sizeof(slab_name), "dm_bufio_buffer");
        c->slab_buffer = kmem_cache_create(slab_name, sizeof(struct dm_buffer) + aux_size,
                                           0, SLAB_RECLAIM_ACCOUNT, NULL);
        if (!c->slab_buffer) {
index 868b158846dd3cc47f59ac06bfd5aee612a2adfb..8426efaf1676c6f21b9ed2744d5d730e3131cf9b 100644 (file)
@@ -826,7 +826,7 @@ static void section_mac(struct dm_integrity_c *ic, unsigned int section, __u8 re
                }
 
                section_le = cpu_to_le64(section);
-               r = crypto_shash_update(desc, (__u8 *)&section_le, sizeof section_le);
+               r = crypto_shash_update(desc, (__u8 *)&section_le, sizeof(section_le));
                if (unlikely(r < 0)) {
                        dm_integrity_io_error(ic, "crypto_shash_update", r);
                        goto err;
@@ -836,7 +836,7 @@ static void section_mac(struct dm_integrity_c *ic, unsigned int section, __u8 re
        for (j = 0; j < ic->journal_section_entries; j++) {
                struct journal_entry *je = access_journal_entry(ic, section, j);
 
-               r = crypto_shash_update(desc, (__u8 *)&je->u.sector, sizeof je->u.sector);
+               r = crypto_shash_update(desc, (__u8 *)&je->u.sector, sizeof(je->u.sector));
                if (unlikely(r < 0)) {
                        dm_integrity_io_error(ic, "crypto_shash_update", r);
                        goto err;
@@ -1687,7 +1687,7 @@ static void integrity_sector_checksum(struct dm_integrity_c *ic, sector_t sector
                }
        }
 
-       r = crypto_shash_update(req, (const __u8 *)&sector_le, sizeof sector_le);
+       r = crypto_shash_update(req, (const __u8 *)&sector_le, sizeof(sector_le));
        if (unlikely(r < 0)) {
                dm_integrity_io_error(ic, "crypto_shash_update", r);
                goto failed;
@@ -2967,8 +2967,8 @@ static void replay_journal(struct dm_integrity_c *ic)
                goto clear_journal;
 
        journal_empty = true;
-       memset(used_commit_ids, 0, sizeof used_commit_ids);
-       memset(max_commit_id_sections, 0, sizeof max_commit_id_sections);
+       memset(used_commit_ids, 0, sizeof(used_commit_ids));
+       memset(max_commit_id_sections, 0, sizeof(max_commit_id_sections));
        for (i = 0; i < ic->journal_sections; i++) {
                for (j = 0; j < ic->journal_section_sectors; j++) {
                        int k;
@@ -3685,7 +3685,7 @@ static void free_alg(struct alg_spec *a)
 {
        kfree_sensitive(a->alg_string);
        kfree_sensitive(a->key);
-       memset(a, 0, sizeof *a);
+       memset(a, 0, sizeof(*a));
 }
 
 static int get_alg_and_key(const char *arg, struct alg_spec *a, char **error, char *error_inval)
@@ -3852,10 +3852,10 @@ static int create_journal(struct dm_integrity_c *ic, char **error)
                                clear_page(va);
                                sg_set_buf(&sg[i], va, PAGE_SIZE);
                        }
-                       sg_set_buf(&sg[i], &ic->commit_ids, sizeof ic->commit_ids);
+                       sg_set_buf(&sg[i], &ic->commit_ids, sizeof(ic->commit_ids));
 
                        skcipher_request_set_crypt(req, sg, sg,
-                                                  PAGE_SIZE * ic->journal_pages + sizeof ic->commit_ids, crypt_iv);
+                                                  PAGE_SIZE * ic->journal_pages + sizeof(ic->commit_ids), crypt_iv);
                        init_completion(&comp.comp);
                        comp.in_flight = (atomic_t)ATOMIC_INIT(1);
                        if (do_crypt(true, req, &comp))
index b8f8e34c1c0972dc4cc9947f4b4856da575b1849..a158c6e5fbd71375e9fefb4ff9855cd35ac7b7e3 100644 (file)
@@ -826,7 +826,7 @@ void dm_kcopyd_copy(struct dm_kcopyd_client *kc, struct dm_io_region *from,
                job->pages = NULL;
                job->op = REQ_OP_READ;
        } else {
-               memset(&job->source, 0, sizeof job->source);
+               memset(&job->source, 0, sizeof(job->source));
                job->source.count = job->dests[0].count;
                job->pages = &zero_page_list;
 
index 70a110a41c44b9fb9c94259400c7587320dc2aff..3aa5874f0aefabb22121e94a928021dca57ef2dc 100644 (file)
@@ -772,7 +772,7 @@ static void writecache_poison_lists(struct dm_writecache *wc)
        /*
         * Catch incorrect access to these values while the device is suspended.
         */
-       memset(&wc->tree, -1, sizeof wc->tree);
+       memset(&wc->tree, -1, sizeof(wc->tree));
        wc->lru.next = LIST_POISON1;
        wc->lru.prev = LIST_POISON2;
        wc->freelist.next = LIST_POISON1;
@@ -1182,7 +1182,7 @@ static int process_clear_stats_mesg(unsigned int argc, char **argv, struct dm_wr
                return -EINVAL;
 
        wc_lock(wc);
-       memset(&wc->stats, 0, sizeof wc->stats);
+       memset(&wc->stats, 0, sizeof(wc->stats));
        wc_unlock(wc);
 
        return 0;
@@ -2174,7 +2174,7 @@ static int init_memory(struct dm_writecache *wc)
        writecache_flush_all_metadata(wc);
        writecache_commit_flushed(wc, false);
        pmem_assign(sb(wc)->magic, cpu_to_le32(MEMORY_SUPERBLOCK_MAGIC));
-       writecache_flush_region(wc, &sb(wc)->magic, sizeof sb(wc)->magic);
+       writecache_flush_region(wc, &sb(wc)->magic, sizeof(sb(wc)->magic));
        writecache_commit_flushed(wc, false);
 
        return 0;