[libvirt PATCH v2 2/3] nodedev: handle failure to generate mdevctl cmd

Jonathon Jongsma jjongsma at redhat.com
Wed Apr 21 15:52:35 UTC 2021


Coverity complained that the 'default' case of the switch in
nodeDeviceGetMdevctlCommand() was falling through without initializing
'cmd'. Return NULL in this case even though it should never happen.

Signed-off-by: Jonathon Jongsma <jjongsma at redhat.com>
Reviewed-by: Michal Privoznik <mprivozn at redhat.com>
---
 src/node_device/node_device_driver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
index e565cc29ec..49f3cc166d 100644
--- a/src/node_device/node_device_driver.c
+++ b/src/node_device/node_device_driver.c
@@ -743,7 +743,7 @@ nodeDeviceGetMdevctlCommand(virNodeDeviceDef *def,
     case MDEVCTL_CMD_LAST:
     default:
         /* SHOULD NEVER HAPPEN */
-        break;
+        return NULL;
     }
 
     switch (cmd_type) {
-- 
2.26.3




More information about the libvir-list mailing list