[Libvirt-cim] [PATCH 05/19] Coverity: Resolve CHECKED_RETURN - get_pools()

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


(7) 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).
(14) Event unchecked_value:
    No check of the return value of "cu_get_str_prop(inst,
    "InstanceID", &id)".

171                             cu_get_str_prop(inst, "InstanceID", &id);

Resolve by checking return status vs. CMPI_RC_OK and just continuing to
next entry
---
 src/Virt_ElementAllocatedFromPool.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/Virt_ElementAllocatedFromPool.c b/src/Virt_ElementAllocatedFromPool.c
index c7813b7..946580c 100644
--- a/src/Virt_ElementAllocatedFromPool.c
+++ b/src/Virt_ElementAllocatedFromPool.c
@@ -168,7 +168,9 @@ static CMPIStatus get_pools(const CMPIObjectPath *ref,
                         CMPIInstance *inst = tmp.list[i];
                         const char *id = NULL;
 
-                        cu_get_str_prop(inst, "InstanceID", &id);
+                        if (cu_get_str_prop(inst, "InstanceID", &id) !=
+                           CMPI_RC_OK)
+                                continue;
 
                         if (!STREQC(id, poolid))
                                 inst_list_add(list, inst);
-- 
1.8.1.4




More information about the Libvirt-cim mailing list