Re: [libvirt PATCH] conf: add missing break on a switch case

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jul 19, 2022 at 10:40:46AM -0500, Jonathon Jongsma wrote:
> This was not causing any problems because all cases below were empty,
> but in order to avoid future misbehavior, add a break to this case.

FYI, future misbehaviour would have been prevented by -Wimplicit-fallthrough.


diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
index 51746229fc..a920a3cdae 100644
--- a/src/conf/node_device_conf.c
+++ b/src/conf/node_device_conf.c
@@ -776,6 +776,7 @@ virNodeDeviceDefFormat(const virNodeDeviceDef *def)
         case VIR_NODE_DEV_CAP_VPORTS:
         case VIR_NODE_DEV_CAP_VPD:
         case VIR_NODE_DEV_CAP_LAST:
+            g_printerr("Hello world\n");
             break;
         }
 

$ ninja
...snip...

../src/conf/node_device_conf.c: In function ‘virNodeDeviceDefFormat’:
../src/conf/node_device_conf.c:769:16: error: this statement may fall through [-Werror=implicit-fallthrough=]
  769 |             if (data->ap_matrix.flags & VIR_NODE_DEV_CAP_FLAG_AP_MATRIX_MDEV)
      |                ^
../src/conf/node_device_conf.c:774:9: note: here
  774 |         case VIR_NODE_DEV_CAP_MDEV_TYPES:
      |         ^~~~
cc1: all warnings being treated as errors
ninja: build stopped: subcommand failed.

Kinda surprised it doesn't already generate a warning in this situation,
but I guess since there's no code in the later labels, it was considered
harmless.

> 
> Signed-off-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx>
> ---
>  src/conf/node_device_conf.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
> index 51746229fc..364bb489bd 100644
> --- a/src/conf/node_device_conf.c
> +++ b/src/conf/node_device_conf.c
> @@ -770,7 +770,7 @@ virNodeDeviceDefFormat(const virNodeDeviceDef *def)
>                  virNodeDeviceCapMdevTypesFormat(&buf,
>                                                  data->ap_matrix.mdev_types,
>                                                  data->ap_matrix.nmdev_types);
> -
> +            break;
>          case VIR_NODE_DEV_CAP_MDEV_TYPES:
>          case VIR_NODE_DEV_CAP_FC_HOST:
>          case VIR_NODE_DEV_CAP_VPORTS:

Reviewed-by: Daniel P. Berrangé <berrange@xxxxxxxxxx>

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux