summaryrefslogtreecommitdiffstats
path: root/fs/bcachefs/vstructs.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-09-09 20:10:11 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:10:12 -0400
commit5cfd69775eb5460ef78bb5034a37eb0dc52ab65d (patch)
tree26a5e49f14d153acbf243df39a75e38ffdc9f3d6 /fs/bcachefs/vstructs.h
parenta9a7bbab1469f0c427f90c309720c543e37ab110 (diff)
downloadlinux-5cfd69775eb5460ef78bb5034a37eb0dc52ab65d.tar.gz
linux-5cfd69775eb5460ef78bb5034a37eb0dc52ab65d.tar.bz2
linux-5cfd69775eb5460ef78bb5034a37eb0dc52ab65d.zip
bcachefs: Array bounds fixes
It's no longer legal to use a zero size array as a flexible array member - this causes UBSAN to complain. This patch switches our zero size arrays to normal flexible array members when possible, and inserts casts in other places (e.g. where we use the zero size array as a marker partway through an array). Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/vstructs.h')
-rw-r--r--fs/bcachefs/vstructs.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/fs/bcachefs/vstructs.h b/fs/bcachefs/vstructs.h
index 53a694d71967..a6561b4b36a6 100644
--- a/fs/bcachefs/vstructs.h
+++ b/fs/bcachefs/vstructs.h
@@ -41,11 +41,11 @@
(round_up(vstruct_bytes(_s), 512 << (_sector_block_bits)) >> 9)
#define vstruct_next(_s) \
- ((typeof(_s)) ((_s)->_data + __vstruct_u64s(_s)))
+ ((typeof(_s)) ((u64 *) (_s)->_data + __vstruct_u64s(_s)))
#define vstruct_last(_s) \
- ((typeof(&(_s)->start[0])) ((_s)->_data + __vstruct_u64s(_s)))
+ ((typeof(&(_s)->start[0])) ((u64 *) (_s)->_data + __vstruct_u64s(_s)))
#define vstruct_end(_s) \
- ((void *) ((_s)->_data + __vstruct_u64s(_s)))
+ ((void *) ((u64 *) (_s)->_data + __vstruct_u64s(_s)))
#define vstruct_for_each(_s, _i) \
for (_i = (_s)->start; \