* [PATCH 0/3] tests: three easy Coverity fixes
@ 2021-05-03 16:55 Peter Maydell
2021-05-03 16:55 ` [PATCH 1/3] tests/qtest/tpm-util.c: Free memory with correct free function Peter Maydell
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Peter Maydell @ 2021-05-03 16:55 UTC (permalink / raw)
To: qemu-devel
Cc: Laurent Vivier, Paolo Bonzini, Thomas Huth, Corey Minyard, Stefan Berger
We recently started running Coverity on our tests/ code,
which has revealed a pile of issues that we were previously
blissfully unaware of. This series fixes three easy ones:
* use of free() where g_free() was meant
* unnecessary NULL check
* side effect inside g_assert() argument
thanks
-- PMM
Peter Maydell (3):
tests/qtest/tpm-util.c: Free memory with correct free function
tests/qtest/rtc-test: Remove pointless NULL check
tests: Avoid side effects inside g_assert() arguments
tests/qtest/ipmi-bt-test.c | 6 ++++--
tests/qtest/ipmi-kcs-test.c | 3 ++-
tests/qtest/rtc-test.c | 6 ++----
tests/qtest/tpm-util.c | 4 ++--
4 files changed, 10 insertions(+), 9 deletions(-)
--
2.20.1
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/3] tests/qtest/tpm-util.c: Free memory with correct free function
2021-05-03 16:55 [PATCH 0/3] tests: three easy Coverity fixes Peter Maydell
@ 2021-05-03 16:55 ` Peter Maydell
2021-05-03 16:59 ` Stefan Berger
2021-05-04 8:44 ` Alex Bennée
2021-05-03 16:55 ` [PATCH 2/3] tests/qtest/rtc-test: Remove pointless NULL check Peter Maydell
2021-05-03 16:55 ` [PATCH 3/3] tests: Avoid side effects inside g_assert() arguments Peter Maydell
2 siblings, 2 replies; 12+ messages in thread
From: Peter Maydell @ 2021-05-03 16:55 UTC (permalink / raw)
To: qemu-devel
Cc: Laurent Vivier, Paolo Bonzini, Thomas Huth, Corey Minyard, Stefan Berger
tpm_util_migration_start_qemu() allocates memory with g_strdup_printf()
but frees it with free() rather than g_free(), which provokes Coverity
complaints (CID 1432379, 1432350). Use the correct free function.
Fixes: Coverity CID 1432379, CID 1432350
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
With newer glib (2.46 and up) g_free() is guaranteed to be the same
as free(), but matching things up is neater anyway.
---
tests/qtest/tpm-util.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/qtest/tpm-util.c b/tests/qtest/tpm-util.c
index b70cc32d600..3a40ff3f96c 100644
--- a/tests/qtest/tpm-util.c
+++ b/tests/qtest/tpm-util.c
@@ -289,6 +289,6 @@ void tpm_util_migration_start_qemu(QTestState **src_qemu,
*dst_qemu = qtest_init(dst_qemu_args);
- free(src_qemu_args);
- free(dst_qemu_args);
+ g_free(src_qemu_args);
+ g_free(dst_qemu_args);
}
--
2.20.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 2/3] tests/qtest/rtc-test: Remove pointless NULL check
2021-05-03 16:55 [PATCH 0/3] tests: three easy Coverity fixes Peter Maydell
2021-05-03 16:55 ` [PATCH 1/3] tests/qtest/tpm-util.c: Free memory with correct free function Peter Maydell
@ 2021-05-03 16:55 ` Peter Maydell
2021-05-04 5:43 ` Thomas Huth
2021-05-04 8:47 ` Alex Bennée
2021-05-03 16:55 ` [PATCH 3/3] tests: Avoid side effects inside g_assert() arguments Peter Maydell
2 siblings, 2 replies; 12+ messages in thread
From: Peter Maydell @ 2021-05-03 16:55 UTC (permalink / raw)
To: qemu-devel
Cc: Laurent Vivier, Paolo Bonzini, Thomas Huth, Corey Minyard, Stefan Berger
In rtc-test.c we know that s is non-NULL because qtest_start()
will return a non-NULL value, and we assume this when we
pass s to qtest_irq_intercept_in(). So we can drop the
initial assignment of NULL and the "if (s)" condition at
the end of the function.
Fixes: Coverity CID 1432353
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
tests/qtest/rtc-test.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/tests/qtest/rtc-test.c b/tests/qtest/rtc-test.c
index 402ce2c6090..8126ab1bdb8 100644
--- a/tests/qtest/rtc-test.c
+++ b/tests/qtest/rtc-test.c
@@ -686,7 +686,7 @@ static void periodic_timer(void)
int main(int argc, char **argv)
{
- QTestState *s = NULL;
+ QTestState *s;
int ret;
g_test_init(&argc, &argv, NULL);
@@ -712,9 +712,7 @@ int main(int argc, char **argv)
ret = g_test_run();
- if (s) {
- qtest_quit(s);
- }
+ qtest_quit(s);
return ret;
}
--
2.20.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 3/3] tests: Avoid side effects inside g_assert() arguments
2021-05-03 16:55 [PATCH 0/3] tests: three easy Coverity fixes Peter Maydell
2021-05-03 16:55 ` [PATCH 1/3] tests/qtest/tpm-util.c: Free memory with correct free function Peter Maydell
2021-05-03 16:55 ` [PATCH 2/3] tests/qtest/rtc-test: Remove pointless NULL check Peter Maydell
@ 2021-05-03 16:55 ` Peter Maydell
2021-05-03 17:14 ` Philippe Mathieu-Daudé
` (2 more replies)
2 siblings, 3 replies; 12+ messages in thread
From: Peter Maydell @ 2021-05-03 16:55 UTC (permalink / raw)
To: qemu-devel
Cc: Laurent Vivier, Paolo Bonzini, Thomas Huth, Corey Minyard, Stefan Berger
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>
---
tests/qtest/ipmi-bt-test.c | 6 ++++--
tests/qtest/ipmi-kcs-test.c | 3 ++-
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/tests/qtest/ipmi-bt-test.c b/tests/qtest/ipmi-bt-test.c
index a42207d416f..8492f02a9c3 100644
--- a/tests/qtest/ipmi-bt-test.c
+++ b/tests/qtest/ipmi-bt-test.c
@@ -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);
}
}
diff --git a/tests/qtest/ipmi-kcs-test.c b/tests/qtest/ipmi-kcs-test.c
index fc0a918c8d1..afc24dd3e46 100644
--- a/tests/qtest/ipmi-kcs-test.c
+++ b/tests/qtest/ipmi-kcs-test.c
@@ -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);
}
}
--
2.20.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 1/3] tests/qtest/tpm-util.c: Free memory with correct free function
2021-05-03 16:55 ` [PATCH 1/3] tests/qtest/tpm-util.c: Free memory with correct free function Peter Maydell
@ 2021-05-03 16:59 ` Stefan Berger
2021-05-04 8:44 ` Alex Bennée
1 sibling, 0 replies; 12+ messages in thread
From: Stefan Berger @ 2021-05-03 16:59 UTC (permalink / raw)
To: Peter Maydell, qemu-devel
Cc: Laurent Vivier, Paolo Bonzini, Thomas Huth, Corey Minyard, Stefan Berger
On 5/3/21 12:55 PM, Peter Maydell wrote:
> tpm_util_migration_start_qemu() allocates memory with g_strdup_printf()
> but frees it with free() rather than g_free(), which provokes Coverity
> complaints (CID 1432379, 1432350). Use the correct free function.
>
> Fixes: Coverity CID 1432379, CID 1432350
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> With newer glib (2.46 and up) g_free() is guaranteed to be the same
> as free(), but matching things up is neater anyway.
> ---
> tests/qtest/tpm-util.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tests/qtest/tpm-util.c b/tests/qtest/tpm-util.c
> index b70cc32d600..3a40ff3f96c 100644
> --- a/tests/qtest/tpm-util.c
> +++ b/tests/qtest/tpm-util.c
> @@ -289,6 +289,6 @@ void tpm_util_migration_start_qemu(QTestState **src_qemu,
>
> *dst_qemu = qtest_init(dst_qemu_args);
>
> - free(src_qemu_args);
> - free(dst_qemu_args);
> + g_free(src_qemu_args);
> + g_free(dst_qemu_args);
> }
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] tests: Avoid side effects inside g_assert() arguments
2021-05-03 16:55 ` [PATCH 3/3] tests: Avoid side effects inside g_assert() arguments Peter Maydell
@ 2021-05-03 17:14 ` Philippe Mathieu-Daudé
2021-05-04 7:18 ` Thomas Huth
2021-05-04 8:48 ` Alex Bennée
2 siblings, 0 replies; 12+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-05-03 17:14 UTC (permalink / raw)
To: Peter Maydell, qemu-devel
Cc: Laurent Vivier, Paolo Bonzini, Thomas Huth, Corey Minyard, Stefan Berger
On 5/3/21 6:55 PM, Peter Maydell wrote:
> 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>
> ---
> tests/qtest/ipmi-bt-test.c | 6 ++++--
> tests/qtest/ipmi-kcs-test.c | 3 ++-
> 2 files changed, 6 insertions(+), 3 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] tests/qtest/rtc-test: Remove pointless NULL check
2021-05-03 16:55 ` [PATCH 2/3] tests/qtest/rtc-test: Remove pointless NULL check Peter Maydell
@ 2021-05-04 5:43 ` Thomas Huth
2021-05-04 8:47 ` Alex Bennée
1 sibling, 0 replies; 12+ messages in thread
From: Thomas Huth @ 2021-05-04 5:43 UTC (permalink / raw)
To: Peter Maydell, qemu-devel
Cc: Laurent Vivier, Paolo Bonzini, Corey Minyard, Stefan Berger
On 03/05/2021 18.55, Peter Maydell wrote:
> In rtc-test.c we know that s is non-NULL because qtest_start()
> will return a non-NULL value, and we assume this when we
> pass s to qtest_irq_intercept_in(). So we can drop the
> initial assignment of NULL and the "if (s)" condition at
> the end of the function.
>
> Fixes: Coverity CID 1432353
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> tests/qtest/rtc-test.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/tests/qtest/rtc-test.c b/tests/qtest/rtc-test.c
> index 402ce2c6090..8126ab1bdb8 100644
> --- a/tests/qtest/rtc-test.c
> +++ b/tests/qtest/rtc-test.c
> @@ -686,7 +686,7 @@ static void periodic_timer(void)
>
> int main(int argc, char **argv)
> {
> - QTestState *s = NULL;
> + QTestState *s;
> int ret;
>
> g_test_init(&argc, &argv, NULL);
> @@ -712,9 +712,7 @@ int main(int argc, char **argv)
>
> ret = g_test_run();
>
> - if (s) {
> - qtest_quit(s);
> - }
> + qtest_quit(s);
>
> return ret;
> }
>
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] tests: Avoid side effects inside g_assert() arguments
2021-05-03 16:55 ` [PATCH 3/3] tests: Avoid side effects inside g_assert() arguments Peter Maydell
2021-05-03 17:14 ` Philippe Mathieu-Daudé
@ 2021-05-04 7:18 ` Thomas Huth
2021-05-04 8:46 ` Peter Maydell
2021-05-04 8:48 ` Alex Bennée
2 siblings, 1 reply; 12+ messages in thread
From: Thomas Huth @ 2021-05-04 7:18 UTC (permalink / raw)
To: Peter Maydell, qemu-devel
Cc: Laurent Vivier, Paolo Bonzini, Corey Minyard, Stefan Berger
On 03/05/2021 18.55, Peter Maydell wrote:
> 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>
> ---
> tests/qtest/ipmi-bt-test.c | 6 ++++--
> tests/qtest/ipmi-kcs-test.c | 3 ++-
> 2 files changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/tests/qtest/ipmi-bt-test.c b/tests/qtest/ipmi-bt-test.c
> index a42207d416f..8492f02a9c3 100644
> --- a/tests/qtest/ipmi-bt-test.c
> +++ b/tests/qtest/ipmi-bt-test.c
> @@ -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);
> }
> }
> diff --git a/tests/qtest/ipmi-kcs-test.c b/tests/qtest/ipmi-kcs-test.c
> index fc0a918c8d1..afc24dd3e46 100644
> --- a/tests/qtest/ipmi-kcs-test.c
> +++ b/tests/qtest/ipmi-kcs-test.c
> @@ -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);
> }
> }
According to
https://developer.gnome.org/glib/unstable/glib-Testing.html#g-assert
g_assert() should be avoided in unit tests and g_assert_true() should be
used instead. So I think it might be nicer to use g_assert_true() here?
Thomas
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/3] tests/qtest/tpm-util.c: Free memory with correct free function
2021-05-03 16:55 ` [PATCH 1/3] tests/qtest/tpm-util.c: Free memory with correct free function Peter Maydell
2021-05-03 16:59 ` Stefan Berger
@ 2021-05-04 8:44 ` Alex Bennée
1 sibling, 0 replies; 12+ messages in thread
From: Alex Bennée @ 2021-05-04 8:44 UTC (permalink / raw)
To: Peter Maydell
Cc: Laurent Vivier, Thomas Huth, Corey Minyard, Stefan Berger,
qemu-devel, Paolo Bonzini
Peter Maydell <peter.maydell@linaro.org> writes:
> tpm_util_migration_start_qemu() allocates memory with g_strdup_printf()
> but frees it with free() rather than g_free(), which provokes Coverity
> complaints (CID 1432379, 1432350). Use the correct free function.
>
> Fixes: Coverity CID 1432379, CID 1432350
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> With newer glib (2.46 and up) g_free() is guaranteed to be the same
> as free(), but matching things up is neater anyway.
> ---
> tests/qtest/tpm-util.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tests/qtest/tpm-util.c b/tests/qtest/tpm-util.c
> index b70cc32d600..3a40ff3f96c 100644
> --- a/tests/qtest/tpm-util.c
> +++ b/tests/qtest/tpm-util.c
> @@ -289,6 +289,6 @@ void tpm_util_migration_start_qemu(QTestState **src_qemu,
>
> *dst_qemu = qtest_init(dst_qemu_args);
>
> - free(src_qemu_args);
> - free(dst_qemu_args);
> + g_free(src_qemu_args);
> + g_free(dst_qemu_args);
> }
The more modern approach would be to use g_autofree but this works given
we aren't dealing with multiple exits:
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
--
Alex Bennée
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] tests: Avoid side effects inside g_assert() arguments
2021-05-04 7:18 ` Thomas Huth
@ 2021-05-04 8:46 ` Peter Maydell
0 siblings, 0 replies; 12+ messages in thread
From: Peter Maydell @ 2021-05-04 8:46 UTC (permalink / raw)
To: Thomas Huth
Cc: Laurent Vivier, Paolo Bonzini, QEMU Developers, Corey Minyard,
Stefan Berger
On Tue, 4 May 2021 at 08:18, Thomas Huth <thuth@redhat.com> wrote:
>
> On 03/05/2021 18.55, Peter Maydell wrote:
> > 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>
> > diff --git a/tests/qtest/ipmi-kcs-test.c b/tests/qtest/ipmi-kcs-test.c
> > index fc0a918c8d1..afc24dd3e46 100644
> > --- a/tests/qtest/ipmi-kcs-test.c
> > +++ b/tests/qtest/ipmi-kcs-test.c
> > @@ -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);
> > }
> > }
>
> According to
> https://developer.gnome.org/glib/unstable/glib-Testing.html#g-assert
> g_assert() should be avoided in unit tests and g_assert_true() should be
> used instead. So I think it might be nicer to use g_assert_true() here?
That probably depends on what we decide about whether we want to
use glib-testing-style "assert but this might not stop execution" in our
tests: see this thread:
https://lore.kernel.org/qemu-devel/CAFEAcA9juOChqrh5orybJQwpQsyEZ5z3Dvmy7fjX0DW4Nbgmrg@mail.gmail.com/
(I should have cc'd you and Laurent on that as qtest maintainers; sorry.)
-- PMM
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] tests/qtest/rtc-test: Remove pointless NULL check
2021-05-03 16:55 ` [PATCH 2/3] tests/qtest/rtc-test: Remove pointless NULL check Peter Maydell
2021-05-04 5:43 ` Thomas Huth
@ 2021-05-04 8:47 ` Alex Bennée
1 sibling, 0 replies; 12+ messages in thread
From: Alex Bennée @ 2021-05-04 8:47 UTC (permalink / raw)
To: Peter Maydell
Cc: Laurent Vivier, Thomas Huth, Corey Minyard, Stefan Berger,
qemu-devel, Paolo Bonzini
Peter Maydell <peter.maydell@linaro.org> writes:
> In rtc-test.c we know that s is non-NULL because qtest_start()
> will return a non-NULL value, and we assume this when we
> pass s to qtest_irq_intercept_in(). So we can drop the
> initial assignment of NULL and the "if (s)" condition at
> the end of the function.
>
> Fixes: Coverity CID 1432353
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
--
Alex Bennée
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] tests: Avoid side effects inside g_assert() arguments
2021-05-03 16:55 ` [PATCH 3/3] tests: Avoid side effects inside g_assert() arguments Peter Maydell
2021-05-03 17:14 ` Philippe Mathieu-Daudé
2021-05-04 7:18 ` Thomas Huth
@ 2021-05-04 8:48 ` Alex Bennée
2 siblings, 0 replies; 12+ messages in thread
From: Alex Bennée @ 2021-05-04 8:48 UTC (permalink / raw)
To: Peter Maydell
Cc: Laurent Vivier, Thomas Huth, Corey Minyard, Stefan Berger,
qemu-devel, Paolo Bonzini
Peter Maydell <peter.maydell@linaro.org> writes:
> 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>
> ---
> tests/qtest/ipmi-bt-test.c | 6 ++++--
> tests/qtest/ipmi-kcs-test.c | 3 ++-
> 2 files changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/tests/qtest/ipmi-bt-test.c b/tests/qtest/ipmi-bt-test.c
> index a42207d416f..8492f02a9c3 100644
> --- a/tests/qtest/ipmi-bt-test.c
> +++ b/tests/qtest/ipmi-bt-test.c
> @@ -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);
This does seem a little weird - we are not asserting an interface
violation just that the read should have cleared in 1000 * 100 usec. If
it doesn't is that really a theoretically impossible situation or just
an example of a failed test.
That said looking at how deeply buried in the test these helpers are an
assert is probably better than a convoluted attempt to return out and
exit the test with a failure.
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
> 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);
> }
> }
> diff --git a/tests/qtest/ipmi-kcs-test.c b/tests/qtest/ipmi-kcs-test.c
> index fc0a918c8d1..afc24dd3e46 100644
> --- a/tests/qtest/ipmi-kcs-test.c
> +++ b/tests/qtest/ipmi-kcs-test.c
> @@ -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);
> }
> }
--
Alex Bennée
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2021-05-04 9:04 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-03 16:55 [PATCH 0/3] tests: three easy Coverity fixes Peter Maydell
2021-05-03 16:55 ` [PATCH 1/3] tests/qtest/tpm-util.c: Free memory with correct free function Peter Maydell
2021-05-03 16:59 ` Stefan Berger
2021-05-04 8:44 ` Alex Bennée
2021-05-03 16:55 ` [PATCH 2/3] tests/qtest/rtc-test: Remove pointless NULL check Peter Maydell
2021-05-04 5:43 ` Thomas Huth
2021-05-04 8:47 ` Alex Bennée
2021-05-03 16:55 ` [PATCH 3/3] tests: Avoid side effects inside g_assert() arguments Peter Maydell
2021-05-03 17:14 ` Philippe Mathieu-Daudé
2021-05-04 7:18 ` Thomas Huth
2021-05-04 8:46 ` Peter Maydell
2021-05-04 8:48 ` Alex Bennée
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).