From ca82230780c28645d6fa610960ee56ce2ba60c2a Mon Sep 17 00:00:00 2001 From: Andy Ross Date: Wed, 21 Aug 2019 16:30:32 -0700 Subject: [PATCH] tests/kernel/fp_sharing: Fix static analysis warning Can't use a volatile variable in something that the tool thinks is an optional assert, because the read is treated as a side effect. Fixes #18438 Fixes #18439 Signed-off-by: Andy Ross --- .../fp_sharing/float_disable/src/k_float_disable.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/kernel/fp_sharing/float_disable/src/k_float_disable.c b/tests/kernel/fp_sharing/float_disable/src/k_float_disable.c index b91dd5e017c..53d865d41af 100644 --- a/tests/kernel/fp_sharing/float_disable/src/k_float_disable.c +++ b/tests/kernel/fp_sharing/float_disable/src/k_float_disable.c @@ -139,7 +139,10 @@ void test_k_float_disable_syscall(void) "usr_fp_thread FP options not clear (0x%0x)", usr_fp_thread.base.user_options); - zassert_true(ret == TC_PASS, ""); + /* ret is volatile, static analysis says we can't use in assert */ + bool ok = ret == TC_PASS; + + zassert_true(ok, ""); #else /* Check skipped for x86 without support for Lazy FP Sharing */ #endif @@ -237,7 +240,10 @@ void test_k_float_disable_irq(void) /* Yield will swap-in sup_fp_thread */ k_yield(); - zassert_true(ret == TC_PASS, ""); + /* ret is volatile, static analysis says we can't use in assert */ + bool ok = ret == TC_PASS; + + zassert_true(ok, ""); } #else void test_k_float_disable_irq(void)