[Libvirt-cim] [PATCH 07/19] Coverity: Resolve CHECKED_RETURN - return_enum_rasds()

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


1097            inst_list_init(&list);
1098

(1) Event check_return:
    Calling function "res_type_from_rasd_classname(char const *, uint16_t *)"
    without checking return value (as is done elsewhere 11 out of 12 times).
(7) Event unchecked_value:
    No check of the return value of "res_type_from_rasd_classname(
    (char *)(*ref->ft->getClassName)(ref, NULL)->hdl, &type)".

1099            res_type_from_rasd_classname(CLASSNAME(ref), &type);

Resolve by checking return vs. CMPI_RC_OK, setting error, and returning
---
 src/Virt_RASD.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c
index 6e8a244..ad1a2e7 100644
--- a/src/Virt_RASD.c
+++ b/src/Virt_RASD.c
@@ -1096,7 +1096,12 @@ static CMPIStatus return_enum_rasds(const CMPIObjectPath *ref,
 
         inst_list_init(&list);
 
-        res_type_from_rasd_classname(CLASSNAME(ref), &type);
+        if (res_type_from_rasd_classname(CLASSNAME(ref), &type) != CMPI_RC_OK) {
+                cu_statusf(_BROKER, &s,
+                           CMPI_RC_ERR_FAILED,
+                           "Unable to determine RASD type");
+                goto out;
+        }
 
         s = enum_rasds(_BROKER, ref, NULL,
                        type, properties, &list);
-- 
1.8.1.4




More information about the Libvirt-cim mailing list