{"id":2221091,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2221091/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260408010026.4611-3-matt@matthewpenney.net/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/1.1/projects/14/?format=json","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":"<20260408010026.4611-3-matt@matthewpenney.net>","date":"2026-04-08T01:02:13","name":"[2/8] hw/usb: use g_clear_handle_id() for GSource cleanup","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"12aa5a6ec274d573a79fd86d74f5337833753c56","submitter":{"id":92789,"url":"http://patchwork.ozlabs.org/api/1.1/people/92789/?format=json","name":"Matthew Penney","email":"matt@matthewpenney.net"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260408010026.4611-3-matt@matthewpenney.net/mbox/","series":[{"id":499175,"url":"http://patchwork.ozlabs.org/api/1.1/series/499175/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=499175","date":"2026-04-08T01:02:28","name":"[1/8] hw/char: use g_clear_handle_id() for GSource cleanup","version":1,"mbox":"http://patchwork.ozlabs.org/series/499175/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2221091/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2221091/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=matthewpenney.net header.i=@matthewpenney.net\n header.a=rsa-sha256 header.s=protonmail header.b=iMhKBiNu;\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 (unknown [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 4frXD86SScz1yD6\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 09 Apr 2026 04:49:28 +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 1wAXxM-0006dz-U5; Wed, 08 Apr 2026 14:48:52 -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 <matt@matthewpenney.net>)\n id 1wAXx2-0003kp-KA\n for qemu-devel@nongnu.org; Wed, 08 Apr 2026 14:48:33 -0400","from mail-4323.protonmail.ch ([185.70.43.23])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <matt@matthewpenney.net>)\n id 1wAHJC-0001Lr-Ua\n for qemu-devel@nongnu.org; Tue, 07 Apr 2026 21:02:21 -0400"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=matthewpenney.net;\n s=protonmail; t=1775610136; x=1775869336;\n bh=bzcWTfebsBxOlL1d+WlHaxDFxLorzIaQvjRqCYonbc4=;\n h=Date:To:From:Cc:Subject:Message-ID:Feedback-ID:From:To:Cc:Date:\n Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector;\n b=iMhKBiNuSo0R8sEye39B6f0n8U1qZ6N0mWExcS9Np/wgQGJU/1jbO+/OnriDyoQuv\n 2tWdM9EXBuoKzKpWoOSL9We3a4+PJVH+MMzfaRVFqdItQhUl6Q+v3dM3t/Cc4caPg9\n 99f7GfvUPqE7w7cINreXMChNC43C9YRAH2FRCHnS0c88y1HN6P11bSf4cxrpejl+k4\n NtrIztgVHxJqXpCphAtR5ONsyS4lSg2zgCMkgCNPUKhraRTBFyoewHl5OhQiQ//Pqx\n icr2cw7U3gZAMb9Ww4ZvRiMvLyUpYEql43nXKdLyEbiNbUActo8PlAsa8Cc1mt8TVG\n A48yncZXqI1rg==","Date":"Wed, 08 Apr 2026 01:02:13 +0000","To":"qemu-devel@nongnu.org","From":"Matthew Penney <matt@matthewpenney.net>","Cc":"Matthew Penney <matt@matthewpenney.net>, pbonzini@redhat.com,\n marcandre.lureau@redhat.com, philmd@linaro.org, richard.henderson@linaro.org","Subject":"[PATCH 2/8] hw/usb: use g_clear_handle_id() for GSource cleanup","Message-ID":"<20260408010026.4611-3-matt@matthewpenney.net>","Feedback-ID":"185185778:user:proton","X-Pm-Message-ID":"b87fa7b8eaed33bfdd489f4525506883408af91c","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Transfer-Encoding":"quoted-printable","Received-SPF":"pass client-ip=185.70.43.23;\n envelope-from=matt@matthewpenney.net;\n helo=mail-4323.protonmail.ch","X-Spam_score_int":"-27","X-Spam_score":"-2.8","X-Spam_bar":"--","X-Spam_report":"(-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001,\n RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001,\n SPF_HELO_PASS=-0.001, 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 manual ID\nchecking and zeroing.\n\nThis simplifies the code and ensures consistent handling of GSource IDs,\nsince g_clear_handle_id() checks for a non-zero ID before calling the\ncleanup function and zeros it afterwards.\n\nNo functional change intended.\n\nSigned-off-by: Matthew Penney <matt@matthewpenney.net>\n---\n hw/usb/redirect.c | 9 ++-------\n 1 file changed, 2 insertions(+), 7 deletions(-)","diff":"diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c\nindex fda5bbca67..bde821e214 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)\n@@ -1494,9 +1491,7 @@ static void usbredir_unrealize(USBDevice *udev)\n     if (dev->parser) {\n         usbredirparser_destroy(dev->parser);\n     }\n-    if (dev->watch) {\n-        g_source_remove(dev->watch);\n-    }\n+    g_clear_handle_id(&dev->watch, g_source_remove);\n \n     free(dev->filter_rules);\n     qemu_del_vm_change_state_handler(dev->vmstate);\n","prefixes":["2/8"]}