Re: [PATCH 2/2] dm-bufio: Use struct_size() helper in kmalloc()

From: kernel test robot

Date: Fri Mar 06 2026 - 14:13:08 EST


Hi luoqing,

kernel test robot noticed the following build errors:

[auto build test ERROR on axboe/for-next]
[also build test ERROR on device-mapper-dm/for-next linus/master v7.0-rc2 next-20260306]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/luoqing/dm-bufio-Use-struct_size-helper-in-kmalloc/20260306-165625
base: https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux.git for-next
patch link: https://lore.kernel.org/r/20260306080257.1268206-1-l1138897701%40163.com
patch subject: [PATCH 2/2] dm-bufio: Use struct_size() helper in kmalloc()
config: m68k-defconfig (https://download.01.org/0day-ci/archive/20260307/202603070341.J8qZJaCg-lkp@xxxxxxxxx/config)
compiler: m68k-linux-gcc (GCC) 15.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260307/202603070341.J8qZJaCg-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202603070341.J8qZJaCg-lkp@xxxxxxxxx/

All errors (new ones prefixed by >>):

In file included from include/linux/workqueue.h:9,
from include/linux/mm_types.h:19,
from include/linux/mmzone.h:22,
from include/linux/gfp.h:7,
from include/linux/xarray.h:16,
from include/linux/list_lru.h:14,
from include/linux/fs/super_types.h:7,
from include/linux/fs/super.h:5,
from include/linux/fs.h:5,
from include/linux/highmem.h:5,
from include/linux/bvec.h:10,
from include/linux/blk_types.h:10,
from include/linux/blkdev.h:9,
from include/linux/dm-bufio.h:13,
from drivers/md/dm-bufio.c:10:
drivers/md/dm-bufio.c: In function 'dm_bufio_client_create':
>> include/linux/overflow.h:420:38: error: 'struct dm_bufio_client' has no member named 'buffer_tree'
420 | (count) * sizeof(*(p)->member) + __must_be_array((p)->member), \
| ^~
include/linux/alloc_tag.h:251:16: note: in definition of macro 'alloc_hooks_tag'
251 | typeof(_do_alloc) _res; \
| ^~~~~~~~~
include/linux/slab.h:1190:49: note: in expansion of macro 'alloc_hooks'
1190 | #define kzalloc(...) alloc_hooks(kzalloc_noprof(__VA_ARGS__))
| ^~~~~~~~~~~
drivers/md/dm-bufio.c:2514:13: note: in expansion of macro 'kzalloc'
2514 | c = kzalloc(struct_size(c, buffer_tree, num_locks), GFP_KERNEL);
| ^~~~~~~
include/linux/overflow.h:436:32: note: in expansion of macro 'flex_array_size'
436 | sizeof(*(p)) + flex_array_size(p, member, count), \
| ^~~~~~~~~~~~~~~
drivers/md/dm-bufio.c:2514:21: note: in expansion of macro 'struct_size'
2514 | c = kzalloc(struct_size(c, buffer_tree, num_locks), GFP_KERNEL);
| ^~~~~~~~~~~
include/linux/overflow.h:420:69: error: 'struct dm_bufio_client' has no member named 'buffer_tree'
420 | (count) * sizeof(*(p)->member) + __must_be_array((p)->member), \
| ^~
include/linux/alloc_tag.h:251:16: note: in definition of macro 'alloc_hooks_tag'
251 | typeof(_do_alloc) _res; \
| ^~~~~~~~~
include/linux/slab.h:1190:49: note: in expansion of macro 'alloc_hooks'
1190 | #define kzalloc(...) alloc_hooks(kzalloc_noprof(__VA_ARGS__))
| ^~~~~~~~~~~
drivers/md/dm-bufio.c:2514:13: note: in expansion of macro 'kzalloc'
2514 | c = kzalloc(struct_size(c, buffer_tree, num_locks), GFP_KERNEL);
| ^~~~~~~
include/linux/compiler.h:208:33: note: in expansion of macro '__BUILD_BUG_ON_ZERO_MSG'
208 | #define __must_be_array(a) __BUILD_BUG_ON_ZERO_MSG(!__is_array(a), \
| ^~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler.h:207:35: note: in expansion of macro '__same_type'
207 | #define __is_array(a) (!__same_type((a), &(a)[0]))
| ^~~~~~~~~~~
include/linux/compiler.h:208:58: note: in expansion of macro '__is_array'
208 | #define __must_be_array(a) __BUILD_BUG_ON_ZERO_MSG(!__is_array(a), \
| ^~~~~~~~~~
include/linux/overflow.h:420:50: note: in expansion of macro '__must_be_array'
420 | (count) * sizeof(*(p)->member) + __must_be_array((p)->member), \
| ^~~~~~~~~~~~~~~
include/linux/overflow.h:436:32: note: in expansion of macro 'flex_array_size'
436 | sizeof(*(p)) + flex_array_size(p, member, count), \
| ^~~~~~~~~~~~~~~
drivers/md/dm-bufio.c:2514:21: note: in expansion of macro 'struct_size'
2514 | c = kzalloc(struct_size(c, buffer_tree, num_locks), GFP_KERNEL);
| ^~~~~~~~~~~
include/linux/overflow.h:420:69: error: 'struct dm_bufio_client' has no member named 'buffer_tree'
420 | (count) * sizeof(*(p)->member) + __must_be_array((p)->member), \
| ^~
include/linux/alloc_tag.h:251:16: note: in definition of macro 'alloc_hooks_tag'
251 | typeof(_do_alloc) _res; \
| ^~~~~~~~~
include/linux/slab.h:1190:49: note: in expansion of macro 'alloc_hooks'
1190 | #define kzalloc(...) alloc_hooks(kzalloc_noprof(__VA_ARGS__))
| ^~~~~~~~~~~
drivers/md/dm-bufio.c:2514:13: note: in expansion of macro 'kzalloc'
2514 | c = kzalloc(struct_size(c, buffer_tree, num_locks), GFP_KERNEL);
| ^~~~~~~
include/linux/compiler.h:208:33: note: in expansion of macro '__BUILD_BUG_ON_ZERO_MSG'
208 | #define __must_be_array(a) __BUILD_BUG_ON_ZERO_MSG(!__is_array(a), \
| ^~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler.h:207:35: note: in expansion of macro '__same_type'
207 | #define __is_array(a) (!__same_type((a), &(a)[0]))
| ^~~~~~~~~~~
include/linux/compiler.h:208:58: note: in expansion of macro '__is_array'
208 | #define __must_be_array(a) __BUILD_BUG_ON_ZERO_MSG(!__is_array(a), \
| ^~~~~~~~~~
include/linux/overflow.h:420:50: note: in expansion of macro '__must_be_array'
420 | (count) * sizeof(*(p)->member) + __must_be_array((p)->member), \
| ^~~~~~~~~~~~~~~
include/linux/overflow.h:436:32: note: in expansion of macro 'flex_array_size'
436 | sizeof(*(p)) + flex_array_size(p, member, count), \
| ^~~~~~~~~~~~~~~
drivers/md/dm-bufio.c:2514:21: note: in expansion of macro 'struct_size'
2514 | c = kzalloc(struct_size(c, buffer_tree, num_locks), GFP_KERNEL);
| ^~~~~~~~~~~
include/linux/compiler.h:203:82: error: expression in static assertion is not an integer
203 | #define __BUILD_BUG_ON_ZERO_MSG(e, msg, ...) ((int)sizeof(struct {_Static_assert(!(e), msg);}))
| ^
include/linux/alloc_tag.h:251:16: note: in definition of macro 'alloc_hooks_tag'
251 | typeof(_do_alloc) _res; \
| ^~~~~~~~~
include/linux/slab.h:1190:49: note: in expansion of macro 'alloc_hooks'
1190 | #define kzalloc(...) alloc_hooks(kzalloc_noprof(__VA_ARGS__))
| ^~~~~~~~~~~
drivers/md/dm-bufio.c:2514:13: note: in expansion of macro 'kzalloc'
2514 | c = kzalloc(struct_size(c, buffer_tree, num_locks), GFP_KERNEL);
| ^~~~~~~
include/linux/compiler.h:208:33: note: in expansion of macro '__BUILD_BUG_ON_ZERO_MSG'
208 | #define __must_be_array(a) __BUILD_BUG_ON_ZERO_MSG(!__is_array(a), \
| ^~~~~~~~~~~~~~~~~~~~~~~
include/linux/overflow.h:420:50: note: in expansion of macro '__must_be_array'
420 | (count) * sizeof(*(p)->member) + __must_be_array((p)->member), \
| ^~~~~~~~~~~~~~~
include/linux/overflow.h:436:32: note: in expansion of macro 'flex_array_size'
436 | sizeof(*(p)) + flex_array_size(p, member, count), \
| ^~~~~~~~~~~~~~~
drivers/md/dm-bufio.c:2514:21: note: in expansion of macro 'struct_size'
2514 | c = kzalloc(struct_size(c, buffer_tree, num_locks), GFP_KERNEL);
--
| ^~
include/linux/alloc_tag.h:251:16: note: in definition of macro 'alloc_hooks_tag'
251 | typeof(_do_alloc) _res; \
| ^~~~~~~~~
include/linux/slab.h:1190:49: note: in expansion of macro 'alloc_hooks'
1190 | #define kzalloc(...) alloc_hooks(kzalloc_noprof(__VA_ARGS__))
| ^~~~~~~~~~~
drivers/md/dm-bufio.c:2514:13: note: in expansion of macro 'kzalloc'
2514 | c = kzalloc(struct_size(c, buffer_tree, num_locks), GFP_KERNEL);
| ^~~~~~~
include/linux/overflow.h:436:32: note: in expansion of macro 'flex_array_size'
436 | sizeof(*(p)) + flex_array_size(p, member, count), \
| ^~~~~~~~~~~~~~~
drivers/md/dm-bufio.c:2514:21: note: in expansion of macro 'struct_size'
2514 | c = kzalloc(struct_size(c, buffer_tree, num_locks), GFP_KERNEL);
| ^~~~~~~~~~~
include/linux/overflow.h:421:75: error: 'struct dm_bufio_client' has no member named 'buffer_tree'
421 | size_mul(count, sizeof(*(p)->member) + __must_be_array((p)->member)))
| ^~
include/linux/alloc_tag.h:251:16: note: in definition of macro 'alloc_hooks_tag'
251 | typeof(_do_alloc) _res; \
| ^~~~~~~~~
include/linux/slab.h:1190:49: note: in expansion of macro 'alloc_hooks'
1190 | #define kzalloc(...) alloc_hooks(kzalloc_noprof(__VA_ARGS__))
| ^~~~~~~~~~~
drivers/md/dm-bufio.c:2514:13: note: in expansion of macro 'kzalloc'
2514 | c = kzalloc(struct_size(c, buffer_tree, num_locks), GFP_KERNEL);
| ^~~~~~~
include/linux/compiler.h:208:33: note: in expansion of macro '__BUILD_BUG_ON_ZERO_MSG'
208 | #define __must_be_array(a) __BUILD_BUG_ON_ZERO_MSG(!__is_array(a), \
| ^~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler.h:207:35: note: in expansion of macro '__same_type'
207 | #define __is_array(a) (!__same_type((a), &(a)[0]))
| ^~~~~~~~~~~
include/linux/compiler.h:208:58: note: in expansion of macro '__is_array'
208 | #define __must_be_array(a) __BUILD_BUG_ON_ZERO_MSG(!__is_array(a), \
| ^~~~~~~~~~
include/linux/overflow.h:421:56: note: in expansion of macro '__must_be_array'
421 | size_mul(count, sizeof(*(p)->member) + __must_be_array((p)->member)))
| ^~~~~~~~~~~~~~~
include/linux/overflow.h:436:32: note: in expansion of macro 'flex_array_size'
436 | sizeof(*(p)) + flex_array_size(p, member, count), \
| ^~~~~~~~~~~~~~~
drivers/md/dm-bufio.c:2514:21: note: in expansion of macro 'struct_size'
2514 | c = kzalloc(struct_size(c, buffer_tree, num_locks), GFP_KERNEL);
| ^~~~~~~~~~~
include/linux/overflow.h:421:75: error: 'struct dm_bufio_client' has no member named 'buffer_tree'
421 | size_mul(count, sizeof(*(p)->member) + __must_be_array((p)->member)))
| ^~
include/linux/alloc_tag.h:251:16: note: in definition of macro 'alloc_hooks_tag'
251 | typeof(_do_alloc) _res; \
| ^~~~~~~~~
include/linux/slab.h:1190:49: note: in expansion of macro 'alloc_hooks'
1190 | #define kzalloc(...) alloc_hooks(kzalloc_noprof(__VA_ARGS__))
| ^~~~~~~~~~~
drivers/md/dm-bufio.c:2514:13: note: in expansion of macro 'kzalloc'
2514 | c = kzalloc(struct_size(c, buffer_tree, num_locks), GFP_KERNEL);
| ^~~~~~~
include/linux/compiler.h:208:33: note: in expansion of macro '__BUILD_BUG_ON_ZERO_MSG'
208 | #define __must_be_array(a) __BUILD_BUG_ON_ZERO_MSG(!__is_array(a), \
| ^~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler.h:207:35: note: in expansion of macro '__same_type'
207 | #define __is_array(a) (!__same_type((a), &(a)[0]))
| ^~~~~~~~~~~
include/linux/compiler.h:208:58: note: in expansion of macro '__is_array'
208 | #define __must_be_array(a) __BUILD_BUG_ON_ZERO_MSG(!__is_array(a), \
| ^~~~~~~~~~
include/linux/overflow.h:421:56: note: in expansion of macro '__must_be_array'
421 | size_mul(count, sizeof(*(p)->member) + __must_be_array((p)->member)))
| ^~~~~~~~~~~~~~~
include/linux/overflow.h:436:32: note: in expansion of macro 'flex_array_size'
436 | sizeof(*(p)) + flex_array_size(p, member, count), \
| ^~~~~~~~~~~~~~~
drivers/md/dm-bufio.c:2514:21: note: in expansion of macro 'struct_size'
2514 | c = kzalloc(struct_size(c, buffer_tree, num_locks), GFP_KERNEL);
| ^~~~~~~~~~~
include/linux/compiler.h:203:82: error: expression in static assertion is not an integer
203 | #define __BUILD_BUG_ON_ZERO_MSG(e, msg, ...) ((int)sizeof(struct {_Static_assert(!(e), msg);}))
| ^
include/linux/alloc_tag.h:251:16: note: in definition of macro 'alloc_hooks_tag'
251 | typeof(_do_alloc) _res; \
| ^~~~~~~~~
include/linux/slab.h:1190:49: note: in expansion of macro 'alloc_hooks'
1190 | #define kzalloc(...) alloc_hooks(kzalloc_noprof(__VA_ARGS__))
| ^~~~~~~~~~~
drivers/md/dm-bufio.c:2514:13: note: in expansion of macro 'kzalloc'
2514 | c = kzalloc(struct_size(c, buffer_tree, num_locks), GFP_KERNEL);
| ^~~~~~~
include/linux/compiler.h:208:33: note: in expansion of macro '__BUILD_BUG_ON_ZERO_MSG'
208 | #define __must_be_array(a) __BUILD_BUG_ON_ZERO_MSG(!__is_array(a), \
| ^~~~~~~~~~~~~~~~~~~~~~~
include/linux/overflow.h:421:56: note: in expansion of macro '__must_be_array'
421 | size_mul(count, sizeof(*(p)->member) + __must_be_array((p)->member)))
| ^~~~~~~~~~~~~~~
include/linux/overflow.h:436:32: note: in expansion of macro 'flex_array_size'
436 | sizeof(*(p)) + flex_array_size(p, member, count), \
| ^~~~~~~~~~~~~~~
drivers/md/dm-bufio.c:2514:21: note: in expansion of macro 'struct_size'
2514 | c = kzalloc(struct_size(c, buffer_tree, num_locks), GFP_KERNEL);
| ^~~~~~~~~~~
>> include/linux/overflow.h:420:38: error: 'struct dm_bufio_client' has no member named 'buffer_tree'
420 | (count) * sizeof(*(p)->member) + __must_be_array((p)->member), \
| ^~
include/linux/alloc_tag.h:251:16: note: in definition of macro 'alloc_hooks_tag'
251 | typeof(_do_alloc) _res; \
| ^~~~~~~~~
include/linux/slab.h:1190:49: note: in expansion of macro 'alloc_hooks'
1190 | #define kzalloc(...) alloc_hooks(kzalloc_noprof(__VA_ARGS__))
| ^~~~~~~~~~~
drivers/md/dm-bufio.c:2514:13: note: in expansion of macro 'kzalloc'
2514 | c = kzalloc(struct_size(c, buffer_tree, num_locks), GFP_KERNEL);
| ^~~~~~~
include/linux/overflow.h:437:40: note: in expansion of macro 'flex_array_size'
437 | size_add(sizeof(*(p)), flex_array_size(p, member, count)))
| ^~~~~~~~~~~~~~~
drivers/md/dm-bufio.c:2514:21: note: in expansion of macro 'struct_size'
2514 | c = kzalloc(struct_size(c, buffer_tree, num_locks), GFP_KERNEL);
| ^~~~~~~~~~~
include/linux/overflow.h:420:69: error: 'struct dm_bufio_client' has no member named 'buffer_tree'
420 | (count) * sizeof(*(p)->member) + __must_be_array((p)->member), \
| ^~
include/linux/alloc_tag.h:251:16: note: in definition of macro 'alloc_hooks_tag'
251 | typeof(_do_alloc) _res; \
| ^~~~~~~~~
include/linux/slab.h:1190:49: note: in expansion of macro 'alloc_hooks'
1190 | #define kzalloc(...) alloc_hooks(kzalloc_noprof(__VA_ARGS__))
| ^~~~~~~~~~~
drivers/md/dm-bufio.c:2514:13: note: in expansion of macro 'kzalloc'
2514 | c = kzalloc(struct_size(c, buffer_tree, num_locks), GFP_KERNEL);
| ^~~~~~~
include/linux/compiler.h:208:33: note: in expansion of macro '__BUILD_BUG_ON_ZERO_MSG'
208 | #define __must_be_array(a) __BUILD_BUG_ON_ZERO_MSG(!__is_array(a), \
| ^~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler.h:207:35: note: in expansion of macro '__same_type'
207 | #define __is_array(a) (!__same_type((a), &(a)[0]))
| ^~~~~~~~~~~
include/linux/compiler.h:208:58: note: in expansion of macro '__is_array'
208 | #define __must_be_array(a) __BUILD_BUG_ON_ZERO_MSG(!__is_array(a), \
| ^~~~~~~~~~
include/linux/overflow.h:420:50: note: in expansion of macro '__must_be_array'
420 | (count) * sizeof(*(p)->member) + __must_be_array((p)->member), \
| ^~~~~~~~~~~~~~~
include/linux/overflow.h:437:40: note: in expansion of macro 'flex_array_size'
437 | size_add(sizeof(*(p)), flex_array_size(p, member, count)))
| ^~~~~~~~~~~~~~~
drivers/md/dm-bufio.c:2514:21: note: in expansion of macro 'struct_size'
2514 | c = kzalloc(struct_size(c, buffer_tree, num_locks), GFP_KERNEL);
| ^~~~~~~~~~~
include/linux/overflow.h:420:69: error: 'struct dm_bufio_client' has no member named 'buffer_tree'
420 | (count) * sizeof(*(p)->member) + __must_be_array((p)->member), \
| ^~
include/linux/alloc_tag.h:251:16: note: in definition of macro 'alloc_hooks_tag'
251 | typeof(_do_alloc) _res; \
| ^~~~~~~~~
include/linux/slab.h:1190:49: note: in expansion of macro 'alloc_hooks'
1190 | #define kzalloc(...) alloc_hooks(kzalloc_noprof(__VA_ARGS__))
| ^~~~~~~~~~~
drivers/md/dm-bufio.c:2514:13: note: in expansion of macro 'kzalloc'
2514 | c = kzalloc(struct_size(c, buffer_tree, num_locks), GFP_KERNEL);
| ^~~~~~~
include/linux/compiler.h:208:33: note: in expansion of macro '__BUILD_BUG_ON_ZERO_MSG'
208 | #define __must_be_array(a) __BUILD_BUG_ON_ZERO_MSG(!__is_array(a), \
| ^~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler.h:207:35: note: in expansion of macro '__same_type'
207 | #define __is_array(a) (!__same_type((a), &(a)[0]))
| ^~~~~~~~~~~
include/linux/compiler.h:208:58: note: in expansion of macro '__is_array'
208 | #define __must_be_array(a) __BUILD_BUG_ON_ZERO_MSG(!__is_array(a), \
| ^~~~~~~~~~
include/linux/overflow.h:420:50: note: in expansion of macro '__must_be_array'
420 | (count) * sizeof(*(p)->member) + __must_be_array((p)->member), \
| ^~~~~~~~~~~~~~~
include/linux/overflow.h:437:40: note: in expansion of macro 'flex_array_size'
437 | size_add(sizeof(*(p)), flex_array_size(p, member, count)))
| ^~~~~~~~~~~~~~~
drivers/md/dm-bufio.c:2514:21: note: in expansion of macro 'struct_size'
2514 | c = kzalloc(struct_size(c, buffer_tree, num_locks), GFP_KERNEL);
| ^~~~~~~~~~~
include/linux/compiler.h:203:82: error: expression in static assertion is not an integer
203 | #define __BUILD_BUG_ON_ZERO_MSG(e, msg, ...) ((int)sizeof(struct {_Static_assert(!(e), msg);}))
| ^
include/linux/alloc_tag.h:251:16: note: in definition of macro 'alloc_hooks_tag'
251 | typeof(_do_alloc) _res; \
| ^~~~~~~~~
include/linux/slab.h:1190:49: note: in expansion of macro 'alloc_hooks'
1190 | #define kzalloc(...) alloc_hooks(kzalloc_noprof(__VA_ARGS__))
| ^~~~~~~~~~~
drivers/md/dm-bufio.c:2514:13: note: in expansion of macro 'kzalloc'
2514 | c = kzalloc(struct_size(c, buffer_tree, num_locks), GFP_KERNEL);
| ^~~~~~~
include/linux/compiler.h:208:33: note: in expansion of macro '__BUILD_BUG_ON_ZERO_MSG'
208 | #define __must_be_array(a) __BUILD_BUG_ON_ZERO_MSG(!__is_array(a), \
| ^~~~~~~~~~~~~~~~~~~~~~~
include/linux/overflow.h:420:50: note: in expansion of macro '__must_be_array'
420 | (count) * sizeof(*(p)->member) + __must_be_array((p)->member), \
| ^~~~~~~~~~~~~~~
include/linux/overflow.h:437:40: note: in expansion of macro 'flex_array_size'
437 | size_add(sizeof(*(p)), flex_array_size(p, member, count)))
| ^~~~~~~~~~~~~~~
drivers/md/dm-bufio.c:2514:21: note: in expansion of macro 'struct_size'
2514 | c = kzalloc(struct_size(c, buffer_tree, num_locks), GFP_KERNEL);
..


