[Devel] [PATCH] dm-qcow2: fix a clang build error in the bitmap extension parser

Dmitry Sepp dmitry.sepp at virtuozzo.com
Mon Nov 17 15:46:26 MSK 2025


Clang is less forgiving than gcc and does not allow to declare variables in the
middle of a case block.

Fix the issue by correctly intoducing a new scope.

The issue has been observed on:
clang version 17.0.6 ( 17.0.6-5.vl9)
Target: x86_64-redhat-linux-gnu
Thread model: posix

Fixes: 75034a7628f6 ("dm-qcow2: parse bitmap extension")

Signed-off-by: Dmitry Sepp <dmitry.sepp at virtuozzo.com>

Feature: dm-qcow2: block device over QCOW2 files driver
Signed-off-by: Dmitry Sepp <dmitry.sepp at virtuozzo.com>
---
 drivers/md/dm-qcow2-target.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/md/dm-qcow2-target.c b/drivers/md/dm-qcow2-target.c
index 90f315315976..bf0b3728790d 100644
--- a/drivers/md/dm-qcow2-target.c
+++ b/drivers/md/dm-qcow2-target.c
@@ -794,7 +794,7 @@ static int qcow2_parse_extensions(struct dm_target *ti, struct qcow2 *qcow2,
 		offset += sizeof(ext);
 
 		switch (ext.magic) {
-		case QCOW2_EXT_MAGIC_BITMAPS:
+		case QCOW2_EXT_MAGIC_BITMAPS: {
 			struct Qcow2BitmapHeaderExt bitmaps_ext;
 
 			if (ext.len != sizeof(bitmaps_ext)) {
@@ -814,6 +814,7 @@ static int qcow2_parse_extensions(struct dm_target *ti, struct qcow2 *qcow2,
 				return ret;
 			}
 			break;
+		}
 		case QCOW2_EXT_MAGIC_END:
 			return 0;
 		default:
-- 
2.51.0



More information about the Devel mailing list