This attribute allows the compiler to refine compile-time diagnostics
and run-time sanitizer features with information about the size of the
flexible arrays.

Signed-off-by: Ken Raeburn <[email protected]>
---
 drivers/md/dm-vdo/block-map.h            | 2 +-
 drivers/md/dm-vdo/dedupe.c               | 2 +-
 drivers/md/dm-vdo/indexer/index.h        | 2 +-
 drivers/md/dm-vdo/indexer/open-chapter.h | 2 +-
 drivers/md/dm-vdo/logical-zone.h         | 2 +-
 drivers/md/dm-vdo/physical-zone.c        | 2 +-
 drivers/md/dm-vdo/repair.c               | 2 +-
 drivers/md/dm-vdo/slab-depot.h           | 2 +-
 8 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/md/dm-vdo/block-map.h b/drivers/md/dm-vdo/block-map.h
index 39a13039e4a3..4fd24043b0d7 100644
--- a/drivers/md/dm-vdo/block-map.h
+++ b/drivers/md/dm-vdo/block-map.h
@@ -276,7 +276,7 @@ struct block_map {
        block_count_t next_entry_count;
 
        zone_count_t zone_count;
-       struct block_map_zone zones[];
+       struct block_map_zone zones[] __counted_by(zone_count);
 };
 
 /**
diff --git a/drivers/md/dm-vdo/dedupe.c b/drivers/md/dm-vdo/dedupe.c
index 4e0fefd077d0..5f5639d89bc6 100644
--- a/drivers/md/dm-vdo/dedupe.c
+++ b/drivers/md/dm-vdo/dedupe.c
@@ -296,7 +296,7 @@ struct hash_zones {
        /* The number of zones */
        zone_count_t zone_count;
        /* The hash zones themselves */
-       struct hash_zone zones[];
+       struct hash_zone zones[] __counted_by(zone_count);
 };
 
 /* These are in milliseconds. */
diff --git a/drivers/md/dm-vdo/indexer/index.h 
b/drivers/md/dm-vdo/indexer/index.h
index edabb239548e..1891f2de508e 100644
--- a/drivers/md/dm-vdo/indexer/index.h
+++ b/drivers/md/dm-vdo/indexer/index.h
@@ -53,7 +53,7 @@ struct uds_index {
 
        index_callback_fn callback;
        struct uds_request_queue *triage_queue;
-       struct uds_request_queue *zone_queues[];
+       struct uds_request_queue *zone_queues[] __counted_by(zone_count);
 };
 
 enum request_stage {
diff --git a/drivers/md/dm-vdo/indexer/open-chapter.h 
b/drivers/md/dm-vdo/indexer/open-chapter.h
index a4250bb19525..ea6d7336aea0 100644
--- a/drivers/md/dm-vdo/indexer/open-chapter.h
+++ b/drivers/md/dm-vdo/indexer/open-chapter.h
@@ -40,7 +40,7 @@ struct open_chapter_zone {
        /* The number of slots in the hash table */
        unsigned int slot_count;
        /* The hash table slots, referencing virtual record numbers */
-       struct open_chapter_zone_slot slots[];
+       struct open_chapter_zone_slot slots[] __counted_by(slot_count);
 };
 
 int __must_check uds_make_open_chapter(const struct index_geometry *geometry,
diff --git a/drivers/md/dm-vdo/logical-zone.h b/drivers/md/dm-vdo/logical-zone.h
index 1b666c84a193..a36a864c6836 100644
--- a/drivers/md/dm-vdo/logical-zone.h
+++ b/drivers/md/dm-vdo/logical-zone.h
@@ -60,7 +60,7 @@ struct logical_zones {
        /* The number of zones */
        zone_count_t zone_count;
        /* The logical zones themselves */
-       struct logical_zone zones[];
+       struct logical_zone zones[] __counted_by(zone_count);
 };
 
 int __must_check vdo_make_logical_zones(struct vdo *vdo,
diff --git a/drivers/md/dm-vdo/physical-zone.c 
b/drivers/md/dm-vdo/physical-zone.c
index a8c7a57516eb..d6ad8f1a33bb 100644
--- a/drivers/md/dm-vdo/physical-zone.c
+++ b/drivers/md/dm-vdo/physical-zone.c
@@ -200,7 +200,7 @@ struct pbn_lock_pool {
        /** @idle_list: A list containing all idle PBN lock instances. */
        struct list_head idle_list;
        /** @locks: The memory for all the locks allocated by this pool. */
-       idle_pbn_lock locks[];
+       idle_pbn_lock locks[] __counted_by(capacity);
 };
 
 /**
diff --git a/drivers/md/dm-vdo/repair.c b/drivers/md/dm-vdo/repair.c
index 43ce65a69e61..bfed62260280 100644
--- a/drivers/md/dm-vdo/repair.c
+++ b/drivers/md/dm-vdo/repair.c
@@ -127,7 +127,7 @@ struct repair_completion {
         * The page completions used for playing the journal into the block 
map, and, during
         * read-only rebuild, for rebuilding the reference counts from the 
block map.
         */
-       struct vdo_page_completion page_completions[];
+       struct vdo_page_completion page_completions[] __counted_by(page_count);
 };
 
 /*
diff --git a/drivers/md/dm-vdo/slab-depot.h b/drivers/md/dm-vdo/slab-depot.h
index fadc0c9d4dc4..6bfd61c937b6 100644
--- a/drivers/md/dm-vdo/slab-depot.h
+++ b/drivers/md/dm-vdo/slab-depot.h
@@ -509,7 +509,7 @@ struct slab_depot {
        struct slab_summary_entry *summary_entries;
 
        /* The block allocators for this depot */
-       struct block_allocator allocators[];
+       struct block_allocator allocators[] __counted_by(zone_count);
 };
 
 struct reference_updater;
-- 
2.53.0


Reply via email to