aboutsummaryrefslogtreecommitdiff
path: root/lib/test_ubsan.c
diff options
context:
space:
mode:
authorGravatar Kees Cook <keescook@chromium.org> 2024-01-30 14:12:55 -0800
committerGravatar Kees Cook <keescook@chromium.org> 2024-02-06 02:21:38 -0800
commit30edbdf9b98ddc9087f5f8b9a9644fa5c05fa5b1 (patch)
treeca2a60555c0217a9160f79c9f020d135e3744209 /lib/test_ubsan.c
parentubsan: Use Clang's -fsanitize-trap=undefined option (diff)
downloadlinux-30edbdf9b98ddc9087f5f8b9a9644fa5c05fa5b1.tar.gz
linux-30edbdf9b98ddc9087f5f8b9a9644fa5c05fa5b1.tar.bz2
linux-30edbdf9b98ddc9087f5f8b9a9644fa5c05fa5b1.zip
ubsan: Silence W=1 warnings in self-test
Silence a handful of W=1 warnings in the UBSan selftest, which set variables without using them. For example: lib/test_ubsan.c:101:6: warning: variable 'val1' set but not used [-Wunused-but-set-variable] 101 | int val1 = 10; | ^ Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202401310423.XpCIk6KO-lkp@intel.com/ Reviewed-by: Marco Elver <elver@google.com> Signed-off-by: Kees Cook <keescook@chromium.org>
Diffstat (limited to 'lib/test_ubsan.c')
-rw-r--r--lib/test_ubsan.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/test_ubsan.c b/lib/test_ubsan.c
index 2062be1f2e80..f4ee2484d4b5 100644
--- a/lib/test_ubsan.c
+++ b/lib/test_ubsan.c
@@ -23,8 +23,8 @@ static void test_ubsan_divrem_overflow(void)
static void test_ubsan_shift_out_of_bounds(void)
{
volatile int neg = -1, wrap = 4;
- int val1 = 10;
- int val2 = INT_MAX;
+ volatile int val1 = 10;
+ volatile int val2 = INT_MAX;
UBSAN_TEST(CONFIG_UBSAN_SHIFT, "negative exponent");
val1 <<= neg;