@samitouri / QOSamiQemu / commits / 9873bef556

cocci: Do not initialize variable used by RAMBLOCK_FOREACH* macro

The RAMBLOCK_FOREACH_MIGRATABLE() macro, defined in migration/ram.h, ends up calling QLIST_FOREACH_RCU() which 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-6-philmd@linaro.org>

Philippe Mathieu-Daudé committed Apr 15, 2026 at 23:14 UTC 9873bef5563cffd8b48ff38692a3715f4c960425
1 file changed +2 -2
migration/dirtyrate.c
+2 -2
@@ -485,7 +485,7 @@ static bool record_ramblock_hash_info(struct RamblockDirtyInfo **block_dinfo,
485 {
486 struct RamblockDirtyInfo *info = NULL;
487 struct RamblockDirtyInfo *dinfo = NULL;
488 - RAMBlock *block = NULL;
488 + RAMBlock *block;
489 int total_count = 0;
490 int index = 0;
491 bool ret = false;
@@ -568,7 +568,7 @@ static bool compare_page_hash_info(struct RamblockDirtyInfo *info,
568 int block_count)
569 {
570 struct RamblockDirtyInfo *block_dinfo = NULL;
571 - RAMBlock *block = NULL;
571 + RAMBlock *block;
572
573 RAMBLOCK_FOREACH_MIGRATABLE(block) {
574 if (skip_sample_ramblock(block)) {