[PATCH 0 of 2] #5 - SDC: Fixed type of returned instance and error code

Patch 1: The returned RASD instances have been of the general classname ResourceAllocationSettingData instead of the type specific one, e.g. ProcResourceAllocationSettingData Patch 2: RASD to AllocationCapabilities should return NOT_SUPPORTED instead of OK Diff to #1: patch 1: fixed missing check for unknown resource type Diff to #2: - added helper function to RASD that translates the resource type into the classname (patch 1 of 3) - updated patch 2 (#1 before) to make use of the helper function - updated patch 3 (#2 before) to make use of RETURN_UNSUPPORTED macro Diff to #3: - patch 1 and 3 are already checked in and no longer part of this patch series - added patch to harden free_rasd_prop_list() function to handle NULL pointer - patch 2 (also patch 2 before): cleaned up error handling Diff to #4: - patch 2: made inst_id a const char*

# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1197967850 -3600 # Node ID fcb43d2882bc6925c41b7e451e6c41e42d430025 # Parent 7dde77938c45866d0200d647d312407118abdc1a SDC: harden free_rasd_prop_list to handle NULL pointer Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r 7dde77938c45 -r fcb43d2882bc src/Virt_SettingsDefineCapabilities.c --- a/src/Virt_SettingsDefineCapabilities.c Tue Dec 18 10:19:52 2007 +0800 +++ b/src/Virt_SettingsDefineCapabilities.c Tue Dec 18 09:50:50 2007 +0100 @@ -89,17 +89,19 @@ static bool dup_rasd_prop_list(struct sd return true; } -static bool free_rasd_prop_list(struct sdc_rasd_prop *prop_list) +static void free_rasd_prop_list(struct sdc_rasd_prop *prop_list) { int i; + + if (!prop_list) + return; for (i = 0; prop_list[i].field != NULL; i++) { free(prop_list[i].field); free(prop_list[i].value); } - + free (prop_list); - return true; } static struct sdc_rasd_prop *mem_max(const CMPIObjectPath *ref,

# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1197967960 -3600 # Node ID 10e6c4ff5ebcd46dd8a2cb6952ea8d8201624f4d # Parent fcb43d2882bc6925c41b7e451e6c41e42d430025 SDC: returned instances are not of type specific subclass Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r fcb43d2882bc -r 10e6c4ff5ebc src/Virt_SettingsDefineCapabilities.c --- a/src/Virt_SettingsDefineCapabilities.c Tue Dec 18 09:50:50 2007 +0100 +++ b/src/Virt_SettingsDefineCapabilities.c Tue Dec 18 09:52:40 2007 +0100 @@ -42,6 +42,7 @@ #include "Virt_SettingsDefineCapabilities.h" #include "Virt_DevicePool.h" +#include "Virt_RASD.h" const static CMPIBroker *_BROKER; @@ -657,9 +658,10 @@ static CMPIInstance *sdc_rasd_inst(const sdc_rasd_type type) { CMPIInstance *inst = NULL; - struct sdc_rasd_prop *prop_list; + struct sdc_rasd_prop *prop_list = NULL; int i; - char *inst_id; + const char *inst_id = NULL; + const char *base = NULL; uint16_t resource_type; /* Defaults for the following are from CIM_SettingsDefineCapabilities.mof. */ @@ -700,15 +702,21 @@ static CMPIInstance *sdc_rasd_inst(const cu_statusf(broker, s, CMPI_RC_ERR_FAILED, "Unsupported sdc_rasd type"); - goto out; } if (s->rc != CMPI_RC_OK) goto out; + + if (rasd_classname_from_type(rasd->resource_type, &base) != CMPI_RC_OK) { + cu_statusf(broker, s, + CMPI_RC_ERR_FAILED, + "Resource type not known"); + goto out; + } inst = get_typed_instance(broker, CLASSNAME(ref), - "ResourceAllocationSettingData", + base, NAMESPACE(ref)); CMSetProperty(inst, "InstanceID", inst_id, CMPI_chars); @@ -725,10 +733,8 @@ static CMPIInstance *sdc_rasd_inst(const prop_list[i].value, prop_list[i].type); } - CU_DEBUG("freeing prop_list"); + out: free_rasd_prop_list(prop_list); - out: - CU_DEBUG("Returning inst"); return inst; }
participants (1)
-
Heidi Eckhart