Skip to contentSkip to conversation

target/i386/kvm: use g_clear_handle_id() for GSource cleanup

PATCH In review Matthew Penney 1 participant 1 message Apr 8

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 6/8 target/i386/kvm: use g_clear_handle_id() for GSource cleanup

Replace g_source_remove() and explicit watch id check with g_clear_handle_id().

This simplifies the code and ensures consistent handling of GSource IDs, since g_clear_handle_id() checks for a non-zero ID before calling the cleanup function.

No functional change intended.

---
 target/i386/kvm/tdx-quote-generator.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
target/i386/kvm/tdx-quote-generator.c +1 -3
index dee8334b27..ab10986efa 100644
@@ -75,9 +75,7 @@ static void tdx_generate_quote_cleanup(TdxGenerateQuoteTask *task)
 {
     timer_del(&task->timer);
 
-    if (task->watch) {
-        g_source_remove(task->watch);
-    }
+    g_clear_handle_id(&task->watch, g_source_remove);
     qio_channel_close(QIO_CHANNEL(task->sioc), NULL);
     object_unref(OBJECT(task->sioc));
 
Signature · 1 line
2.53.0