diff mbox series

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

Message ID 20200908070028.193298-1-thuth@redhat.com
State New
Headers show
Series block/qcow2-cluster: Add missing "fallthrough" annotation | expand

Commit Message

Thomas Huth Sept. 8, 2020, 7 a.m. UTC
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.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 block/qcow2-cluster.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Philippe Mathieu-Daudé Sept. 8, 2020, 8:43 a.m. UTC | #1
Hi Thomas,

On 9/8/20 9:00 AM, Thomas Huth wrote:
> When compiling with -Werror=implicit-fallthrough, the compiler currently
> complains:

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

> 
> ../../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.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  block/qcow2-cluster.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
> index 996b3314f4..fcdf7af8e6 100644
> --- a/block/qcow2-cluster.c
> +++ b/block/qcow2-cluster.c
> @@ -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:
>
Thomas Huth Sept. 8, 2020, 9:31 a.m. UTC | #2
On 08/09/2020 10.43, Philippe Mathieu-Daudé wrote:
> Hi Thomas,
> 
> On 9/8/20 9:00 AM, Thomas Huth wrote:
>> 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
Kevin Wolf Sept. 8, 2020, 2:42 p.m. UTC | #3
Am 08.09.2020 um 09:00 hat Thomas Huth geschrieben:
> 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.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>

Thanks, applied to the block branch.

Kevin
diff mbox series

Patch

diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
index 996b3314f4..fcdf7af8e6 100644
--- a/block/qcow2-cluster.c
+++ b/block/qcow2-cluster.c
@@ -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: