Skip to contentSkip to conversation

hw/char: clear dangling GLib event source tag

PATCH Superseded Matthew Penney 3 participants 5 messages Mar 5

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/char: clear dangling GLib event source tag

Clear dangling GLib event source tag when virtio-console is unrealized. This prevents a stale tag from being used, and maintains consistency with the rest of virtio-console.

---
 hw/char/virtio-console.c | 1 +
 1 file changed, 1 insertion(+)
hw/char/virtio-console.c +1 -0
index 25db0f019b..11bf51e3ea 100644
@@ -258,6 +258,7 @@ static void virtconsole_unrealize(DeviceState *dev)
 
     if (vcon->watch) {
         g_source_remove(vcon->watch);
+        vcon->watch = 0;
     }
 }
 
Signature · 1 line
2.53.0
Reviewed-by on v1 1/1
#1 lore raw

Hi

Quoted 15 lines · Matthew Penney

Clear dangling GLib event source tag when virtio-console is unrealized. This prevents a stale tag from being used, and maintains consistency with the rest of virtio-console.

---
 hw/char/virtio-console.c | 1 +
 1 file changed, 1 insertion(+)
hw/char/virtio-console.c +0 -0
index 25db0f019b..11bf51e3ea 100644

hw/char/virtio-console.c static void virtconsole_unrealize(DeviceState *dev) · line 261

Quoted 4 lines
hw/char/virtio-console.c +1 -0
@@ -258,6 +258,7 @@ static void virtconsole_unrealize(DeviceState *dev)
 
     if (vcon->watch) {
         g_source_remove(vcon->watch);
+        vcon->watch = 0;

The glib >= 2.56 way is:
g_clear_handle_id(&vcon->watch, g_source_remove);

We could do a bulk change for the whole code base imho

anyway

Quoted 7 lines
hw/char/virtio-console.c +0 -1
     }
 }
 
--

2.53.0

#2 lore raw

Hi Marc-André,

Thanks for the swift reply!

Should I start by sending a V2 with your proposed update just for virtio-console.c, or do you prefer a larger bulk change across the codebase?

Best,
Matthew

Sent with Proton Mail secure email.

Quoted 40 lines · Marc-André Lureau

Hi

Quoted 15 lines · Matthew Penney

Clear dangling GLib event source tag when virtio-console is unrealized. This prevents a stale tag from being used, and maintains consistency with the rest of virtio-console.

---
 hw/char/virtio-console.c | 1 +
 1 file changed, 1 insertion(+)
hw/char/virtio-console.c +0 -0
index 25db0f019b..11bf51e3ea 100644

hw/char/virtio-console.c static void virtconsole_unrealize(DeviceState *dev) · line 261

Quoted 4 lines
hw/char/virtio-console.c +1 -0
@@ -258,6 +258,7 @@ static void virtconsole_unrealize(DeviceState *dev)
 
     if (vcon->watch) {
         g_source_remove(vcon->watch);
+        vcon->watch = 0;

The glib >= 2.56 way is:
g_clear_handle_id(&vcon->watch, g_source_remove);

We could do a bulk change for the whole code base imho

anyway

Quoted 7 lines
hw/char/virtio-console.c +0 -1
     }
 }
 
--

2.53.0

#3 lore raw

Hi

Quoted 6 lines · Matthew Penney

Hi Marc-André,

Thanks for the swift reply!

Should I start by sending a V2 with your proposed update just for virtio-console.c, or do you prefer a larger bulk change across the codebase?

If you can clean the codebase in one patch, hopefully this is agreeable with all the subsystem maintainers.

Though if your patch is actually a fix, it's worth it to make it a different patch.

Quoted 51 lines

Best,
Matthew

Sent with Proton Mail secure email.

Quoted 40 lines · Marc-André Lureau

Hi

Quoted 15 lines · Matthew Penney

Clear dangling GLib event source tag when virtio-console is unrealized. This prevents a stale tag from being used, and maintains consistency with the rest of virtio-console.

---
 hw/char/virtio-console.c | 1 +
 1 file changed, 1 insertion(+)
hw/char/virtio-console.c +0 -0
index 25db0f019b..11bf51e3ea 100644

hw/char/virtio-console.c static void virtconsole_unrealize(DeviceState *dev) · line 261

Quoted 4 lines
hw/char/virtio-console.c +1 -0
@@ -258,6 +258,7 @@ static void virtconsole_unrealize(DeviceState *dev)
 
     if (vcon->watch) {
         g_source_remove(vcon->watch);
+        vcon->watch = 0;

The glib >= 2.56 way is:
g_clear_handle_id(&vcon->watch, g_source_remove);

We could do a bulk change for the whole code base imho

anyway

Quoted 7 lines
hw/char/virtio-console.c +0 -1
     }
 }
 
--

2.53.0

Signature · 1 line
Marc-André Lureau
#4 lore raw

Hi Marc-André,

Thanks for the suggestion.

I will send a v2 of this patch updating it to use g_clear_handle_id(), keeping the scope limited to the virtio-console fix.

I may submit a separate patch later for a broader conversion if the maintainers are in agreement.

Best,
Matthew

Sent with Proton Mail secure email.

Quoted 72 lines · Marc-André Lureau

Hi

Quoted 6 lines · Matthew Penney

Hi Marc-André,

Thanks for the swift reply!

Should I start by sending a V2 with your proposed update just for virtio-console.c, or do you prefer a larger bulk change across the codebase?

If you can clean the codebase in one patch, hopefully this is agreeable with all the subsystem maintainers.

Though if your patch is actually a fix, it's worth it to make it a different patch.

Quoted 51 lines

Best,
Matthew

Sent with Proton Mail secure email.

Quoted 40 lines · Marc-André Lureau

Hi

Quoted 15 lines · Matthew Penney

Clear dangling GLib event source tag when virtio-console is unrealized. This prevents a stale tag from being used, and maintains consistency with the rest of virtio-console.

---
 hw/char/virtio-console.c | 1 +
 1 file changed, 1 insertion(+)
hw/char/virtio-console.c +0 -0
index 25db0f019b..11bf51e3ea 100644

hw/char/virtio-console.c static void virtconsole_unrealize(DeviceState *dev) · line 261

Quoted 4 lines
hw/char/virtio-console.c +1 -0
@@ -258,6 +258,7 @@ static void virtconsole_unrealize(DeviceState *dev)
 
     if (vcon->watch) {
         g_source_remove(vcon->watch);
+        vcon->watch = 0;

The glib >= 2.56 way is:
g_clear_handle_id(&vcon->watch, g_source_remove);

We could do a bulk change for the whole code base imho

anyway

Quoted 7 lines
hw/char/virtio-console.c +0 -1
     }
 }
 
--

2.53.0

--
Marc-André Lureau