<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
The error looks as follows:</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
/root/vzkernel.vzs/drivers/md/dm-qcow2-target.c:798:4: error: expected expression</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
&nbsp; 798 | &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; struct Qcow2BitmapHeaderExt bitmaps_ext;</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
&nbsp; &nbsp; &nbsp; | &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ^</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
/root/vzkernel.vzs/drivers/md/dm-qcow2-target.c:800:26: error: use of undeclared identifier 'bitmaps_ext'</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
&nbsp; 800 | &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (ext.len != sizeof(bitmaps_ext)) {</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
&nbsp; &nbsp; &nbsp; | &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ^</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
/root/vzkernel.vzs/drivers/md/dm-qcow2-target.c:805:24: error: use of undeclared identifier 'bitmaps_ext'</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
&nbsp; 805 | &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (offset + sizeof(bitmaps_ext) &gt; end) {</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
&nbsp; &nbsp; &nbsp; | &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ^</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
...</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
and more bitmaps_ext related errors follow.</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Yes, clang does accept declarations in the middle of code. I think it was not allowed only by some older C standards like C89 but in general it is a valid thing to do. In contrast, declaring variables inside a case block AFAIK is strictly incorrect. So not
 sure why gcc allows it.</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Regarding the fix, I checked the kernel code before submitting this change and found numerous places with curly brackets used to introduce a new scope inside a case block. So in my eyes it's fine.</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Best,</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Dmitry&nbsp;</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<hr style="display: inline-block; width: 98%;">
<div id="divRplyFwdMsg">
<div style="direction: ltr; font-family: Calibri, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<b>From:</b>&nbsp;Alexey Kuznetsov &lt;kuznet@virtuozzo.com&gt;<br>
<b>Sent:</b>&nbsp;Monday, November 17, 2025 3:05 PM<br>
<b>To:</b>&nbsp;Dmitry Sepp &lt;dmitry.sepp@virtuozzo.com&gt;<br>
<b>Cc:</b>&nbsp;Konstantin Khorenko &lt;khorenko@virtuozzo.com&gt;; Pavel Tikhomirov &lt;ptikhomirov@virtuozzo.com&gt;; devel@openvz.org &lt;devel@openvz.org&gt;<br>
<b>Subject:</b>&nbsp;Re: [Devel] [PATCH] dm-qcow2: fix a clang build error in the bitmap extension parser</div>
<div style="direction: ltr;">&nbsp;</div>
</div>
<div style="font-size: 11pt;" class="elementToProof">Ack!<br>
<br>
I suffer from the same problem with gcc 10. BTW what error clang reports?<br>
<br>
But I have a question though. Could you check: does this clang accept<br>
declarations<br>
in the middle of code? gcc 10 looks buggy: it accepts declarations<br>
in the middle of code, but does not accept this one as it insists label must<br>
be followed by non-declaration statement, which sounds utterly stupid when<br>
declations in the middle are accepted :-)<br>
<br>
Anyway, was not this a severe violation of coding style? checkpatch<br>
does not complain, so that I guess decalalrtions in the middle of code<br>
are not considered as a bug any longer. Which is sad.<br>
<br>
BTW I would consider instead of adding ugly stray {} just to scope,<br>
(which is _entirely_ nice, just looks ugly) to use declaration like this:<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; switch (ext.magic) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct Qcow2BitmapHeaderExt bitmaps_ext;<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case QCOW2_EXT_MAGIC_BITMAPS:<br>
<br>
It is syntactically correct in within any C, in line with natural desire to<br>
have all the declarations at beginning of scope. Though looks unusual.<br>
<br>
<br>
<br>
On Mon, Nov 17, 2025 at 9:11 PM Dmitry Sepp &lt;dmitry.sepp@virtuozzo.com&gt; wrote:<br>
&gt;<br>
&gt; Clang is less forgiving than gcc and does not allow to declare variables in the<br>
&gt; middle of a case block.<br>
&gt;<br>
&gt; Fix the issue by correctly intoducing a new scope.<br>
&gt;<br>
&gt; The issue has been observed on:<br>
&gt; clang version 17.0.6 ( 17.0.6-5.vl9)<br>
&gt; Target: x86_64-redhat-linux-gnu<br>
&gt; Thread model: posix<br>
&gt;<br>
&gt; Fixes: 75034a7628f6 (&quot;dm-qcow2: parse bitmap extension&quot;)<br>
&gt;<br>
&gt; Signed-off-by: Dmitry Sepp &lt;dmitry.sepp@virtuozzo.com&gt;<br>
&gt;<br>
&gt; Feature: dm-qcow2: block device over QCOW2 files driver<br>
&gt; Signed-off-by: Dmitry Sepp &lt;dmitry.sepp@virtuozzo.com&gt;<br>
&gt; ---<br>
&gt;&nbsp; drivers/md/dm-qcow2-target.c | 3 ++-<br>
&gt;&nbsp; 1 file changed, 2 insertions(+), 1 deletion(-)<br>
&gt;<br>
&gt; diff --git a/drivers/md/dm-qcow2-target.c b/drivers/md/dm-qcow2-target.c<br>
&gt; index 90f315315976..bf0b3728790d 100644<br>
&gt; --- a/drivers/md/dm-qcow2-target.c<br>
&gt; +++ b/drivers/md/dm-qcow2-target.c<br>
&gt; @@ -794,7 +794,7 @@ static int qcow2_parse_extensions(struct dm_target *ti, struct qcow2 *qcow2,<br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; offset += sizeof(ext);<br>
&gt;<br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; switch (ext.magic) {<br>
&gt; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case QCOW2_EXT_MAGIC_BITMAPS:<br>
&gt; +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case QCOW2_EXT_MAGIC_BITMAPS: {<br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct Qcow2BitmapHeaderExt bitmaps_ext;<br>
&gt;<br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (ext.len != sizeof(bitmaps_ext)) {<br>
&gt; @@ -814,6 +814,7 @@ static int qcow2_parse_extensions(struct dm_target *ti, struct qcow2 *qcow2,<br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return ret;<br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<br>
&gt; +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case QCOW2_EXT_MAGIC_END:<br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 0;<br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; default:<br>
&gt; --<br>
&gt; 2.51.0<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; Devel mailing list<br>
&gt; Devel@openvz.org<br>
&gt; <a data-auth="NotApplicable" class="OWAAutoLink" id="OWA6089d0ff-7c71-c032-863b-a7c696440fd7" href="https://lists.openvz.org/mailman/listinfo/devel">
https://lists.openvz.org/mailman/listinfo/devel</a></div>
</body>
</html>