[PATCH 02/10] conf: domain: Remove checking of return value of virHashCreateFull

Peter Krempa pkrempa at redhat.com
Thu Jan 30 14:53:22 UTC 2020


This module has last two direct checks whether the value returned by
virHashCreateFull is NULL. Remove them so that static analyzers don't
get the false idea that checking the value is necessary.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/conf/domain_addr.c | 32 +++++++++++++-------------------
 1 file changed, 13 insertions(+), 19 deletions(-)

diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
index 607ba56efd..f07b3d9725 100644
--- a/src/conf/domain_addr.c
+++ b/src/conf/domain_addr.c
@@ -1044,28 +1044,22 @@ virDomainPCIAddressSetExtensionAlloc(virDomainPCIAddressSetPtr addrs,
         if (VIR_ALLOC(addrs->zpciIds) < 0)
             return -1;

-        if (!(addrs->zpciIds->uids = virHashCreateFull(10, NULL,
-                                                       virZPCIAddrKeyCode,
-                                                       virZPCIAddrKeyEqual,
-                                                       virZPCIAddrKeyCopy,
-                                                       virZPCIAddrKeyPrintHuman,
-                                                       virZPCIAddrKeyFree)))
-            goto error;
-
-        if (!(addrs->zpciIds->fids = virHashCreateFull(10, NULL,
-                                                       virZPCIAddrKeyCode,
-                                                       virZPCIAddrKeyEqual,
-                                                       virZPCIAddrKeyCopy,
-                                                       virZPCIAddrKeyPrintHuman,
-                                                       virZPCIAddrKeyFree)))
-            goto error;
+        addrs->zpciIds->uids = virHashCreateFull(10, NULL,
+                                                 virZPCIAddrKeyCode,
+                                                 virZPCIAddrKeyEqual,
+                                                 virZPCIAddrKeyCopy,
+                                                 virZPCIAddrKeyPrintHuman,
+                                                 virZPCIAddrKeyFree);
+
+        addrs->zpciIds->fids = virHashCreateFull(10, NULL,
+                                                 virZPCIAddrKeyCode,
+                                                 virZPCIAddrKeyEqual,
+                                                 virZPCIAddrKeyCopy,
+                                                 virZPCIAddrKeyPrintHuman,
+                                                 virZPCIAddrKeyFree);
     }

     return 0;
-
- error:
-    virDomainPCIAddressSetExtensionFree(addrs);
-    return -1;
 }


-- 
2.24.1




More information about the libvir-list mailing list