Ack!

I suffer from the same problem with gcc 10. BTW what error clang reports?

But I have a question though. Could you check: does this clang accept
declarations
in the middle of code? gcc 10 looks buggy: it accepts declarations
in the middle of code, but does not accept this one as it insists label must
be followed by non-declaration statement, which sounds utterly stupid when
declations in the middle are accepted :-)

Anyway, was not this a severe violation of coding style? checkpatch
does not complain, so that I guess decalalrtions in the middle of code
are not considered as a bug any longer. Which is sad.

BTW I would consider instead of adding ugly stray {} just to scope,
(which is _entirely_ nice, just looks ugly) to use declaration like this:

                switch (ext.magic) {
                      struct Qcow2BitmapHeaderExt bitmaps_ext;

                case QCOW2_EXT_MAGIC_BITMAPS:

It is syntactically correct in within any C, in line with natural desire to
have all the declarations at beginning of scope. Though looks unusual.



On Mon, Nov 17, 2025 at 9:11 PM Dmitry Sepp <[email protected]> wrote:
>
> 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 <[email protected]>
>
> Feature: dm-qcow2: block device over QCOW2 files driver
> Signed-off-by: Dmitry Sepp <[email protected]>
> ---
>  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
>
> _______________________________________________
> Devel mailing list
> [email protected]
> https://lists.openvz.org/mailman/listinfo/devel

_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to