[Libvirt-cim] [PATCH 03/19] Coverity: Resolve CHECKED_RETURN - filter_by_pool()

John Ferlan jferlan at redhat.com
Thu May 16 14:57:38 UTC 2013


115

(17) Event check_return:
    Calling function "cu_get_str_prop(CMPIInstance const *, char const *,
    char const **)" without checking return value (as is done elsewhere 72
    out of 77 times).
(24) Event unchecked_value:
    No check of the return value of "cu_get_str_prop(inst, "InstanceID",
    &rasd_id)".

116                     cu_get_str_prop(inst, "InstanceID", &rasd_id);

Resolved by adding a check against CMPI_RC_OK, if not equal then just
continue
---
 src/Virt_ResourceAllocationFromPool.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/Virt_ResourceAllocationFromPool.c b/src/Virt_ResourceAllocationFromPool.c
index e702387..398eef5 100644
--- a/src/Virt_ResourceAllocationFromPool.c
+++ b/src/Virt_ResourceAllocationFromPool.c
@@ -113,7 +113,9 @@ static int filter_by_pool(struct inst_list *dest,
                     CMPI_RC_OK)
                         continue;
 
-                cu_get_str_prop(inst, "InstanceID", &rasd_id);
+                if (cu_get_str_prop(inst, "InstanceID", &rasd_id) !=
+                    CMPI_RC_OK)
+                        continue;
 
                 poolid = pool_member_of(_BROKER, CLASSNAME(op), type, rasd_id);
                 if ((poolid != NULL) && STREQ(poolid, _poolid))
-- 
1.8.1.4




More information about the Libvirt-cim mailing list