[Libvirt-cim] [PATCH 1 of 2] Remove static from get_rasd_instance()

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Wed Nov 21 15:31:43 UTC 2007


# HG changeset patch
# User Kaitlin Rupert <karupert at us.ibm.com>
# Date 1195662213 28800
# Node ID ad925c6e9bf0635e79c2b6e45698d11ede760d99
# Parent  5c0b219865cd675d54d4a13230c549be93a4d144
Remove static from get_rasd_instance()

Add get_rasd_instance() declaration to header file.  Also add an additional broker argument so other providers can call this function.

Fixed minor mem leak in GetInstance().

Signed-off-by: Kaitlin Rupert <karupert at us.ibm.com>

diff -r 5c0b219865cd -r ad925c6e9bf0 src/Virt_RASD.c
--- a/src/Virt_RASD.c	Wed Nov 21 08:17:31 2007 -0800
+++ b/src/Virt_RASD.c	Wed Nov 21 08:23:33 2007 -0800
@@ -177,10 +177,11 @@ static CMPIInstance *rasd_from_vdev(cons
         return inst;
 }
 
-static CMPIInstance *get_rasd_instance(const CMPIContext *context,
-                                       const CMPIObjectPath *ref,
-                                       const char *id,
-                                       const uint16_t type)
+CMPIInstance *get_rasd_instance(const CMPIContext *context,
+                                const CMPIObjectPath *ref,
+                                const CMPIBroker *broker,
+                                const char *id,
+                                const uint16_t type)
 {
         CMPIInstance *inst = NULL;
         CMPIStatus s;
@@ -194,13 +195,13 @@ static CMPIInstance *get_rasd_instance(c
         if (!ret)
                 return NULL;
 
-        conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s);
+        conn = connect_by_classname(broker, CLASSNAME(ref), &s);
         if (conn == NULL)
                 goto out;
 
         dev = find_dev(conn, type, host, devid);
         if (dev)
-                inst = rasd_from_vdev(_BROKER, dev, host, ref);
+                inst = rasd_from_vdev(broker, dev, host, ref);
 
  out:
         virConnectClose(conn);
@@ -264,7 +265,7 @@ static CMPIStatus GetInstance(CMPIInstan
                 goto out;
         }
 
-        inst = get_rasd_instance(context, ref, id, type);
+        inst = get_rasd_instance(context, ref, _BROKER, id, type);
 
         if (inst != NULL)
                 CMReturnInstance(results, inst);
@@ -273,6 +274,8 @@ static CMPIStatus GetInstance(CMPIInstan
                            CMPI_RC_ERR_FAILED,
                            "Unknown instance");
  out:
+        free(id);
+
         return s;
 }
 
diff -r 5c0b219865cd -r ad925c6e9bf0 src/Virt_RASD.h
--- a/src/Virt_RASD.h	Wed Nov 21 08:17:31 2007 -0800
+++ b/src/Virt_RASD.h	Wed Nov 21 08:23:33 2007 -0800
@@ -41,6 +41,12 @@ int rasds_for_domain(const CMPIBroker *b
 
 CMPIrc rasd_type_from_classname(const char *cn, uint16_t *type);
 
+CMPIInstance *get_rasd_instance(const CMPIContext *context,
+                                const CMPIObjectPath *ref,
+                                const CMPIBroker *broker,
+                                       const char *id,
+                                       const uint16_t type);
+
 #endif
 
 /*




More information about the Libvirt-cim mailing list