[Libvirt-cim] [PATCH 2 of 2] [CU] Add parse_inst_arg() to validate_args() call in std_invokemethod

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Tue Jan 29 19:58:40 UTC 2008


# HG changeset patch
# User Kaitlin Rupert <karupert at us.ibm.com>
# Date 1201635824 28800
# Node ID f21b78b847919e032a7c1bbc33958c242d9b30c5
# Parent  fbf396e9c8c2328b646c1d7e6b85fb73d50eac93
[CU] Add parse_inst_arg() to validate_args() call in std_invokemethod.

Updates from set 2 to set 3:
   -Fixed pointer silliness - changed CMPIArgs param in validate_arg_type() to a single pointer.

Updates from set 1 to set 2:
   -check_for_eo() return type changed from int to CMPIType

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

diff -r fbf396e9c8c2 -r f21b78b84791 std_invokemethod.c
--- a/std_invokemethod.c	Tue Jan 29 11:43:42 2008 -0800
+++ b/std_invokemethod.c	Tue Jan 29 11:43:44 2008 -0800
@@ -170,9 +170,14 @@ static int parse_eo_param(CMPIArgs *args
 
 static int validate_arg_type(struct method_arg *arg, 
                              const CMPIArgs *args,
+                             const CMPIBroker *broker, 
+                             const char *ns,
+                             CMPIArgs *new_args,
                              CMPIStatus *s)
 {
         CMPIData argdata;
+        CMPIType type;
+        int ret;
 
         argdata = CMGetArg(args, arg->name, s);
         if ((s->rc != CMPI_RC_OK) || (CMIsNullValue(argdata))) {
@@ -183,10 +188,34 @@ static int validate_arg_type(struct meth
         }
 
         if (argdata.type != arg->type) {
-                CMSetStatus(s, CMPI_RC_ERR_TYPE_MISMATCH);
-                CU_DEBUG("Method parameter `%s' type check failed",
-                         arg->name);
-                return 0;
+                type = check_for_eo(argdata.type, arg->type);
+                if (type != CMPI_null) {
+                        ret = parse_eo_param(new_args,
+                                             argdata,
+                                             type,
+                                             arg->name,
+                                             broker,
+                                             ns,
+                                             s);
+
+                        if (ret != 1)
+                                return 0;
+                } else {
+                        CMSetStatus(s, CMPI_RC_ERR_TYPE_MISMATCH);
+                        CU_DEBUG("Method parameter `%s' type check failed",
+                                 arg->name);
+                        return 0;
+                }
+        } else {
+                *s = CMAddArg(new_args,
+                              arg->name,
+                              &(argdata.value),
+                              argdata.type);
+
+                if (s->rc != CMPI_RC_OK) {
+                        CU_DEBUG("Unable to update method argument");
+                        return 0;
+                }
         }
 
         CU_DEBUG("Method parameter `%s' validated type 0x%x",
@@ -197,19 +226,31 @@ static int validate_arg_type(struct meth
 }
 
 static int validate_args(struct method_handler *h, 
-                         const CMPIArgs *args,
+                         const CMPIArgs **args,
+                         const CMPIObjectPath *ref,
+                         const CMPIBroker *broker,
                          CMPIStatus *s)
 {
+        CMPIArgs *new_args;
         int i;
+
+        new_args = CMNewArgs(broker, s);
 
         for (i = 0; h->args[i].name; i++) {
                 int ret;
                 struct method_arg *arg = &h->args[i];
 
-                ret = validate_arg_type(arg, args, s);
+                ret = validate_arg_type(arg, 
+                                        *args, 
+                                        broker, 
+                                        NAMESPACE(ref), 
+                                        new_args,
+                                        s);
                 if (!ret)
                         return 0;
         }
+
+        *args = new_args;
 
         return 1;
 }
@@ -244,7 +285,11 @@ CMPIStatus _std_invokemethod(CMPIMethodM
                 goto exit;
         }
 
-        ret = validate_args(h, argsin, &s);
+        ret = validate_args(h, 
+                            &argsin, 
+                            reference,
+                            ctx->broker, 
+                            &s);
         if (!ret)
                 goto exit;
 




More information about the Libvirt-cim mailing list