vim +420 include/linux/overflow.h

610b15c50e86eb1 Kees Cook 2018-05-07 405
b19d57d0f3cc6f1 Gustavo A. R. Silva 2020-06-08 406 /**
b19d57d0f3cc6f1 Gustavo A. R. Silva 2020-06-08 407 * flex_array_size() - Calculate size of a flexible array member
b19d57d0f3cc6f1 Gustavo A. R. Silva 2020-06-08 408 * within an enclosing structure.
b19d57d0f3cc6f1 Gustavo A. R. Silva 2020-06-08 409 * @p: Pointer to the structure.
b19d57d0f3cc6f1 Gustavo A. R. Silva 2020-06-08 410 * @member: Name of the flexible array member.
b19d57d0f3cc6f1 Gustavo A. R. Silva 2020-06-08 411 * @count: Number of elements in the array.
b19d57d0f3cc6f1 Gustavo A. R. Silva 2020-06-08 412 *
b19d57d0f3cc6f1 Gustavo A. R. Silva 2020-06-08 413 * Calculates size of a flexible array of @count number of @member
b19d57d0f3cc6f1 Gustavo A. R. Silva 2020-06-08 414 * elements, at the end of structure @p.
b19d57d0f3cc6f1 Gustavo A. R. Silva 2020-06-08 415 *
b19d57d0f3cc6f1 Gustavo A. R. Silva 2020-06-08 416 * Return: number of bytes needed or SIZE_MAX on overflow.
b19d57d0f3cc6f1 Gustavo A. R. Silva 2020-06-08 417 */
b19d57d0f3cc6f1 Gustavo A. R. Silva 2020-06-08 418 #define flex_array_size(p, member, count) \
230f6fa2c1db6a3 Kees Cook 2022-02-09 419 __builtin_choose_expr(__is_constexpr(count), \
230f6fa2c1db6a3 Kees Cook 2022-02-09 @420 (count) * sizeof(*(p)->member) + __must_be_array((p)->member), \
230f6fa2c1db6a3 Kees Cook 2022-02-09 421 size_mul(count, sizeof(*(p)->member) + __must_be_array((p)->member)))
b19d57d0f3cc6f1 Gustavo A. R. Silva 2020-06-08 422

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki