mirror of
https://github.com/qemu/qemu.git
synced 2026-07-08 17:46:17 +00:00
cocci: Do not initialize variable used by QLIST_FOREACH macro
The QLIST_FOREACH() macro, defined in "qemu/queue.h",
always assigns its iterator variable when entering the
loop. Remove the pointless and possibly misleading
assignment.
Mechanical patch using the following coccinelle spatch:
@@
type T;
identifier e;
iterator FOREACH_MACRO =~ ".*_FOREACH.*";
statement S;
@@
- T *e = ...;
+ T *e;
... when != e
FOREACH_MACRO(e, ...) S
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Message-Id: <20260415215539.92629-2-philmd@linaro.org>
This commit is contained in:
@@ -124,7 +124,7 @@ blkio_do_alloc_bounce_buffer(BDRVBlkioState *s, BlkioBounceBuf *bounce,
|
||||
int64_t bytes)
|
||||
{
|
||||
void *addr = s->bounce_pool.addr;
|
||||
BlkioBounceBuf *cur = NULL;
|
||||
BlkioBounceBuf *cur;
|
||||
BlkioBounceBuf *prev = NULL;
|
||||
ptrdiff_t space;
|
||||
|
||||
|
||||
@@ -251,7 +251,7 @@ static void glfs_set_preopened(const char *volume, glfs_t *fs)
|
||||
|
||||
static glfs_t *glfs_find_preopened(const char *volume)
|
||||
{
|
||||
ListElement *entry = NULL;
|
||||
ListElement *entry;
|
||||
|
||||
QLIST_FOREACH(entry, &glfs_list, list) {
|
||||
if (strcmp(entry->saved.volume, volume) == 0) {
|
||||
@@ -265,7 +265,7 @@ static glfs_t *glfs_find_preopened(const char *volume)
|
||||
|
||||
static void glfs_clear_preopened(glfs_t *fs)
|
||||
{
|
||||
ListElement *entry = NULL;
|
||||
ListElement *entry;
|
||||
ListElement *next;
|
||||
|
||||
if (fs == NULL) {
|
||||
|
||||
@@ -146,7 +146,7 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap,
|
||||
{
|
||||
int ecam_id = VIRT_ECAM_ID(vms->highmem_ecam);
|
||||
bool cxl_present = false;
|
||||
PCIBus *bus = vms->bus;
|
||||
PCIBus *bus;
|
||||
bool acpi_pcihp = false;
|
||||
|
||||
if (vms->acpi_dev) {
|
||||
|
||||
@@ -184,7 +184,7 @@ static void xen_ram_init(PCMachineState *pcms,
|
||||
static XenPhysmap *get_physmapping(hwaddr start_addr, ram_addr_t size,
|
||||
int page_mask)
|
||||
{
|
||||
XenPhysmap *physmap = NULL;
|
||||
XenPhysmap *physmap;
|
||||
|
||||
start_addr &= page_mask;
|
||||
|
||||
@@ -200,7 +200,7 @@ static hwaddr xen_phys_offset_to_gaddr(hwaddr phys_offset, ram_addr_t size,
|
||||
int page_mask)
|
||||
{
|
||||
hwaddr addr = phys_offset & page_mask;
|
||||
XenPhysmap *physmap = NULL;
|
||||
XenPhysmap *physmap;
|
||||
|
||||
QLIST_FOREACH(physmap, &xen_physmap, list) {
|
||||
if (range_covers_byte(physmap->phys_offset, physmap->size, addr)) {
|
||||
|
||||
@@ -1678,7 +1678,7 @@ static void riscv_iommu_ats(RISCVIOMMUState *s,
|
||||
IOMMUAccessFlags perm,
|
||||
void (*trace_fn)(const char *id))
|
||||
{
|
||||
RISCVIOMMUSpace *as = NULL;
|
||||
RISCVIOMMUSpace *as;
|
||||
IOMMUNotifier *n;
|
||||
IOMMUTLBEvent event;
|
||||
uint32_t pid;
|
||||
|
||||
@@ -212,7 +212,7 @@ void vfio_legacy_cpr_unregister_container(VFIOLegacyContainer *container)
|
||||
void vfio_cpr_giommu_remap(VFIOContainer *bcontainer,
|
||||
MemoryRegionSection *section)
|
||||
{
|
||||
VFIOGuestIOMMU *giommu = NULL;
|
||||
VFIOGuestIOMMU *giommu;
|
||||
hwaddr as_offset = section->offset_within_address_space;
|
||||
hwaddr iommu_offset = as_offset - section->offset_within_region;
|
||||
|
||||
|
||||
@@ -333,7 +333,7 @@ static void vfio_ram_discard_unregister_listener(VFIOContainer *bcontainer,
|
||||
MemoryRegionSection *section)
|
||||
{
|
||||
RamDiscardManager *rdm = memory_region_get_ram_discard_manager(section->mr);
|
||||
VFIORamDiscardListener *vrdl = NULL;
|
||||
VFIORamDiscardListener *vrdl;
|
||||
|
||||
QLIST_FOREACH(vrdl, &bcontainer->vrdl_list, next) {
|
||||
if (vrdl->mr == section->mr &&
|
||||
@@ -463,7 +463,7 @@ static void vfio_device_error_append(VFIODevice *vbasedev, Error **errp)
|
||||
VFIORamDiscardListener *vfio_find_ram_discard_listener(
|
||||
VFIOContainer *bcontainer, MemoryRegionSection *section)
|
||||
{
|
||||
VFIORamDiscardListener *vrdl = NULL;
|
||||
VFIORamDiscardListener *vrdl;
|
||||
|
||||
QLIST_FOREACH(vrdl, &bcontainer->vrdl_list, next) {
|
||||
if (vrdl->mr == section->mr &&
|
||||
|
||||
@@ -62,7 +62,7 @@ static int xen_pt_hide_dev_cap(const XenHostPCIDevice *d, uint8_t grp_id)
|
||||
/* find emulate register group entry */
|
||||
XenPTRegGroup *xen_pt_find_reg_grp(XenPCIPassthroughState *s, uint32_t address)
|
||||
{
|
||||
XenPTRegGroup *entry = NULL;
|
||||
XenPTRegGroup *entry;
|
||||
|
||||
/* find register group entry */
|
||||
QLIST_FOREACH(entry, &s->reg_grps, entries) {
|
||||
@@ -80,7 +80,7 @@ XenPTRegGroup *xen_pt_find_reg_grp(XenPCIPassthroughState *s, uint32_t address)
|
||||
/* find emulate register entry */
|
||||
XenPTReg *xen_pt_find_reg(XenPTRegGroup *reg_grp, uint32_t address)
|
||||
{
|
||||
XenPTReg *reg_entry = NULL;
|
||||
XenPTReg *reg_entry;
|
||||
XenPTRegInfo *reg = NULL;
|
||||
uint32_t real_offset = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user