On 05/16/2013 10:57 AM, John Ferlan wrote:
1089 dev->dev.mem.maxsize = dev->dev.mem.size;
(4) Event check_return:
Calling function "cu_get_u64_prop(CMPIInstance const *, char const *,
uint64_t *)" without checking return value (as is done elsewhere 9
out of 10 times).
(14) Event unchecked_value:
No check of the return value of "cu_get_u64_prop(inst, "Limit",
&dev->dev.mem.maxsize)".
1090 cu_get_u64_prop(inst, "Limit", &dev->dev.mem.maxsize);
Resolve by adding check and returning a message indicating what's missing
---
src/Virt_VirtualSystemManagementService.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/Virt_VirtualSystemManagementService.c
b/src/Virt_VirtualSystemManagementService.c
index cbb646d..ebf3e4a 100644
--- a/src/Virt_VirtualSystemManagementService.c
+++ b/src/Virt_VirtualSystemManagementService.c
@@ -1087,7 +1087,9 @@ static const char *mem_rasd_to_vdev(CMPIInstance *inst,
return "Missing `VirtualQuantity' field in Memory RASD";
dev->dev.mem.maxsize = dev->dev.mem.size;
- cu_get_u64_prop(inst, "Limit", &dev->dev.mem.maxsize);
+ ret = cu_get_u64_prop(inst, "Limit", &dev->dev.mem.maxsize);
+ if (ret != CMPI_RC_OK)
+ return "Missing `Limit' field in Memory RASD";
if (cu_get_str_prop(inst, "AllocationUnits", &units) !=
CMPI_RC_OK) {
CU_DEBUG("Memory RASD has no units, assuming bytes");
An issue was found with the above code since Limit doesn't seem to be a required
value, thus the code has been changed to the following:
diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemM
index cbb646d..f1441dc 100644
--- a/src/Virt_VirtualSystemManagementService.c
+++ b/src/Virt_VirtualSystemManagementService.c
@@ -1086,8 +1086,9 @@ static const char *mem_rasd_to_vdev(CMPIInstance *inst,
if (ret != CMPI_RC_OK)
return "Missing `VirtualQuantity' field in Memory RASD";
- dev->dev.mem.maxsize = dev->dev.mem.size;
- cu_get_u64_prop(inst, "Limit", &dev->dev.mem.maxsize);
+ ret = cu_get_u64_prop(inst, "Limit", &dev->dev.mem.maxsize);
+ if (ret != CMPI_RC_OK)
+ dev->dev.mem.maxsize = dev->dev.mem.size;
if (cu_get_str_prop(inst, "AllocationUnits", &units) != CMPI_RC_OK)
{
CU_DEBUG("Memory RASD has no units, assuming bytes");
The difference being setting mem.maxsize to mem.size only if the call fails
and not messaging if it does fail.