[Libvirt-cim] [PATCH] (#2) This changes any uses of CMSetStatus() to cu_statusf()

Dan Smith danms at us.ibm.com
Fri Feb 15 15:13:53 UTC 2008


# HG changeset patch
# User Dan Smith <danms at us.ibm.com>
# Date 1203088430 28800
# Node ID 72f9d41f72aaf7d0eb06191f4170efdb9f490d9d
# Parent  ae2cfc5a6a853690af1fc6821b1767e383f0d24a
(#2) This changes any uses of CMSetStatus() to cu_statusf()

With new versions of GCC, the check for (s != NULL) in the macro sets off
the "Address of `s' will always be true" warning.  We don't want to turn
that warning off, so this seems like the better choice

Changes:
 - Fix broken error code

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

diff -r ae2cfc5a6a85 -r 72f9d41f72aa src/Virt_ComputerSystem.c
--- a/src/Virt_ComputerSystem.c	Wed Feb 13 08:16:37 2008 -0800
+++ b/src/Virt_ComputerSystem.c	Fri Feb 15 07:13:50 2008 -0800
@@ -440,7 +440,9 @@ static CMPIStatus return_enum_domains(co
         inst_list_init(&list);
         ret = enum_domains(_BROKER, conn, NAMESPACE(reference), &list);
         if (!ret) {
-                CMSetStatus(&s, CMPI_RC_ERR_FAILED);
+                cu_statusf(_BROKER, &s,
+                           CMPI_RC_ERR_FAILED,
+                           "Failed to get domain list");
                 goto out;
         }
 
@@ -449,8 +451,9 @@ static CMPIStatus return_enum_domains(co
         else
                 cu_return_instances(results, &list);
 
-        CMSetStatus(&s, CMPI_RC_OK);
-
+        cu_statusf(_BROKER, &s,
+                   CMPI_RC_OK,
+                   "");
  out:
         inst_list_free(&list);
 
@@ -734,7 +737,9 @@ static CMPIStatus __state_change(const c
         else if (state == CIM_STATE_RESET)
                 s = state_change_reset(dom, &info);
         else
-                CMSetStatus(&s, CMPI_RC_ERR_NOT_SUPPORTED);
+                cu_statusf(_BROKER, &s,
+                           CMPI_RC_ERR_NOT_SUPPORTED,
+                           "State not supported");
 
  out:
         virDomainFree(dom);
@@ -757,7 +762,9 @@ static CMPIStatus state_change(CMPIMetho
 
         ret = cu_get_u16_arg(argsin, "RequestedState", &state);
         if (ret != CMPI_RC_OK) {
-                CMSetStatus(&s, CMPI_RC_ERR_INVALID_PARAMETER);
+                cu_statusf(_BROKER, &s,
+                           CMPI_RC_ERR_INVALID_PARAMETER,
+                           "Invalid RequestedState");
                 goto out;
         }
 
diff -r ae2cfc5a6a85 -r 72f9d41f72aa src/Virt_Device.c
--- a/src/Virt_Device.c	Wed Feb 13 08:16:37 2008 -0800
+++ b/src/Virt_Device.c	Fri Feb 15 07:13:50 2008 -0800
@@ -371,7 +371,9 @@ static CMPIStatus enum_devices(const CMP
         inst_list_free(&list);
 
  out:
-        CMSetStatus(&s, CMPI_RC_OK);
+        cu_statusf(_BROKER, &s,
+                   CMPI_RC_OK,
+                   "");
         virConnectClose(conn);
 
         return s;
diff -r ae2cfc5a6a85 -r 72f9d41f72aa src/Virt_DevicePool.c
--- a/src/Virt_DevicePool.c	Wed Feb 13 08:16:37 2008 -0800
+++ b/src/Virt_DevicePool.c	Fri Feb 15 07:13:50 2008 -0800
@@ -795,7 +795,9 @@ static CMPIStatus return_pool(const CMPI
                              &list);
         if (s.rc == CMPI_RC_OK) {
                 __return_pool(results, &list, name_only);
-                CMSetStatus(&s, CMPI_RC_OK);
+                cu_statusf(_BROKER, &s,
+                           CMPI_RC_OK,
+                           "");
         } else {
                 cu_statusf(_BROKER, &s,
                            CMPI_RC_ERR_FAILED,
diff -r ae2cfc5a6a85 -r 72f9d41f72aa src/Virt_ElementAllocatedFromPool.c
--- a/src/Virt_ElementAllocatedFromPool.c	Wed Feb 13 08:16:37 2008 -0800
+++ b/src/Virt_ElementAllocatedFromPool.c	Fri Feb 15 07:13:50 2008 -0800
@@ -102,7 +102,9 @@ static CMPIStatus vdev_to_pool(const CMP
         pool = get_pool_by_id(_BROKER, conn, poolid, NAMESPACE(ref));
         if (pool != NULL) {
                 inst_list_add(list, pool);
-                CMSetStatus(&s, CMPI_RC_OK);
+                cu_statusf(_BROKER, &s,
+                           CMPI_RC_OK,
+                           "");
         } else {
                 cu_statusf(_BROKER, &s,
                            CMPI_RC_ERR_FAILED,
@@ -220,8 +222,9 @@ static CMPIStatus pool_to_vdev(const CMP
 
         devs_from_pool(type, ref, poolid, list);
 
-        CMSetStatus(&s, CMPI_RC_OK);
-
+        cu_statusf(_BROKER, &s,
+                   CMPI_RC_OK,
+                   "");
  out:
         return s;
 }
diff -r ae2cfc5a6a85 -r 72f9d41f72aa src/Virt_ElementCapabilities.c
--- a/src/Virt_ElementCapabilities.c	Wed Feb 13 08:16:37 2008 -0800
+++ b/src/Virt_ElementCapabilities.c	Fri Feb 15 07:13:50 2008 -0800
@@ -72,7 +72,9 @@ static CMPIStatus validate_caps_get_serv
 
                 s = get_migration_service(ref, &_inst, _BROKER);
         } else
-                CMSetStatus(&s, CMPI_RC_ERR_NOT_FOUND);
+                cu_statusf(_BROKER, &s,
+                           CMPI_RC_ERR_NOT_FOUND,
+                           "Not found");
 
         *inst = _inst;
  out:
@@ -103,7 +105,9 @@ static CMPIStatus validate_service_get_c
 
                 s = get_migration_caps(ref, &_inst, _BROKER);
         } else
-                CMSetStatus(&s, CMPI_RC_ERR_NOT_FOUND);
+                cu_statusf(_BROKER, &s,
+                           CMPI_RC_ERR_NOT_FOUND,
+                           "");
 
         *inst = _inst;
 
diff -r ae2cfc5a6a85 -r 72f9d41f72aa src/Virt_HostedDependency.c
--- a/src/Virt_HostedDependency.c	Wed Feb 13 08:16:37 2008 -0800
+++ b/src/Virt_HostedDependency.c	Fri Feb 15 07:13:50 2008 -0800
@@ -70,14 +70,18 @@ static CMPIStatus host_to_vs(const CMPIO
 
         ret = enum_domains(_BROKER, conn, NAMESPACE(ref), list);
         if (ret) {
-                CMSetStatus(&s, CMPI_RC_OK);
+                cu_statusf(_BROKER, &s,
+                           CMPI_RC_OK,
+                           "");
         } else {
                 cu_statusf(_BROKER, &s,
                            CMPI_RC_ERR_FAILED,
                            "Failed to get domain list");
         }
 
-        CMSetStatus(&s, CMPI_RC_OK);
+        cu_statusf(_BROKER, &s,
+                   CMPI_RC_OK,
+                   "");
 
         return s;
 }
diff -r ae2cfc5a6a85 -r 72f9d41f72aa src/Virt_HostedResourcePool.c
--- a/src/Virt_HostedResourcePool.c	Wed Feb 13 08:16:37 2008 -0800
+++ b/src/Virt_HostedResourcePool.c	Fri Feb 15 07:13:50 2008 -0800
@@ -87,7 +87,9 @@ static CMPIStatus sys_to_pool(const CMPI
                                  NAMESPACE(ref),
                                  list);
 
-        CMSetStatus(&s, CMPI_RC_OK);
+        cu_statusf(_BROKER, &s,
+                   CMPI_RC_OK,
+                   "");
 
         return s;
 }
diff -r ae2cfc5a6a85 -r 72f9d41f72aa src/Virt_RegisteredProfile.c
--- a/src/Virt_RegisteredProfile.c	Wed Feb 13 08:16:37 2008 -0800
+++ b/src/Virt_RegisteredProfile.c	Fri Feb 15 07:13:50 2008 -0800
@@ -162,7 +162,9 @@ static CMPIStatus get_prof(const CMPIObj
         if(instance)
                 CMReturnInstance(results, instance);
         else
-                CMSetStatus(&s, CMPI_RC_ERR_NOT_FOUND);
+                cu_statusf(_BROKER, &s,
+                           CMPI_RC_ERR_NOT_FOUND,
+                           "Profile instance not found");
  out:
         virConnectClose(conn);
 
diff -r ae2cfc5a6a85 -r 72f9d41f72aa src/Virt_ResourceAllocationFromPool.c
--- a/src/Virt_ResourceAllocationFromPool.c	Wed Feb 13 08:16:37 2008 -0800
+++ b/src/Virt_ResourceAllocationFromPool.c	Fri Feb 15 07:13:50 2008 -0800
@@ -112,7 +112,9 @@ static CMPIStatus rasd_to_pool(const CMP
                               NAMESPACE(ref));
         if (pool != NULL) {
                 inst_list_add(list, pool);
-                CMSetStatus(&s, CMPI_RC_OK);
+                cu_statusf(_BROKER, &s,
+                           CMPI_RC_OK,
+                           "");
         } else {
                 cu_statusf(_BROKER, &s,
                            CMPI_RC_ERR_FAILED,
@@ -237,8 +239,9 @@ static CMPIStatus pool_to_rasd(const CMP
                         poolid,
                         list);
 
-        CMSetStatus(&s, CMPI_RC_OK);
-
+        cu_statusf(_BROKER, &s,
+                   CMPI_RC_OK,
+                   "");
  out:
         return s;
 }
diff -r ae2cfc5a6a85 -r 72f9d41f72aa src/Virt_SettingsDefineState.c
--- a/src/Virt_SettingsDefineState.c	Wed Feb 13 08:16:37 2008 -0800
+++ b/src/Virt_SettingsDefineState.c	Fri Feb 15 07:13:50 2008 -0800
@@ -104,8 +104,9 @@ static CMPIStatus dev_to_rasd(const CMPI
         if (rasd != NULL)
                 inst_list_add(list, rasd);
 
-        CMSetStatus(&s, CMPI_RC_OK);
-
+        cu_statusf(_BROKER, &s,
+                   CMPI_RC_OK,
+                   "");
  out:
         free(name);
         free(devid);
@@ -184,8 +185,9 @@ static CMPIStatus rasd_to_dev(const CMPI
 
         inst_list_add(list, dev);
 
-        CMSetStatus(&s, CMPI_RC_OK);
-
+        cu_statusf(_BROKER, &s,
+                   CMPI_RC_OK,
+                   "");
  out:
         return s;
 }
@@ -226,8 +228,9 @@ static CMPIStatus vs_to_vssd(const CMPIO
         if (vssd != NULL)
                 inst_list_add(list, vssd);
 
-        CMSetStatus(&s, CMPI_RC_OK);
-
+        cu_statusf(_BROKER, &s,
+                   CMPI_RC_OK,
+                   "");
  out:
         virDomainFree(dom);
         virConnectClose(conn);
@@ -277,8 +280,9 @@ static CMPIStatus vssd_to_vs(const CMPIO
         if (cs != NULL)
                 inst_list_add(list, cs);
 
-        CMSetStatus(&s, CMPI_RC_OK);
-
+        cu_statusf(_BROKER, &s,
+                   CMPI_RC_OK,
+                   "");
  out:
         free(name);
         free(pfx);
diff -r ae2cfc5a6a85 -r 72f9d41f72aa src/Virt_SystemDevice.c
--- a/src/Virt_SystemDevice.c	Wed Feb 13 08:16:37 2008 -0800
+++ b/src/Virt_SystemDevice.c	Fri Feb 15 07:13:50 2008 -0800
@@ -157,7 +157,9 @@ static CMPIStatus sys_to_dev(const CMPIO
                               NAMESPACE(ref));
 
         if (ret >= 0) {
-                CMSetStatus(&s, CMPI_RC_OK);
+                cu_statusf(_BROKER, &s,
+                           CMPI_RC_OK,
+                           "");
         } else {
                 cu_statusf(_BROKER, &s,
                            CMPI_RC_ERR_FAILED,
@@ -208,7 +210,9 @@ static CMPIStatus dev_to_sys(const CMPIO
                            "Unable to find DeviceID `%s'", devid);
         else {
                 inst_list_add(list, sys);
-                CMSetStatus(&s, CMPI_RC_OK);
+                cu_statusf(_BROKER, &s,
+                           CMPI_RC_OK,
+                           "");
         }
 
  out:
diff -r ae2cfc5a6a85 -r 72f9d41f72aa src/Virt_VSMigrationCapabilities.c
--- a/src/Virt_VSMigrationCapabilities.c	Wed Feb 13 08:16:37 2008 -0800
+++ b/src/Virt_VSMigrationCapabilities.c	Fri Feb 15 07:13:50 2008 -0800
@@ -73,8 +73,9 @@ static CMPIStatus set_method_properties(
         CMSetProperty(inst, "SynchronousMethodsSupported",
                       (CMPIValue *)&array, CMPI_uint16A);
 
-        CMSetStatus(&s, CMPI_RC_OK);
-
+        cu_statusf(_BROKER, &s,
+                   CMPI_RC_OK,
+                   "");
         return s;
 }
 
diff -r ae2cfc5a6a85 -r 72f9d41f72aa src/Virt_VSMigrationService.c
--- a/src/Virt_VSMigrationService.c	Wed Feb 13 08:16:37 2008 -0800
+++ b/src/Virt_VSMigrationService.c	Fri Feb 15 07:13:50 2008 -0800
@@ -114,7 +114,9 @@ static CMPIStatus check_hver(virConnectP
 
         if (remote >= local) {
                 CU_DEBUG("Version check OK (%lu >= %lu)", remote, local);
-                CMSetStatus(&s, CMPI_RC_OK);
+                cu_statusf(_BROKER, &s,
+                           CMPI_RC_OK,
+                           "");
         } else {
                 CU_DEBUG("Version check FAILED (%lu < %lu)", remote, local);
                 cu_statusf(_BROKER, &s,
@@ -123,8 +125,9 @@ static CMPIStatus check_hver(virConnectP
                            remote, local);
         }
 
-        CMSetStatus(&s, CMPI_RC_OK);
-
+        cu_statusf(_BROKER, &s,
+                   CMPI_RC_OK,
+                   "");
  out:
         return s;
 }
@@ -172,8 +175,9 @@ static CMPIStatus vs_migratable(const CM
                 goto out;
 
         retcode = 0;
-        CMSetStatus(&s, CMPI_RC_OK);
-
+        cu_statusf(_BROKER, &s,
+                   CMPI_RC_OK,
+                   "");
  out:
         CMReturnData(results, (CMPIValue *)&retcode, CMPI_uint32);
 
@@ -432,8 +436,9 @@ static CMPIStatus migrate_vs(struct migr
         }
 
         CU_DEBUG("Migration succeeded");
-        CMSetStatus(&s, CMPI_RC_OK);
-
+        cu_statusf(_BROKER, &s,
+                   CMPI_RC_OK,
+                   "");
  out:
         free(uri);
         virDomainFree(dom);
@@ -788,8 +793,10 @@ CMPIStatus get_migration_service(const C
         CMSetProperty(inst, "SystemCreationClassName",
                       (CMPIValue *)ccname, CMPI_chars);
 
-        CMSetStatus(&s, CMPI_RC_OK);
- 
+        cu_statusf(_BROKER, &s,
+                   CMPI_RC_OK,
+                   "");
+
         *_inst = inst;
 
  out:
diff -r ae2cfc5a6a85 -r 72f9d41f72aa src/Virt_VSMigrationSettingData.c
--- a/src/Virt_VSMigrationSettingData.c	Wed Feb 13 08:16:37 2008 -0800
+++ b/src/Virt_VSMigrationSettingData.c	Fri Feb 15 07:13:50 2008 -0800
@@ -47,7 +47,9 @@ static CMPIStatus set_properties(const C
                       (CMPIValue *)&priority, CMPI_uint16);
 
 
-        CMSetStatus(&s, CMPI_RC_OK);
+        cu_statusf(broker, &s,
+                   CMPI_RC_OK,
+                   "");
 
         return s;
 }
diff -r ae2cfc5a6a85 -r 72f9d41f72aa src/Virt_VSSD.c
--- a/src/Virt_VSSD.c	Wed Feb 13 08:16:37 2008 -0800
+++ b/src/Virt_VSSD.c	Fri Feb 15 07:13:50 2008 -0800
@@ -182,7 +182,9 @@ static CMPIStatus enum_vssd(const CMPIOb
                            "Failed to enumerate domains");
                 goto out;
         } else if (count == 0) {
-                CMSetStatus(&s, CMPI_RC_OK);
+                cu_statusf(_BROKER, &s,
+                           CMPI_RC_OK,
+                           "");
                 goto out;
         }
 
@@ -200,7 +202,9 @@ static CMPIStatus enum_vssd(const CMPIOb
                         CMReturnInstance(results, inst);
         }
 
-        CMSetStatus(&s, CMPI_RC_OK);
+        cu_statusf(_BROKER, &s,
+                   CMPI_RC_OK,
+                   "");
  out:
         free(list);
 
@@ -271,7 +275,9 @@ static CMPIStatus GetInstance(CMPIInstan
         if (inst)
                 CMReturnInstance(results, inst);
 
-        CMSetStatus(&s, CMPI_RC_OK);
+        cu_statusf(_BROKER, &s,
+                   CMPI_RC_OK,
+                   "");
 
         free(locid);
 
diff -r ae2cfc5a6a85 -r 72f9d41f72aa src/Virt_VSSDComponent.c
--- a/src/Virt_VSSDComponent.c	Wed Feb 13 08:16:37 2008 -0800
+++ b/src/Virt_VSSDComponent.c	Fri Feb 15 07:13:50 2008 -0800
@@ -69,8 +69,9 @@ static CMPIStatus vssd_to_rasd(const CMP
                                  list);
         }
 
-        CMSetStatus(&s, CMPI_RC_OK);
-
+        cu_statusf(_BROKER, &s,
+                   CMPI_RC_OK,
+                   "");
  out:
         free(name);
 
@@ -103,8 +104,9 @@ static CMPIStatus vssd_for_name(const ch
                            CMPI_RC_ERR_FAILED,
                            "Error getting VSSD for `%s'", host);
         else
-                CMSetStatus(&s, CMPI_RC_OK);
-
+                cu_statusf(_BROKER, &s,
+                           CMPI_RC_OK,
+                           "");
  out:
         virDomainFree(dom);
         virConnectClose(conn);
diff -r ae2cfc5a6a85 -r 72f9d41f72aa src/Virt_VirtualSystemManagementService.c
--- a/src/Virt_VirtualSystemManagementService.c	Wed Feb 13 08:16:37 2008 -0800
+++ b/src/Virt_VirtualSystemManagementService.c	Fri Feb 15 07:13:50 2008 -0800
@@ -75,8 +75,9 @@ static CMPIStatus define_system_parse_ar
                 goto out;
         }
 
-        CMSetStatus(&s, CMPI_RC_OK);
-
+        cu_statusf(_BROKER, &s,
+                   CMPI_RC_OK,
+                   "");
  out:
         return s;
 }
@@ -373,7 +374,9 @@ static CMPIInstance *create_system(CMPII
 
         domain = calloc(1, sizeof(*domain));
         if (domain == NULL) {
-                CMSetStatus(s, CMPI_RC_ERR_FAILED);
+                cu_statusf(_BROKER, s,
+                           CMPI_RC_ERR_FAILED,
+                           "Failed to allocate memory");
                 goto out;
         }
 
@@ -492,7 +495,9 @@ static CMPIStatus destroy_system(CMPIMet
                         rc.uint32 = IM_RC_OK;
                 } else {
                         rc.uint32 = IM_RC_FAILED;
-                        CMSetStatus(&status, CMPI_RC_ERR_FAILED);
+                        cu_statusf(_BROKER, &status,
+                                   CMPI_RC_ERR_FAILED,
+                                   "Domain already exists");
                 }
                 virDomainFree(dom);
                 trigger_indication(context,
@@ -665,7 +670,9 @@ static CMPIStatus _resource_dynamic(stru
         if (!domain_online(dom)) {
                 CU_DEBUG("VS `%s' not online; skipping dynamic update",
                          dominfo->name);
-                CMSetStatus(&s, CMPI_RC_OK);
+                cu_statusf(_BROKER, &s,
+                           CMPI_RC_OK,
+                           "");
                 goto out;
         }
 
@@ -676,7 +683,9 @@ static CMPIStatus _resource_dynamic(stru
                            CMPI_RC_ERR_FAILED,
                            "Unable to change (%i) device", action);
         } else {
-                CMSetStatus(&s, CMPI_RC_OK);
+                cu_statusf(_BROKER, &s,
+                           CMPI_RC_OK,
+                           "");
         }
  out:
         virDomainFree(dom);
@@ -769,7 +778,9 @@ static CMPIStatus resource_add(struct do
         list = realloc(*_list, ((*count)+1)*sizeof(struct virt_device));
         if (list == NULL) {
                 /* No memory */
-                CMSetStatus(&s, CMPI_RC_ERR_FAILED);
+                cu_statusf(_BROKER, &s,
+                           CMPI_RC_ERR_FAILED,
+                           "Failed to allocate memory");
                 goto out;
         }
 
@@ -786,7 +797,9 @@ static CMPIStatus resource_add(struct do
         if (s.rc != CMPI_RC_OK)
                 goto out;
 
-        CMSetStatus(&s, CMPI_RC_OK);
+        cu_statusf(_BROKER, &s,
+                   CMPI_RC_OK,
+                   "");
         (*count)++;
 
  out:
@@ -1038,7 +1051,9 @@ static CMPIStatus rasd_refs_to_insts(con
                                  REF2STR(ref));
         }
 
-        CMSetStatus(&s, CMPI_RC_OK);
+        cu_statusf(_BROKER, &s,
+                   CMPI_RC_OK,
+                   "");
         *ret_arr = tmp_arr;
 
         return s;
@@ -1220,8 +1235,9 @@ CMPIStatus get_vsms(const CMPIObjectPath
                         goto out;
         }
 
-        CMSetStatus(&s, CMPI_RC_OK);
-
+        cu_statusf(_BROKER, &s,
+                   CMPI_RC_OK,
+                   "");
  out:
         virConnectClose(conn);
         *_inst = inst;




More information about the Libvirt-cim mailing list