# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1196273290 28800
# Node ID 30dcc8eaa9a5455815dae18df6b0a98e7e352fc5
# Parent becc78027309750c7cfd300e55d33b9e774eef6a
Fixes to ElementCapabilities for libcmpiutil API change
Changes:
- Updated to reflect new code in Kaitlin's recent patch
- Fixed to *not* remove a valid STREQ() check in sys_to_cap()
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r becc78027309 -r 30dcc8eaa9a5 src/Virt_ElementCapabilities.c
--- a/src/Virt_ElementCapabilities.c Wed Nov 28 09:50:29 2007 -0800
+++ b/src/Virt_ElementCapabilities.c Wed Nov 28 10:08:10 2007 -0800
@@ -53,8 +53,8 @@ static CMPIStatus sys_to_cap(const CMPIO
{
CMPIInstance *inst;
CMPIrc host_rc;
- char *host_name = NULL;
- char *sys_name = NULL;
+ const char *host_name = NULL;
+ const char *sys_name = NULL;
CMPIStatus s = {CMPI_RC_OK, NULL};
s = get_host_cs(_BROKER, ref, &inst);
@@ -65,7 +65,13 @@ static CMPIStatus sys_to_cap(const CMPIO
if (host_rc != CMPI_RC_OK)
goto out;
- sys_name = cu_get_str_path(ref, "Name");
+ if (cu_get_str_path(ref, "Name", &sys_name) != CMPI_RC_OK) {
+ cu_statusf(_BROKER, *s,
+ CMPI_RC_ERR_FAILED,
+ "Missing `Name' property");
+ goto out;
+ }
+
if (!STREQ(sys_name, host_name)) {
cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED,
"System '%s' is not a host system.",
sys_name);
@@ -76,7 +82,6 @@ static CMPIStatus sys_to_cap(const CMPIO
if (s.rc == CMPI_RC_OK)
inst_list_add(list, inst);
out:
- free(sys_name);
return s;
}
@@ -84,16 +89,15 @@ static CMPIStatus cap_to_sys(const CMPIO
struct std_assoc_info *info,
struct inst_list *list)
{
- char *inst_id;
+ const char *inst_id;
char *host;
char *device;
- char *host_name;
+ const char *host_name;
CMPIrc host_rc;
CMPIInstance *inst;
CMPIStatus s = {CMPI_RC_OK, NULL};
- inst_id = cu_get_str_path(ref, "InstanceID");
- if (inst_id == NULL) {
+ if (cu_get_str_path(ref, "InstanceID", &inst_id) != CMPI_RC_OK) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
"Could not get InstanceID.");
@@ -123,7 +127,6 @@ static CMPIStatus cap_to_sys(const CMPIO
out:
free(host);
free(device);
- free(inst_id);
return s;
}
@@ -133,10 +136,9 @@ static CMPIStatus cs_to_cap(const CMPIOb
{
CMPIInstance *inst;
CMPIStatus s = {CMPI_RC_OK, NULL};
- char *sys_name = NULL;
-
- sys_name = cu_get_str_path(ref, "Name");
- if (sys_name == NULL) {
+ const char *sys_name = NULL;
+
+ if (cu_get_str_path(ref, "Name", &sys_name) != CMPI_RC_OK) {
CMSetStatusWithChars(_BROKER, &s,
CMPI_RC_ERR_FAILED,
"Missing key: Name");
@@ -148,8 +150,6 @@ static CMPIStatus cs_to_cap(const CMPIOb
inst_list_add(list, inst);
out:
- free(sys_name);
-
return s;
}
@@ -157,15 +157,14 @@ static CMPIStatus cap_to_cs(const CMPIOb
struct std_assoc_info *info,
struct inst_list *list)
{
- char *inst_id;
+ const char *inst_id;
char *host;
char *device;
CMPIInstance *inst;
virConnectPtr conn;
CMPIStatus s = {CMPI_RC_OK, NULL};
- inst_id = cu_get_str_path(ref, "InstanceID");
- if (inst_id == NULL) {
+ if (cu_get_str_path(ref, "InstanceID", &inst_id) != CMPI_RC_OK) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
"Could not get InstanceID.");
@@ -191,7 +190,7 @@ static CMPIStatus cap_to_cs(const CMPIOb
error1:
free(host);
free(device);
- free(inst_id);
+
return s;
}
@@ -208,13 +207,12 @@ static CMPIStatus pool_to_alloc(const CM
struct inst_list *list)
{
int ret;
- char *inst_id;
+ const char *inst_id;
uint16_t type;
CMPIInstance *inst = NULL;
CMPIStatus s = {CMPI_RC_OK};
- inst_id = cu_get_str_path(ref, "InstanceID");
- if (inst_id == NULL) {
+ if (cu_get_str_path(ref, "InstanceID", &inst_id) != CMPI_RC_OK) {
CMSetStatusWithChars(_BROKER, &s, CMPI_RC_ERR_FAILED,
"Could not get InstanceID.");
goto out;
@@ -237,8 +235,6 @@ static CMPIStatus pool_to_alloc(const CM
inst_list_add(list, inst);
out:
- free(inst_id);
-
return s;
}
static CMPIInstance *make_ref(const CMPIObjectPath *ref,