{"id":2223645,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2223645/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260415215539.92629-2-philmd@linaro.org/","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":"<20260415215539.92629-2-philmd@linaro.org>","date":"2026-04-15T21:55:32","name":"[1/8] cocci: Do not initialize variable used by QLIST_FOREACH macro","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"8fbe05a8e8a417f44a399e555157e5f80da5c9d7","submitter":{"id":85046,"url":"http://patchwork.ozlabs.org/api/1.1/people/85046/?format=json","name":"Philippe Mathieu-Daudé","email":"philmd@linaro.org"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260415215539.92629-2-philmd@linaro.org/mbox/","series":[{"id":500043,"url":"http://patchwork.ozlabs.org/api/1.1/series/500043/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=500043","date":"2026-04-15T21:55:33","name":"cocci: Do not initialize variable used by *FOREACH*() macro","version":1,"mbox":"http://patchwork.ozlabs.org/series/500043/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2223645/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2223645/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=pD98zgRo;\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=lists1p.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)"],"Received":["from lists1p.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 4fww3G0lrRz1yHV\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 16 Apr 2026 07:56:56 +1000 (AEST)","from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists1p.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1wD8DE-0002DY-Qh; Wed, 15 Apr 2026 17:55:56 -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 1wD8DB-0002BI-8g\n for qemu-devel@nongnu.org; Wed, 15 Apr 2026 17:55:53 -0400","from mail-wm1-x335.google.com ([2a00:1450:4864:20::335])\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 1wD8D9-0002cy-16\n for qemu-devel@nongnu.org; Wed, 15 Apr 2026 17:55:52 -0400","by mail-wm1-x335.google.com with SMTP id\n 5b1f17b1804b1-4852b81c73aso68085395e9.3\n for <qemu-devel@nongnu.org>; Wed, 15 Apr 2026 14:55:49 -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-488f5813954sm651235e9.3.2026.04.15.14.55.47\n (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);\n Wed, 15 Apr 2026 14:55:47 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=linaro.org; s=google; t=1776290148; x=1776894948; 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=VuzviMl1wmLNCePSminxPRECrcBokMjkzSTP18yd1OY=;\n b=pD98zgRopECYuPYK/ack7Mbgy/S61amnk5yVpz9Z9Ic93O9pJV+Sma9oMs/Cucy9Hz\n vU4EwX+eUQP+bHzsgGnNqI7xorveQAZjJYFwsX1op2eeG7s2ktSjLpBmYfHSnUU36fDp\n s9cUjhIpMBm5ElGKZX7qw1bRLbOU4MIhTZckdZ6Xvu9RkNNYMYhGTVUIMRPAY85vacoG\n DTmYDGjXKhB0yFNm3RhgnfJDe/l0Qrikmat0nW0ftdb/U8n7qYcEnbihlJQm+j9jH/+h\n DaEqnxxvTy5bz2RxnLZwcMp4IyzlWjRegngTZBi/XTdk32SsOG65nXXqcCB9utwKxwW1\n LVnQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1776290148; x=1776894948;\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=VuzviMl1wmLNCePSminxPRECrcBokMjkzSTP18yd1OY=;\n b=NGV8zlX7DIi8C3iWp+MXwpg6UHHmECSlKqj6csd4IjMPKheJV9Rm0udA41jqdYpg6Z\n oV9zoCxcH6dKBHIRnQ6OHz3ac65ElEP/RgaOaCp1FO817Ujt9gD7Af/IoABC55A3+GU2\n jlgYgDghsUypO1+QhD5xc6pV88IAL+NHGJ4o4WS/dGKMIWc5AqQ3aRB2rWJhiHp9JoPD\n AwUBQZuniUFZDOzwZm947/Ic/81wtIyZcZIJfzu1o4ocFGPz6pZUD4LpjZWOc4VvXizW\n qk2JjaXoqKKL0+EPhjM9hZPPpwE9/ZaekjerCD9vKs12lOmpRWOJCH9Jg/z1yQbuaO+O\n wcWQ==","X-Gm-Message-State":"AOJu0YxTyOpALu9INZxszORw11NHCxdsOhn2iDZXc3sqZFxAvXW2LorO\n HoyS0ZJHpe/K8jO0IJtJbY+ZZBbxXzr/AxYeGLCICZRhewCEeo4JfFO9ZYk6jr/9zRhV4XjA7jI\n AMl6Eyag=","X-Gm-Gg":"AeBDiet+ub2UF6Q11riSEZ9Y/9+e85V0V7u+brXAsDmnqcACIY4q+4ki6MG2Euq3+MI\n CPyQaFXA7ksA42xXXmc5PAzY/jwIZqpRbBCd0bNr2Mbdxh83reZgAuXq5MfOpCXqtRTtrPLjGCn\n jeBLlqMfXU2dQsNFBoylGsdm3WFqT2uSMgwBQsCFJ2jcmi181+sSwd2vzjKV7QzjEsSA/aLIHfI\n e2yHSUAwWZZZTPrguEwgycGhyVFs0OOzY24Jq14SDzHmdepQV/uVkhAhc1LIIrEYP/bo9Xp2gko\n P/GD4LcJSJsVRwRJgneWlmzPMqLiD95t0m9I/ty/6jxMElVv8xcyCLmYkVujJKH+z6eOeoilRIM\n H5WwKCsx/B1VMgnvfh4r84SOR1BLCTsxG1WKyeuggOdZXqP+h84+HYXTfGMV/N5fVPex4KzrSVe\n uTzCbLtHCykqc4ftpn1xe28tJDRy4Vlczy8RdQUw1pTVeq+HwxFa220oaCmKyHMmArBdWJw+38","X-Received":"by 2002:a05:600c:34cc:b0:485:557d:9fe with SMTP id\n 5b1f17b1804b1-488d67e65e7mr307710595e9.12.1776290148183;\n Wed, 15 Apr 2026 14:55:48 -0700 (PDT)","From":"=?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= <philmd@linaro.org>","To":"qemu-devel@nongnu.org","Cc":"qemu-arm@nongnu.org, qemu-s390x@nongnu.org, qemu-riscv@nongnu.org,\n qemu-block@nongnu.org","Subject":"[PATCH 1/8] cocci: Do not initialize variable used by QLIST_FOREACH\n macro","Date":"Wed, 15 Apr 2026 23:55:32 +0200","Message-ID":"<20260415215539.92629-2-philmd@linaro.org>","X-Mailer":"git-send-email 2.53.0","In-Reply-To":"<20260415215539.92629-1-philmd@linaro.org>","References":"<20260415215539.92629-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::335;\n envelope-from=philmd@linaro.org; helo=mail-wm1-x335.google.com","X-Spam_score_int":"4","X-Spam_score":"0.4","X-Spam_bar":"/","X-Spam_report":"(0.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,\n DKIM_VALID=-0.1,\n DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001,\n SPF_HELO_NONE=0.001, SPF_PASS=-0.001,\n SUSPICIOUS_RECIPS=2.51 autolearn=no 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":"The QLIST_FOREACH() macro, defined in \"qemu/queue.h\",\nalways assigns its iterator variable when entering the\nloop. Remove the pointless and possibly misleading\nassignment.\n\nMechanical patch using the following coccinelle spatch:\n\n  @@\n  type T;\n  identifier e;\n  iterator FOREACH_MACRO =~ \".*_FOREACH.*\";\n  statement S;\n  @@\n  -    T *e = ...;\n  +    T *e;\n       ... when != e\n       FOREACH_MACRO(e, ...) S\n\nSigned-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>\n---\n block/blkio.c               | 2 +-\n block/gluster.c             | 4 ++--\n hw/arm/virt-acpi-build.c    | 2 +-\n hw/i386/xen/xen-hvm.c       | 4 ++--\n hw/riscv/riscv-iommu.c      | 2 +-\n hw/vfio/cpr-legacy.c        | 2 +-\n hw/vfio/listener.c          | 4 ++--\n hw/xen/xen_pt_config_init.c | 4 ++--\n 8 files changed, 12 insertions(+), 12 deletions(-)","diff":"diff --git a/block/blkio.c b/block/blkio.c\nindex 20f138a38c5..fb8bec27d71 100644\n--- a/block/blkio.c\n+++ b/block/blkio.c\n@@ -124,7 +124,7 @@ blkio_do_alloc_bounce_buffer(BDRVBlkioState *s, BlkioBounceBuf *bounce,\n                              int64_t bytes)\n {\n     void *addr = s->bounce_pool.addr;\n-    BlkioBounceBuf *cur = NULL;\n+    BlkioBounceBuf *cur;\n     BlkioBounceBuf *prev = NULL;\n     ptrdiff_t space;\n \ndiff --git a/block/gluster.c b/block/gluster.c\nindex 4fb25b2c6d8..279f650241c 100644\n--- a/block/gluster.c\n+++ b/block/gluster.c\n@@ -251,7 +251,7 @@ static void glfs_set_preopened(const char *volume, glfs_t *fs)\n \n static glfs_t *glfs_find_preopened(const char *volume)\n {\n-    ListElement *entry = NULL;\n+    ListElement *entry;\n \n      QLIST_FOREACH(entry, &glfs_list, list) {\n         if (strcmp(entry->saved.volume, volume) == 0) {\n@@ -265,7 +265,7 @@ static glfs_t *glfs_find_preopened(const char *volume)\n \n static void glfs_clear_preopened(glfs_t *fs)\n {\n-    ListElement *entry = NULL;\n+    ListElement *entry;\n     ListElement *next;\n \n     if (fs == NULL) {\ndiff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c\nindex 591cfc993c6..a38a835d48d 100644\n--- a/hw/arm/virt-acpi-build.c\n+++ b/hw/arm/virt-acpi-build.c\n@@ -146,7 +146,7 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap,\n {\n     int ecam_id = VIRT_ECAM_ID(vms->highmem_ecam);\n     bool cxl_present = false;\n-    PCIBus *bus = vms->bus;\n+    PCIBus *bus;\n     bool acpi_pcihp = false;\n \n     if (vms->acpi_dev) {\ndiff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c\nindex 67d3e836eb1..d3ce082e07a 100644\n--- a/hw/i386/xen/xen-hvm.c\n+++ b/hw/i386/xen/xen-hvm.c\n@@ -184,7 +184,7 @@ static void xen_ram_init(PCMachineState *pcms,\n static XenPhysmap *get_physmapping(hwaddr start_addr, ram_addr_t size,\n                                    int page_mask)\n {\n-    XenPhysmap *physmap = NULL;\n+    XenPhysmap *physmap;\n \n     start_addr &= page_mask;\n \n@@ -200,7 +200,7 @@ static hwaddr xen_phys_offset_to_gaddr(hwaddr phys_offset, ram_addr_t size,\n                                        int page_mask)\n {\n     hwaddr addr = phys_offset & page_mask;\n-    XenPhysmap *physmap = NULL;\n+    XenPhysmap *physmap;\n \n     QLIST_FOREACH(physmap, &xen_physmap, list) {\n         if (range_covers_byte(physmap->phys_offset, physmap->size, addr)) {\ndiff --git a/hw/riscv/riscv-iommu.c b/hw/riscv/riscv-iommu.c\nindex c3c9ed6469a..bdc64b70ff2 100644\n--- a/hw/riscv/riscv-iommu.c\n+++ b/hw/riscv/riscv-iommu.c\n@@ -1681,7 +1681,7 @@ static void riscv_iommu_ats(RISCVIOMMUState *s,\n     IOMMUAccessFlags perm,\n     void (*trace_fn)(const char *id))\n {\n-    RISCVIOMMUSpace *as = NULL;\n+    RISCVIOMMUSpace *as;\n     IOMMUNotifier *n;\n     IOMMUTLBEvent event;\n     uint32_t pid;\ndiff --git a/hw/vfio/cpr-legacy.c b/hw/vfio/cpr-legacy.c\nindex 033a546c301..c431d899731 100644\n--- a/hw/vfio/cpr-legacy.c\n+++ b/hw/vfio/cpr-legacy.c\n@@ -212,7 +212,7 @@ void vfio_legacy_cpr_unregister_container(VFIOLegacyContainer *container)\n void vfio_cpr_giommu_remap(VFIOContainer *bcontainer,\n                            MemoryRegionSection *section)\n {\n-    VFIOGuestIOMMU *giommu = NULL;\n+    VFIOGuestIOMMU *giommu;\n     hwaddr as_offset = section->offset_within_address_space;\n     hwaddr iommu_offset = as_offset - section->offset_within_region;\n \ndiff --git a/hw/vfio/listener.c b/hw/vfio/listener.c\nindex 960da9e0a93..cf2f9ef5e8f 100644\n--- a/hw/vfio/listener.c\n+++ b/hw/vfio/listener.c\n@@ -337,7 +337,7 @@ static void vfio_ram_discard_unregister_listener(VFIOContainer *bcontainer,\n                                                  MemoryRegionSection *section)\n {\n     RamDiscardManager *rdm = memory_region_get_ram_discard_manager(section->mr);\n-    VFIORamDiscardListener *vrdl = NULL;\n+    VFIORamDiscardListener *vrdl;\n \n     QLIST_FOREACH(vrdl, &bcontainer->vrdl_list, next) {\n         if (vrdl->mr == section->mr &&\n@@ -467,7 +467,7 @@ static void vfio_device_error_append(VFIODevice *vbasedev, Error **errp)\n VFIORamDiscardListener *vfio_find_ram_discard_listener(\n     VFIOContainer *bcontainer, MemoryRegionSection *section)\n {\n-    VFIORamDiscardListener *vrdl = NULL;\n+    VFIORamDiscardListener *vrdl;\n \n     QLIST_FOREACH(vrdl, &bcontainer->vrdl_list, next) {\n         if (vrdl->mr == section->mr &&\ndiff --git a/hw/xen/xen_pt_config_init.c b/hw/xen/xen_pt_config_init.c\nindex 3edaeab1e34..bbc82a2bcfa 100644\n--- a/hw/xen/xen_pt_config_init.c\n+++ b/hw/xen/xen_pt_config_init.c\n@@ -62,7 +62,7 @@ static int xen_pt_hide_dev_cap(const XenHostPCIDevice *d, uint8_t grp_id)\n /*   find emulate register group entry */\n XenPTRegGroup *xen_pt_find_reg_grp(XenPCIPassthroughState *s, uint32_t address)\n {\n-    XenPTRegGroup *entry = NULL;\n+    XenPTRegGroup *entry;\n \n     /* find register group entry */\n     QLIST_FOREACH(entry, &s->reg_grps, entries) {\n@@ -80,7 +80,7 @@ XenPTRegGroup *xen_pt_find_reg_grp(XenPCIPassthroughState *s, uint32_t address)\n /* find emulate register entry */\n XenPTReg *xen_pt_find_reg(XenPTRegGroup *reg_grp, uint32_t address)\n {\n-    XenPTReg *reg_entry = NULL;\n+    XenPTReg *reg_entry;\n     XenPTRegInfo *reg = NULL;\n     uint32_t real_offset = 0;\n \n","prefixes":["1/8"]}