The following compile error has been observed with gcc 16:
super-intel.c: In function 'imsm_process_update':
super-intel.c:10069:43: error: '%d' directive writing between 1 and 11 bytes into a region of size 7 [-Werror=format-overflow=]
10069 | " MISSING_%d", du->index);
| ^~
In function 'apply_takeover_update',
inlined from 'imsm_process_update' at super-intel.c:10168:7:
super-intel.c:10069:33: note: directive argument in the range [-
2147483647,
2147483647]
10069 | " MISSING_%d", du->index);
| ^~~~~~~~~~~~~
In file included from /usr/include/stdio.h:970,
from mdadm.h:42,
from super-intel.c:21:
In function 'sprintf',
inlined from 'apply_takeover_update' at super-intel.c:10068:4,
inlined from 'imsm_process_update' at super-intel.c:10168:7:
/usr/include/bits/stdio2.h:30:10: note: '__builtin_sprintf' output between 11 and 21 bytes into a destination of size 16
30 | return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
31 | __glibc_objsize (__s), __fmt,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
32 | __va_arg_pack ());
| ~~~~~~~~~~~~~~~~~
Fix it by using an unsigned type for the index variable. This works
because map->num_members is an unsigned short.
Suggested-by: Mariusz Tkaczyk <mtkaczyk@kernel.org>
Signed-off-by: Martin Wilck <mwilck@suse.com>