tests: Avoid side effects inside g_assert() arguments
authorPeter Maydell <peter.maydell@linaro.org>
Mon, 3 May 2021 16:55:25 +0000 (17:55 +0100)
committerThomas Huth <thuth@redhat.com>
Fri, 14 May 2021 10:28:01 +0000 (12:28 +0200)
For us, assertions are always enabled, but side-effect expressions
inside the argument to g_assert() are bad style anyway. Fix three
occurrences in IPMI related tests, which will silence some Coverity
nits.

Fixes: CID 1432322, CID 1432287, CID 1432291
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20210503165525.26221-4-peter.maydell@linaro.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
tests/qtest/ipmi-bt-test.c
tests/qtest/ipmi-kcs-test.c

index a42207d416ffcc0ae72dea8401e9f47d2516dd5f..8492f02a9c3db02f9bb7da770cae14b22a1d3ce4 100644 (file)
@@ -98,7 +98,8 @@ static void bt_wait_b_busy(void)
 {
     unsigned int count = 1000;
     while (IPMI_BT_CTLREG_GET_B_BUSY() != 0) {
-        g_assert(--count != 0);
+        --count;
+        g_assert(count != 0);
         usleep(100);
     }
 }
@@ -107,7 +108,8 @@ static void bt_wait_b2h_atn(void)
 {
     unsigned int count = 1000;
     while (IPMI_BT_CTLREG_GET_B2H_ATN() == 0) {
-        g_assert(--count != 0);
+        --count;
+        g_assert(count != 0);
         usleep(100);
     }
 }
index fc0a918c8d1f1bbe67a7897f0b6d0b6e3a4d3df5..afc24dd3e460821d291b16802c52766af9730ee0 100644 (file)
@@ -73,7 +73,8 @@ static void kcs_wait_ibf(void)
 {
     unsigned int count = 1000;
     while (IPMI_KCS_CMDREG_GET_IBF() != 0) {
-        g_assert(--count != 0);
+        --count;
+        g_assert(count != 0);
     }
 }