get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/1.0/patches/2221168/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2221168,
    "url": "http://patchwork.ozlabs.org/api/1.0/patches/2221168/?format=api",
    "project": {
        "id": 14,
        "url": "http://patchwork.ozlabs.org/api/1.0/projects/14/?format=api",
        "name": "QEMU Development",
        "link_name": "qemu-devel",
        "list_id": "qemu-devel.nongnu.org",
        "list_email": "qemu-devel@nongnu.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20260408100605.66795-3-philmd@linaro.org>",
    "date": "2026-04-08T10:06:05",
    "name": "[2/2] io: use g_clear_handle_id() for GSource cleanup",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "fa809a882b92be7278680c8244be5584e1371694",
    "submitter": {
        "id": 85046,
        "url": "http://patchwork.ozlabs.org/api/1.0/people/85046/?format=api",
        "name": "Philippe Mathieu-Daudé",
        "email": "philmd@linaro.org"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260408100605.66795-3-philmd@linaro.org/mbox/",
    "series": [
        {
            "id": 499196,
            "url": "http://patchwork.ozlabs.org/api/1.0/series/499196/?format=api",
            "date": "2026-04-08T10:06:04",
            "name": "io: use g_clear_handle_id() for GSource cleanup",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/499196/mbox/"
        }
    ],
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2221168/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>",
        "X-Original-To": "incoming@patchwork.ozlabs.org",
        "Delivered-To": "patchwork-incoming@legolas.ozlabs.org",
        "Authentication-Results": [
            "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256\n header.s=google header.b=L6ScIUjx;\n\tdkim-atps=neutral",
            "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)"
        ],
        "Received": [
            "from lists.gnu.org (lists1p.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4frYCB0QnTz1yD6\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 09 Apr 2026 05:33:42 +1000 (AEST)",
            "from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1wAYYQ-0003OI-Eu; Wed, 08 Apr 2026 15:27:12 -0400",
            "from eggs.gnu.org ([2001:470:142:3::10])\n by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <philmd@linaro.org>) id 1wAY7i-0007r2-Ow\n for qemu-devel@nongnu.org; Wed, 08 Apr 2026 14:59:35 -0400",
            "from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)\n (Exim 4.90_1) (envelope-from <philmd@linaro.org>) id 1wAPni-0005kx-M0\n for qemu-devel@nongnu.org; Wed, 08 Apr 2026 06:06:24 -0400",
            "by mail-wm1-x32a.google.com with SMTP id\n 5b1f17b1804b1-488a4bc360bso22202835e9.0\n for <qemu-devel@nongnu.org>; Wed, 08 Apr 2026 03:06:22 -0700 (PDT)",
            "from localhost.localdomain (88-187-86-199.subs.proxad.net.\n [88.187.86.199]) by smtp.gmail.com with ESMTPSA id\n 5b1f17b1804b1-488c1c5291esm160617735e9.15.2026.04.08.03.06.19\n (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);\n Wed, 08 Apr 2026 03:06:20 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=linaro.org; s=google; t=1775642781; x=1776247581; darn=nongnu.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=X3IC7giLeG32iqm8vM+G34aT4OP2axUXXvrwECNgWU0=;\n b=L6ScIUjxaucvUTn0YZcEKIT9qKxbGOyIwjTgDNrqMAByw76fvyPci8dCaTUVu19FDB\n 8hQFLqOKU64bUZfYZM3okUcGQ7VFIaZMKckIun3yAJDX6rSUlG3UT7PdPysIXrQau1qp\n Ic7rzfz5tIl/NDzi/hKHW5cnQSNKqoyJDASMoLG2vl4K5SBx/lIwgWBpCBUzaV8/hAI3\n i7IbjYFItLsOpB3/eHpfXrNOFGi2BdrFuzIYp55IRvv4IgkZCWv0ZNLv8Sky7QgstIjQ\n kZ774SmxoVQPS0VmSfDUYBLRHyg/t/+RGdiq8YVPSfLkq7kfNVe+A+lfYyAwDbctmfgE\n AcrA==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1775642781; x=1776247581;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n :to:cc:subject:date:message-id:reply-to;\n bh=X3IC7giLeG32iqm8vM+G34aT4OP2axUXXvrwECNgWU0=;\n b=a5vURJcZOY9ik3Jv+Ju9emu60I87DY7SIp9veMGdQP4pZOsCvpYGNbYuRm1r8j+Kvg\n rGu9ovZw/LhjRA57BOGHCrYjSDUXefDEyxm/gEsg7vFUOWi/QD5+6KNzhdtT4VNn54ei\n MxrySKo/g90vVJ1OQa4V7kGbLnLZ1nU5jJwIxYqcCrn4ImHZaOV5LkM3EKgpt4f1MECi\n mXYve5+spFnG4vcaXo+jXDigXe8KGbweJln4oiwc8+NfG2g4AgbOS4oHgIsFEiXiqi8n\n NO7u2hR2Pd0TQlaWApv8BcX1c2TcOt6/CWfWUOyH/f67+iFArF6TjsH2H0LeoegMaBD3\n RK0w==",
        "X-Gm-Message-State": "AOJu0YwoZkOtfJQLSFcpahZQ6fegUDFzxNB9+duZ/4xUvZBZigSraQpr\n Su5cgV9INQ8CfvP1DVnghy27cxNgrFFEJ8xXDCdhDf/w1E2TgBUsXckUUzS9ia2as7jvLtgNRg/\n HLGOAnwg=",
        "X-Gm-Gg": "AeBDiesYEApk9uld8FcVv+wdHMy/8m5COj/BzES9iwUOfMhWS8Eos7xuZozuhF6/giC\n LmFABk1ix7/IlxEsmFCWQSeln8HYjLab+B0GPDMSKDoXdrmX/symon9zQ72c0S5UtSDKnlXre50\n nOsHffQyk3LizlU3RMD8MmcoAOAskt4IU7Tr9ofQP+89PQ0gOGjn+QvnScbtE6zqCuAay7gQNjI\n HWsRj2JJZJ3P2H+VzFfNnidOCyL5mXqr9p5wyP+VPlQyEw4tV7cEy4UWELgoQW5ta6JpPTSxRT5\n ZsZAqtRbUH40wRIVkzR3BY2qdk7Peh/1op3UWalfkc03F7dGEJAdGKYvRNUqCjlA5KqFS46gX7r\n 62Kt1DhDKBDzbquUKAtwUlgstkgTsaUO7a0CiEti15068jyofwAWLIMB44XsaMqF8oqNJ9LACLc\n 6RVElOSfQizEU+VASsH0g9h6fXcKqul80L+q40aQe2uQSG6BpIX2cA0osv2E/9AiloGlcbuJ86",
        "X-Received": "by 2002:a05:600c:3546:b0:485:2f4a:6ae6 with SMTP id\n 5b1f17b1804b1-488996da165mr289588235e9.6.1775642780752;\n Wed, 08 Apr 2026 03:06:20 -0700 (PDT)",
        "From": "=?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= <philmd@linaro.org>",
        "To": "qemu-devel@nongnu.org",
        "Cc": "=?utf-8?q?Marc-Andr=C3=A9_Lureau?= <marcandre.lureau@redhat.com>,\n\t=?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= <berrange@redhat.com>,\n Matthew Penney <matt@matthewpenney.net>",
        "Subject": "[PATCH 2/2] io: use g_clear_handle_id() for GSource cleanup",
        "Date": "Wed,  8 Apr 2026 12:06:05 +0200",
        "Message-ID": "<20260408100605.66795-3-philmd@linaro.org>",
        "X-Mailer": "git-send-email 2.53.0",
        "In-Reply-To": "<20260408100605.66795-1-philmd@linaro.org>",
        "References": "<20260408100605.66795-1-philmd@linaro.org>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "Received-SPF": "pass client-ip=2a00:1450:4864:20::32a;\n envelope-from=philmd@linaro.org; helo=mail-wm1-x32a.google.com",
        "X-Spam_score_int": "-20",
        "X-Spam_score": "-2.1",
        "X-Spam_bar": "--",
        "X-Spam_report": "(-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,\n DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,\n SPF_PASS=-0.001 autolearn=ham autolearn_force=no",
        "X-Spam_action": "no action",
        "X-BeenThere": "qemu-devel@nongnu.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "qemu development <qemu-devel.nongnu.org>",
        "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>",
        "List-Archive": "<https://lists.nongnu.org/archive/html/qemu-devel>",
        "List-Post": "<mailto:qemu-devel@nongnu.org>",
        "List-Help": "<mailto:qemu-devel-request@nongnu.org?subject=help>",
        "List-Subscribe": "<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>",
        "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org",
        "Sender": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org"
    },
    "content": "Use g_clear_handle_id() instead of g_source_remove() with\nmanual ID checking and zeroing.\n\nThis simplifies the code and ensures consistent handling of\nGSource IDs, since g_clear_handle_id() checks for a non-zero\nID before calling the cleanup function and zeros it afterwards.\n\nNo functional change intended.\n\nMechanical change using the following Coccinelle spatch script:\n\n  @@\n  expression TAG;\n  @@\n  -    if (TAG > 0) {\n  +    if (TAG) {\n           g_source_remove(TAG);\n           <... when != TAG\n           TAG = 0;\n           ...>\n       }\n\n  @@\n  expression TAG;\n  @@\n  -    g_source_remove(TAG);\n  -    TAG = 0;\n  +    g_clear_handle_id(&TAG, g_source_remove);\n\n  @@\n  expression TAG;\n  @@\n  -    if (TAG) {\n           g_clear_handle_id(&TAG, g_source_remove);\n  -    }\n\nInspired-by: Matthew Penney <matt@matthewpenney.net>\nSigned-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>\n---\n hw/char/cmsdk-apb-uart.c  |  5 +----\n hw/char/nrf51_uart.c      |  5 +----\n hw/char/serial.c          |  6 +-----\n hw/char/stm32l4x5_usart.c |  5 +----\n hw/char/terminal3270.c    |  5 +----\n hw/char/virtio-console.c  | 10 ++--------\n hw/usb/redirect.c         |  5 +----\n io/channel-websock.c      | 13 +++----------\n net/passt.c               |  8 ++------\n net/stream.c              | 15 +++------------\n net/stream_data.c         |  5 +----\n net/vhost-user.c          |  8 ++------\n ui/dbus-clipboard.c       |  6 ++----\n ui/input-barrier.c        |  6 +-----\n ui/vnc-auth-vencrypt.c    |  6 +-----\n ui/vnc-ws.c               | 12 ++----------\n 16 files changed, 25 insertions(+), 95 deletions(-)",
    "diff": "diff --git a/hw/char/cmsdk-apb-uart.c b/hw/char/cmsdk-apb-uart.c\nindex edb80f61819..0631821a571 100644\n--- a/hw/char/cmsdk-apb-uart.c\n+++ b/hw/char/cmsdk-apb-uart.c\n@@ -236,10 +236,7 @@ buffer_drained:\n \n static void uart_cancel_transmit(CMSDKAPBUART *s)\n {\n-    if (s->watch_tag) {\n-        g_source_remove(s->watch_tag);\n-        s->watch_tag = 0;\n-    }\n+    g_clear_handle_id(&s->watch_tag, g_source_remove);\n }\n \n static void uart_write(void *opaque, hwaddr offset, uint64_t value,\ndiff --git a/hw/char/nrf51_uart.c b/hw/char/nrf51_uart.c\nindex 73069232441..96f0d085fdd 100644\n--- a/hw/char/nrf51_uart.c\n+++ b/hw/char/nrf51_uart.c\n@@ -104,10 +104,7 @@ buffer_drained:\n \n static void uart_cancel_transmit(NRF51UARTState *s)\n {\n-    if (s->watch_tag) {\n-        g_source_remove(s->watch_tag);\n-        s->watch_tag = 0;\n-    }\n+    g_clear_handle_id(&s->watch_tag, g_source_remove);\n }\n \n static void uart_write(void *opaque, hwaddr addr,\ndiff --git a/hw/char/serial.c b/hw/char/serial.c\nindex 0f3469a1e8f..0729cd2ce9d 100644\n--- a/hw/char/serial.c\n+++ b/hw/char/serial.c\n@@ -856,11 +856,7 @@ const VMStateDescription vmstate_serial = {\n static void serial_reset(void *opaque)\n {\n     SerialState *s = opaque;\n-\n-    if (s->watch_tag > 0) {\n-        g_source_remove(s->watch_tag);\n-        s->watch_tag = 0;\n-    }\n+    g_clear_handle_id(&s->watch_tag, g_source_remove);\n \n     s->rbr = 0;\n     s->ier = 0;\ndiff --git a/hw/char/stm32l4x5_usart.c b/hw/char/stm32l4x5_usart.c\nindex 736f1e764e6..dd1b0991956 100644\n--- a/hw/char/stm32l4x5_usart.c\n+++ b/hw/char/stm32l4x5_usart.c\n@@ -280,10 +280,7 @@ buffer_drained:\n \n static void usart_cancel_transmit(Stm32l4x5UsartBaseState *s)\n {\n-    if (s->watch_tag) {\n-        g_source_remove(s->watch_tag);\n-        s->watch_tag = 0;\n-    }\n+    g_clear_handle_id(&s->watch_tag, g_source_remove);\n }\n \n static void stm32l4x5_update_params(Stm32l4x5UsartBaseState *s)\ndiff --git a/hw/char/terminal3270.c b/hw/char/terminal3270.c\nindex 1d857bad9bc..989b6f6ee1e 100644\n--- a/hw/char/terminal3270.c\n+++ b/hw/char/terminal3270.c\n@@ -52,10 +52,7 @@ static int terminal_can_read(void *opaque)\n \n static void terminal_timer_cancel(Terminal3270 *t)\n {\n-    if (t->timer_tag) {\n-        g_source_remove(t->timer_tag);\n-        t->timer_tag = 0;\n-    }\n+    g_clear_handle_id(&t->timer_tag, g_source_remove);\n }\n \n /*\ndiff --git a/hw/char/virtio-console.c b/hw/char/virtio-console.c\nindex efe7cd6772e..4737b9a56eb 100644\n--- a/hw/char/virtio-console.c\n+++ b/hw/char/virtio-console.c\n@@ -159,10 +159,7 @@ static void chr_event(void *opaque, QEMUChrEvent event)\n         virtio_serial_open(port);\n         break;\n     case CHR_EVENT_CLOSED:\n-        if (vcon->watch) {\n-            g_source_remove(vcon->watch);\n-            vcon->watch = 0;\n-        }\n+        g_clear_handle_id(&vcon->watch, g_source_remove);\n         virtio_serial_close(port);\n         break;\n     case CHR_EVENT_BREAK:\n@@ -255,10 +252,7 @@ static void virtconsole_realize(DeviceState *dev, Error **errp)\n static void virtconsole_unrealize(DeviceState *dev)\n {\n     VirtConsole *vcon = VIRTIO_CONSOLE(dev);\n-\n-    if (vcon->watch) {\n-        g_clear_handle_id(&vcon->watch, g_source_remove);\n-    }\n+    g_clear_handle_id(&vcon->watch, g_source_remove);\n }\n \n static void virtconsole_class_init(ObjectClass *klass, const void *data)\ndiff --git a/hw/usb/redirect.c b/hw/usb/redirect.c\nindex 100afbdb06a..bde821e214b 100644\n--- a/hw/usb/redirect.c\n+++ b/hw/usb/redirect.c\n@@ -1226,10 +1226,7 @@ static void usbredir_chardev_close_bh(void *opaque)\n         usbredirparser_destroy(dev->parser);\n         dev->parser = NULL;\n     }\n-    if (dev->watch) {\n-        g_source_remove(dev->watch);\n-        dev->watch = 0;\n-    }\n+    g_clear_handle_id(&dev->watch, g_source_remove);\n }\n \n static void usbredir_create_parser(USBRedirDevice *dev)\ndiff --git a/io/channel-websock.c b/io/channel-websock.c\nindex da7e7c9e345..3479a5c32d2 100644\n--- a/io/channel-websock.c\n+++ b/io/channel-websock.c\n@@ -1066,10 +1066,7 @@ static gboolean qio_channel_websock_flush(QIOChannel *ioc,\n \n static void qio_channel_websock_unset_watch(QIOChannelWebsock *ioc)\n {\n-    if (ioc->io_tag) {\n-        g_source_remove(ioc->io_tag);\n-        ioc->io_tag = 0;\n-    }\n+    g_clear_handle_id(&ioc->io_tag, g_source_remove);\n }\n \n static void qio_channel_websock_set_watch(QIOChannelWebsock *ioc)\n@@ -1246,12 +1243,8 @@ static int qio_channel_websock_close(QIOChannel *ioc,\n     buffer_free(&wioc->encinput);\n     buffer_free(&wioc->encoutput);\n     buffer_free(&wioc->rawinput);\n-    if (wioc->hs_io_tag) {\n-        g_clear_handle_id(&wioc->hs_io_tag, g_source_remove);\n-    }\n-    if (wioc->io_tag) {\n-        g_clear_handle_id(&wioc->io_tag, g_source_remove);\n-    }\n+    g_clear_handle_id(&wioc->hs_io_tag, g_source_remove);\n+    g_clear_handle_id(&wioc->io_tag, g_source_remove);\n     if (wioc->io_err) {\n         g_clear_pointer(&wioc->io_err, error_free);\n     }\ndiff --git a/net/passt.c b/net/passt.c\nindex 4ff94ee509d..d3b5ab426c9 100644\n--- a/net/passt.c\n+++ b/net/passt.c\n@@ -90,10 +90,7 @@ static void net_passt_cleanup(NetClientState *nc)\n         g_free(s->vhost_net);\n         s->vhost_net = NULL;\n     }\n-    if (s->vhost_watch) {\n-        g_source_remove(s->vhost_watch);\n-        s->vhost_watch = 0;\n-    }\n+    g_clear_handle_id(&s->vhost_watch, g_source_remove);\n     qemu_chr_fe_deinit(&s->vhost_chr, true);\n     if (s->vhost_user) {\n         vhost_user_cleanup(s->vhost_user);\n@@ -421,8 +418,7 @@ static void passt_vhost_user_event(void *opaque, QEMUChrEvent event)\n         if (s->vhost_watch) {\n             AioContext *ctx = qemu_get_current_aio_context();\n \n-            g_source_remove(s->vhost_watch);\n-            s->vhost_watch = 0;\n+            g_clear_handle_id(&s->vhost_watch, g_source_remove);\n             qemu_chr_fe_set_handlers(&s->vhost_chr, NULL, NULL,  NULL, NULL,\n                                      NULL, NULL, false);\n \ndiff --git a/net/stream.c b/net/stream.c\nindex ea83f4a763a..6df4e251feb 100644\n--- a/net/stream.c\n+++ b/net/stream.c\n@@ -71,24 +71,15 @@ static gboolean net_stream_send(QIOChannel *ioc,\n static void net_stream_cleanup(NetClientState *nc)\n {\n     NetStreamState *s = DO_UPCAST(NetStreamState, data.nc, nc);\n-    if (s->timer_tag) {\n-        g_source_remove(s->timer_tag);\n-        s->timer_tag = 0;\n-    }\n+    g_clear_handle_id(&s->timer_tag, g_source_remove);\n     if (s->addr) {\n         qapi_free_SocketAddress(s->addr);\n         s->addr = NULL;\n     }\n     if (s->data.ioc) {\n         if (QIO_CHANNEL_SOCKET(s->data.ioc)->fd != -1) {\n-            if (s->data.ioc_read_tag) {\n-                g_source_remove(s->data.ioc_read_tag);\n-                s->data.ioc_read_tag = 0;\n-            }\n-            if (s->data.ioc_write_tag) {\n-                g_source_remove(s->data.ioc_write_tag);\n-                s->data.ioc_write_tag = 0;\n-            }\n+            g_clear_handle_id(&s->data.ioc_read_tag, g_source_remove);\n+            g_clear_handle_id(&s->data.ioc_write_tag, g_source_remove);\n         }\n         object_unref(OBJECT(s->data.ioc));\n         s->data.ioc = NULL;\ndiff --git a/net/stream_data.c b/net/stream_data.c\nindex 03740e9f73e..73b45da9fe3 100644\n--- a/net/stream_data.c\n+++ b/net/stream_data.c\n@@ -84,10 +84,7 @@ void net_stream_data_rs_finalize(SocketReadState *rs)\n     if (qemu_send_packet_async(&d->nc, rs->buf,\n                                rs->packet_len,\n                                net_stream_data_send_completed) == 0) {\n-        if (d->ioc_read_tag) {\n-            g_source_remove(d->ioc_read_tag);\n-            d->ioc_read_tag = 0;\n-        }\n+        g_clear_handle_id(&d->ioc_read_tag, g_source_remove);\n     }\n }\n \ndiff --git a/net/vhost-user.c b/net/vhost-user.c\nindex a4bb49bbcff..2d0fc49b4d8 100644\n--- a/net/vhost-user.c\n+++ b/net/vhost-user.c\n@@ -215,10 +215,7 @@ static void net_vhost_user_cleanup(NetClientState *nc)\n         s->vhost_net = NULL;\n     }\n     if (nc->queue_index == 0) {\n-        if (s->watch) {\n-            g_source_remove(s->watch);\n-            s->watch = 0;\n-        }\n+        g_clear_handle_id(&s->watch, g_source_remove);\n         qemu_chr_fe_deinit(&s->chr, true);\n         if (s->vhost_user) {\n             vhost_user_cleanup(s->vhost_user);\n@@ -356,8 +353,7 @@ static void net_vhost_user_event(void *opaque, QEMUChrEvent event)\n         if (s->watch) {\n             AioContext *ctx = qemu_get_current_aio_context();\n \n-            g_source_remove(s->watch);\n-            s->watch = 0;\n+            g_clear_handle_id(&s->watch, g_source_remove);\n             qemu_chr_fe_set_handlers(&s->chr, NULL, NULL, NULL, NULL,\n                                      NULL, NULL, false);\n \ndiff --git a/ui/dbus-clipboard.c b/ui/dbus-clipboard.c\nindex 935b6b1a2ac..90318384ee4 100644\n--- a/ui/dbus-clipboard.c\n+++ b/ui/dbus-clipboard.c\n@@ -80,8 +80,7 @@ dbus_clipboard_update_info(DBusDisplay *dpy, QemuClipboardInfo *info)\n     if (req->invocation && info->types[req->type].data) {\n         dbus_clipboard_complete_request(dpy, req->invocation, info, req->type);\n         g_clear_object(&req->invocation);\n-        g_source_remove(req->timeout_id);\n-        req->timeout_id = 0;\n+        g_clear_handle_id(&req->timeout_id, g_source_remove);\n         return;\n     }\n \n@@ -183,8 +182,7 @@ dbus_clipboard_request_cancelled(DBusClipboardRequest *req)\n         \"Cancelled clipboard request\");\n \n     g_clear_object(&req->invocation);\n-    g_source_remove(req->timeout_id);\n-    req->timeout_id = 0;\n+    g_clear_handle_id(&req->timeout_id, g_source_remove);\n }\n \n static void\ndiff --git a/ui/input-barrier.c b/ui/input-barrier.c\nindex 0a2198ca500..84212c50442 100644\n--- a/ui/input-barrier.c\n+++ b/ui/input-barrier.c\n@@ -518,11 +518,7 @@ static void input_barrier_complete(UserCreatable *uc, Error **errp)\n static void input_barrier_instance_finalize(Object *obj)\n {\n     InputBarrier *ib = INPUT_BARRIER(obj);\n-\n-    if (ib->ioc_tag) {\n-        g_source_remove(ib->ioc_tag);\n-        ib->ioc_tag = 0;\n-    }\n+    g_clear_handle_id(&ib->ioc_tag, g_source_remove);\n \n     if (ib->sioc) {\n         qio_channel_close(QIO_CHANNEL(ib->sioc), NULL);\ndiff --git a/ui/vnc-auth-vencrypt.c b/ui/vnc-auth-vencrypt.c\nindex d9c212ff328..a1b8cde2292 100644\n--- a/ui/vnc-auth-vencrypt.c\n+++ b/ui/vnc-auth-vencrypt.c\n@@ -101,11 +101,7 @@ static int protocol_client_vencrypt_auth(VncState *vs, uint8_t *data, size_t len\n         QIOChannelTLS *tls;\n         vnc_write_u8(vs, 1); /* Accept auth */\n         vnc_flush(vs);\n-\n-        if (vs->ioc_tag) {\n-            g_source_remove(vs->ioc_tag);\n-            vs->ioc_tag = 0;\n-        }\n+        g_clear_handle_id(&vs->ioc_tag, g_source_remove);\n \n         tls = qio_channel_tls_new_server(\n             vs->ioc,\ndiff --git a/ui/vnc-ws.c b/ui/vnc-ws.c\nindex 9e3503d93d8..65e8b344b65 100644\n--- a/ui/vnc-ws.c\n+++ b/ui/vnc-ws.c\n@@ -54,11 +54,7 @@ gboolean vncws_tls_handshake_io(QIOChannel *ioc G_GNUC_UNUSED,\n     VncState *vs = opaque;\n     QIOChannelTLS *tls;\n     Error *err = NULL;\n-\n-    if (vs->ioc_tag) {\n-        g_source_remove(vs->ioc_tag);\n-        vs->ioc_tag = 0;\n-    }\n+    g_clear_handle_id(&vs->ioc_tag, g_source_remove);\n \n     if (condition & (G_IO_HUP | G_IO_ERR)) {\n         vnc_client_error(vs);\n@@ -123,11 +119,7 @@ gboolean vncws_handshake_io(QIOChannel *ioc G_GNUC_UNUSED,\n {\n     VncState *vs = opaque;\n     QIOChannelWebsock *wioc;\n-\n-    if (vs->ioc_tag) {\n-        g_source_remove(vs->ioc_tag);\n-        vs->ioc_tag = 0;\n-    }\n+    g_clear_handle_id(&vs->ioc_tag, g_source_remove);\n \n     if (condition & (G_IO_HUP | G_IO_ERR)) {\n         vnc_client_error(vs);\n",
    "prefixes": [
        "2/2"
    ]
}