[Libvirt-cim] [PATCH 13 of 18] Fixes to ElementCapabilities for libcmpiutil API change

Dan Smith danms at us.ibm.com
Tue Nov 27 19:28:39 UTC 2007


# HG changeset patch
# User Dan Smith <danms at us.ibm.com>
# Date 1196195127 28800
# Node ID 589cad1316a9eb3fe0214cf9515bb72ccaef91f8
# Parent  fecc81fd400c780ecb496af2ed9ba17001ff2f05
Fixes to ElementCapabilities for libcmpiutil API change

Signed-off-by: Dan Smith <danms at us.ibm.com>

diff -r fecc81fd400c -r 589cad1316a9 src/Virt_ElementCapabilities.c
--- a/src/Virt_ElementCapabilities.c	Tue Nov 27 12:25:14 2007 -0800
+++ b/src/Virt_ElementCapabilities.c	Tue Nov 27 12:25:27 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,8 +65,7 @@ static CMPIStatus sys_to_cap(const CMPIO
         if (host_rc != CMPI_RC_OK)
                 goto out;
         
-        sys_name = cu_get_str_path(ref, "Name");
-        if (!STREQ(sys_name, host_name)) {
+        if (cu_get_str_path(ref, "Name", &sys_name) != CMPI_RC_OK) {
                 cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED,
                            "System '%s' is not a host system.", sys_name);
                 goto out;
@@ -76,7 +75,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 +82,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 +120,6 @@ static CMPIStatus cap_to_sys(const CMPIO
  out:
         free(host);
         free(device);
-        free(inst_id);
         return s;
 }
 
@@ -145,15 +141,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.");
@@ -179,7 +174,7 @@ static CMPIStatus cap_to_cs(const CMPIOb
  error1:
         free(host);
         free(device);
-        free(inst_id);
+
         return s;
 }
 
@@ -196,13 +191,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;
@@ -225,8 +219,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,




More information about the Libvirt-cim mailing list