# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1201621355 28800
# Node ID d49ff2c6fd5f4a8826d564aaf9ade4912fbab95c
# Parent 0375f0b616f44cba8705b667a658663e891cb068
[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(a)us.ibm.com>
diff -r 0375f0b616f4 -r d49ff2c6fd5f std_invokemethod.c
--- a/std_invokemethod.c Tue Jan 29 07:41:20 2008 -0800
+++ b/std_invokemethod.c Tue Jan 29 07:42:35 2008 -0800
@@ -173,9 +173,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))) {
@@ -186,10 +191,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",
@@ -200,19 +229,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;
}
@@ -247,7 +288,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;