lib/memcpy_kunit.c:299 init_large() warn: calling memset(x, y, ARRAY_SIZE());

From: Dan Carpenter
Date: Tue Jan 03 2023 - 02:59:18 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: c8451c141e07a8d05693f6c8d0e418fbb4b68bb7
commit: 96fce387d58fa8eae6e8d9b1ecdfbc18292d7a68 kunit/memcpy: Add dynamic size and window tests
config: ia64-randconfig-m031-20221229
compiler: ia64-linux-gcc (GCC) 12.1.0

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Reported-by: Dan Carpenter <error27@xxxxxxxxx>

smatch warnings:
lib/memcpy_kunit.c:299 init_large() warn: calling memset(x, y, ARRAY_SIZE());

vim +299 lib/memcpy_kunit.c

96fce387d58fa8 Kees Cook 2022-09-28 290
96fce387d58fa8 Kees Cook 2022-09-28 291 /* Get many bit patterns. */
96fce387d58fa8 Kees Cook 2022-09-28 292 get_random_bytes(large_src, ARRAY_SIZE(large_src));
^^^^^^^^^^^^^^^^^^^^^

96fce387d58fa8 Kees Cook 2022-09-28 293
96fce387d58fa8 Kees Cook 2022-09-28 294 /* Make sure we have non-zero edges. */
96fce387d58fa8 Kees Cook 2022-09-28 295 set_random_nonzero(test, &large_src[0]);
96fce387d58fa8 Kees Cook 2022-09-28 296 set_random_nonzero(test, &large_src[ARRAY_SIZE(large_src) - 1]);
96fce387d58fa8 Kees Cook 2022-09-28 297
96fce387d58fa8 Kees Cook 2022-09-28 298 /* Explicitly zero the entire destination. */
96fce387d58fa8 Kees Cook 2022-09-28 @299 memset(large_dst, 0, ARRAY_SIZE(large_dst));

ARRAY_SIZE() is the number of elements. You want sizeof(). My guess is
that probably large_dst has the 1 byte elements, but you know...

96fce387d58fa8 Kees Cook 2022-09-28 300 }

--
0-DAY CI Kernel Test Service
https://01.org/lkp