diff mbox series

[1/3] tests/unit/test-qmp-event: Drop superfluous mutex

Message ID 20231122072456.2518816-2-armbru@redhat.com
State New
Headers show
Series tests/unit/test-qmp-event: Unconfuse Coverity & simplify | expand

Commit Message

Markus Armbruster Nov. 22, 2023, 7:24 a.m. UTC
Mutex @test_event_lock is held from fixture setup to teardown,
protecting global variable @test_event_data.  But tests always run one
after the other, so this is superfluous.  It also confuses Coverity.
Drop the mutex.

Fixes: CID 1527425
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 tests/unit/test-qmp-event.c | 5 -----
 1 file changed, 5 deletions(-)

Comments

Thomas Huth Nov. 22, 2023, 8:03 a.m. UTC | #1
On 22/11/2023 08.24, Markus Armbruster wrote:
> Mutex @test_event_lock is held from fixture setup to teardown,
> protecting global variable @test_event_data.  But tests always run one
> after the other, so this is superfluous.  It also confuses Coverity.
> Drop the mutex.
> 
> Fixes: CID 1527425
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>   tests/unit/test-qmp-event.c | 5 -----
>   1 file changed, 5 deletions(-)

Reviewed-by: Thomas Huth <thuth@redhat.com>
diff mbox series

Patch

diff --git a/tests/unit/test-qmp-event.c b/tests/unit/test-qmp-event.c
index 3626d2372f..c2c44687d5 100644
--- a/tests/unit/test-qmp-event.c
+++ b/tests/unit/test-qmp-event.c
@@ -30,7 +30,6 @@  typedef struct TestEventData {
 } TestEventData;
 
 TestEventData *test_event_data;
-static GMutex test_event_lock;
 
 void test_qapi_event_emit(test_QAPIEvent event, QDict *d)
 {
@@ -59,9 +58,6 @@  void test_qapi_event_emit(test_QAPIEvent event, QDict *d)
 static void event_prepare(TestEventData *data,
                           const void *unused)
 {
-    /* Global variable test_event_data was used to pass the expectation, so
-       test cases can't be executed at same time. */
-    g_mutex_lock(&test_event_lock);
     test_event_data = data;
 }
 
@@ -69,7 +65,6 @@  static void event_teardown(TestEventData *data,
                            const void *unused)
 {
     test_event_data = NULL;
-    g_mutex_unlock(&test_event_lock);
 }
 
 static void event_test_add(const char *testpath,