
# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1196195268 28800 # Node ID fa0aa635ce2eb93e8a6f8581056f3d0f40122389 # Parent 1d3cf993995a4d162e11890a04cfcbf2446c3ca2 Fixes to EAFP for libcmpiutil API change Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 1d3cf993995a -r fa0aa635ce2e src/Virt_ElementAllocatedFromPool.c --- a/src/Virt_ElementAllocatedFromPool.c Tue Nov 27 12:27:30 2007 -0800 +++ b/src/Virt_ElementAllocatedFromPool.c Tue Nov 27 12:27:48 2007 -0800 @@ -63,7 +63,7 @@ static CMPIStatus vdev_to_pool(const CMP { CMPIStatus s; uint16_t type; - char *id = NULL; + const char *id = NULL; char *poolid = NULL; virConnectPtr conn = NULL; CMPIInstance *pool = NULL; @@ -76,8 +76,7 @@ static CMPIStatus vdev_to_pool(const CMP goto out; } - id = cu_get_str_path(ref, "DeviceID"); - if (id == NULL) { + if (cu_get_str_path(ref, "DeviceID", &id) != CMPI_RC_OK) { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, "Missing DeviceID"); @@ -107,7 +106,6 @@ static CMPIStatus vdev_to_pool(const CMP } out: - free(id); free(poolid); virConnectClose(conn); @@ -124,23 +122,20 @@ static int filter_by_pool(struct inst_li for (i = 0; i < src->cur; i++) { CMPIInstance *inst = src->list[i]; - char *cn = NULL; - char *dev_id = NULL; + const char *cn = NULL; + const char *dev_id = NULL; cu_get_str_prop(inst, "CreationClassName", &cn); cu_get_str_prop(inst, "DeviceID", &dev_id); if ((dev_id == NULL) || (cn == NULL)) - goto end; + continue; printf("Device %hhi:%s", type, dev_id); poolid = pool_member_of(_BROKER, cn, type, dev_id); if (poolid && STREQ(poolid, _poolid)) inst_list_add(dest, inst); - end: - free(dev_id); - free(cn); } return dest->cur; @@ -200,11 +195,10 @@ static CMPIStatus pool_to_vdev(const CMP struct std_assoc_info *info, struct inst_list *list) { - char *poolid; + const char *poolid; CMPIStatus s; - poolid = cu_get_str_path(ref, "InstanceID"); - if (poolid == NULL) { + if (cu_get_str_path(ref, "InstanceID", &poolid) != CMPI_RC_OK) { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, "Missing InstanceID"); @@ -244,8 +238,6 @@ static CMPIStatus pool_to_vdev(const CMP CMSetStatus(&s, CMPI_RC_OK); out: - free(poolid); - return s; }