Skip to content

Commit 3fcb62f

Browse files
committed
dm vdo: add __counted_by attribute to a number of structures
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 <raeburn@redhat.com>
1 parent c08503a commit 3fcb62f

8 files changed

Lines changed: 8 additions & 8 deletions

File tree

drivers/md/dm-vdo/block-map.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ struct block_map {
276276
block_count_t next_entry_count;
277277

278278
zone_count_t zone_count;
279-
struct block_map_zone zones[];
279+
struct block_map_zone zones[] __counted_by(zone_count);
280280
};
281281

282282
/**

drivers/md/dm-vdo/dedupe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ struct hash_zones {
296296
/* The number of zones */
297297
zone_count_t zone_count;
298298
/* The hash zones themselves */
299-
struct hash_zone zones[];
299+
struct hash_zone zones[] __counted_by(zone_count);
300300
};
301301

302302
/* These are in milliseconds. */

drivers/md/dm-vdo/indexer/index.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ struct uds_index {
5353

5454
index_callback_fn callback;
5555
struct uds_request_queue *triage_queue;
56-
struct uds_request_queue *zone_queues[];
56+
struct uds_request_queue *zone_queues[] __counted_by(zone_count);
5757
};
5858

5959
enum request_stage {

drivers/md/dm-vdo/indexer/open-chapter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ struct open_chapter_zone {
4040
/* The number of slots in the hash table */
4141
unsigned int slot_count;
4242
/* The hash table slots, referencing virtual record numbers */
43-
struct open_chapter_zone_slot slots[];
43+
struct open_chapter_zone_slot slots[] __counted_by(slot_count);
4444
};
4545

4646
int __must_check uds_make_open_chapter(const struct index_geometry *geometry,

drivers/md/dm-vdo/logical-zone.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ struct logical_zones {
6060
/* The number of zones */
6161
zone_count_t zone_count;
6262
/* The logical zones themselves */
63-
struct logical_zone zones[];
63+
struct logical_zone zones[] __counted_by(zone_count);
6464
};
6565

6666
int __must_check vdo_make_logical_zones(struct vdo *vdo,

drivers/md/dm-vdo/physical-zone.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ struct pbn_lock_pool {
200200
/** @idle_list: A list containing all idle PBN lock instances. */
201201
struct list_head idle_list;
202202
/** @locks: The memory for all the locks allocated by this pool. */
203-
idle_pbn_lock locks[];
203+
idle_pbn_lock locks[] __counted_by(capacity);
204204
};
205205

206206
/**

drivers/md/dm-vdo/repair.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ struct repair_completion {
127127
* The page completions used for playing the journal into the block map, and, during
128128
* read-only rebuild, for rebuilding the reference counts from the block map.
129129
*/
130-
struct vdo_page_completion page_completions[];
130+
struct vdo_page_completion page_completions[] __counted_by(page_count);
131131
};
132132

133133
/*

drivers/md/dm-vdo/slab-depot.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ struct slab_depot {
509509
struct slab_summary_entry *summary_entries;
510510

511511
/* The block allocators for this depot */
512-
struct block_allocator allocators[];
512+
struct block_allocator allocators[] __counted_by(zone_count);
513513
};
514514

515515
struct reference_updater;

0 commit comments

Comments
 (0)