Skip to contentSkip to conversation

block/qcow2-cluster: Add missing "fallthrough" annotation

PATCH Applied Thomas Huth 3 participants 4 messages Sep 8, 2020 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block/qcow2-cluster: Add missing "fallthrough" annotation

When compiling with -Werror=implicit-fallthrough, the compiler currently complains:

../../devel/qemu/block/qcow2-cluster.c: In function ‘cluster_needs_new_alloc’:
../../devel/qemu/block/qcow2-cluster.c:1320:12: error: this statement may fall
through [-Werror=implicit-fallthrough=]

         if (l2_entry & QCOW_OFLAG_COPIED) {
            ^
../../devel/qemu/block/qcow2-cluster.c:1323:5: note: here
     case QCOW2_CLUSTER_UNALLOCATED:
     ^~~~

It's quite obvious that the fallthrough is intended here, so let's add a comment to silence the compiler warning.

---
 block/qcow2-cluster.c | 1 +
 1 file changed, 1 insertion(+)
block/qcow2-cluster.c +1 -0
index 996b3314f4..fcdf7af8e6 100644
@@ -1320,6 +1320,7 @@ static bool cluster_needs_new_alloc(BlockDriverState *bs, uint64_t l2_entry)
         if (l2_entry & QCOW_OFLAG_COPIED) {
             return false;
         }
+        /* fallthrough */
     case QCOW2_CLUSTER_UNALLOCATED:
     case QCOW2_CLUSTER_COMPRESSED:
     case QCOW2_CLUSTER_ZERO_PLAIN:
Signature · 1 line
2.18.2
#1 lore raw

Hi Thomas,

Quoted 2 lines · Thomas Huth

When compiling with -Werror=implicit-fallthrough, the compiler currently complains:

Do you know what is missing to add this in configure::warn_flags?

Quoted 31 lines

../../devel/qemu/block/qcow2-cluster.c: In function ‘cluster_needs_new_alloc’:
../../devel/qemu/block/qcow2-cluster.c:1320:12: error: this statement may fall
through [-Werror=implicit-fallthrough=]

         if (l2_entry & QCOW_OFLAG_COPIED) {
            ^
../../devel/qemu/block/qcow2-cluster.c:1323:5: note: here
     case QCOW2_CLUSTER_UNALLOCATED:
     ^~~~

It's quite obvious that the fallthrough is intended here, so let's add a comment to silence the compiler warning.

---
 block/qcow2-cluster.c | 1 +
 1 file changed, 1 insertion(+)
block/qcow2-cluster.c +1 -0
index 996b3314f4..fcdf7af8e6 100644
@@ -1320,6 +1320,7 @@ static bool cluster_needs_new_alloc(BlockDriverState *bs, uint64_t l2_entry)
         if (l2_entry & QCOW_OFLAG_COPIED) {
             return false;
         }
+        /* fallthrough */
     case QCOW2_CLUSTER_UNALLOCATED:
     case QCOW2_CLUSTER_COMPRESSED:
     case QCOW2_CLUSTER_ZERO_PLAIN:
#2 lore raw
Quoted 7 lines · Philippe Mathieu-Daudé

Hi Thomas,

Quoted 2 lines · Thomas Huth

When compiling with -Werror=implicit-fallthrough, the compiler currently complains:

Do you know what is missing to add this in configure::warn_flags?

Quite a bit, I think. I'm fixing it step by step...

Thomas

Applied
#3 lore raw
In reply to Thomas Huth

Am 08.09.2020 um 09:00 hat Thomas Huth geschrieben:

Quoted 12 lines

When compiling with -Werror=implicit-fallthrough, the compiler currently complains:

../../devel/qemu/block/qcow2-cluster.c: In function ‘cluster_needs_new_alloc’:
../../devel/qemu/block/qcow2-cluster.c:1320:12: error: this statement may fall
through [-Werror=implicit-fallthrough=]

         if (l2_entry & QCOW_OFLAG_COPIED) {
            ^
../../devel/qemu/block/qcow2-cluster.c:1323:5: note: here
     case QCOW2_CLUSTER_UNALLOCATED:
     ^~~~
Quoted 4 lines

It's quite obvious that the fallthrough is intended here, so let's add a comment to silence the compiler warning.

Thanks, applied to the block branch.

Kevin