]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/vstructs.h
Merge pull request #196 from Conan-Kudo/spec-libexecdir
[bcachefs-tools-debian] / libbcachefs / vstructs.h
index 53a694d71967196ad2784f89da5ea5c3966644a1..2ad338e282da8263f2025f5a9241d37767f0b1d0 100644 (file)
        (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;                                          \
+       for (typeof(&(_s)->start[0]) _i = (_s)->start;                  \
             _i < vstruct_last(_s);                                     \
             _i = vstruct_next(_i))
 
-#define vstruct_for_each_safe(_s, _i, _t)                              \
-       for (_i = (_s)->start;                                          \
-            _i < vstruct_last(_s) && (_t = vstruct_next(_i), true);    \
-            _i = _t)
+#define vstruct_for_each_safe(_s, _i)                                  \
+       for (typeof(&(_s)->start[0]) _next, _i = (_s)->start;           \
+            _i < vstruct_last(_s) && (_next = vstruct_next(_i), true); \
+            _i = _next)
 
 #define vstruct_idx(_s, _idx)                                          \
        ((typeof(&(_s)->start[0])) ((_s)->_data + (_idx)))