Kees Cook 2461ffdc77 lib: stackinit: hide never-taken branch from compiler
[ Upstream commit 5c3793604f91123bf49bc792ce697a0bef4c173c ]

The never-taken branch leads to an invalid bounds condition, which is by
design. To avoid the unwanted warning from the compiler, hide the
variable from the optimizer.

../lib/stackinit_kunit.c: In function 'do_nothing_u16_zero':
../lib/stackinit_kunit.c:51:49: error: array subscript 1 is outside array bounds of 'u16[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds=]
   51 | #define DO_NOTHING_RETURN_SCALAR(ptr)           *(ptr)
      |                                                 ^~~~~~
../lib/stackinit_kunit.c:219:24: note: in expansion of macro 'DO_NOTHING_RETURN_SCALAR'
  219 |                 return DO_NOTHING_RETURN_ ## which(ptr + 1);    \
      |                        ^~~~~~~~~~~~~~~~~~

Link: https://lkml.kernel.org/r/20241117113813.work.735-kees@kernel.org
Signed-off-by: Kees Cook <kees@kernel.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-01-09 13:28:41 +01:00
..
2024-07-18 13:07:29 +02:00
2021-07-08 11:48:20 -07:00
2021-07-08 11:48:20 -07:00
2024-10-17 15:10:56 +02:00
2021-07-08 11:48:20 -07:00
2021-05-06 19:24:12 -07:00
2018-08-16 12:14:42 -07:00
2021-01-21 14:06:00 -07:00
2021-06-05 08:58:12 -07:00
2021-08-19 09:02:55 +09:00
2021-07-08 11:48:20 -07:00
2021-01-03 20:05:18 -05:00
2021-08-19 09:02:55 +09:00
2022-06-22 14:22:03 +02:00
2021-07-08 11:48:20 -07:00
2021-07-08 11:48:20 -07:00
2022-06-22 14:22:03 +02:00
2018-10-16 13:45:44 +02:00
2022-06-22 14:22:03 +02:00
2021-07-08 11:48:20 -07:00
2021-09-17 13:52:17 +01:00
2021-07-08 11:48:20 -07:00
2021-07-08 11:48:20 -07:00
2021-07-08 11:48:20 -07:00
2021-07-08 11:48:20 -07:00
2021-07-08 11:48:20 -07:00
2021-06-18 11:43:09 +02:00
2021-07-08 11:48:20 -07:00