# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1202773946 28800
# Node ID b36fabb5b94524b5252cb8ed355d54f648a219fa
# Parent cc846858f60cb7ce5b859015c9a120d784074eed
[CU] Add support for optional method arguments.
If no argument is supplied for a given parameter, skip any additional argument
validation.
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r cc846858f60c -r b36fabb5b945 std_invokemethod.c
--- a/std_invokemethod.c Wed Feb 06 08:27:12 2008 -0800
+++ b/std_invokemethod.c Mon Feb 11 15:52:26 2008 -0800
@@ -184,7 +184,8 @@ static int validate_arg_type(struct meth
int ret;
argdata = CMGetArg(args, arg->name, s);
- if ((s->rc != CMPI_RC_OK) || (CMIsNullValue(argdata))) {
+ if (((s->rc != CMPI_RC_OK) || (CMIsNullValue(argdata)))
+ && !arg->optional) {
CMSetStatus(s, CMPI_RC_ERR_INVALID_PARAMETER);
CU_DEBUG("Method parameter `%s' missing",
arg->name);
@@ -204,12 +205,14 @@ static int validate_arg_type(struct meth
if (ret != 1)
return 0;
- } else {
+ } else if (!arg->optional) {
CMSetStatus(s, CMPI_RC_ERR_TYPE_MISMATCH);
CU_DEBUG("Method parameter `%s' type check
failed",
arg->name);
return 0;
- }
+ } else
+ CU_DEBUG("No optional parameter supplied for
`%s'",
+ arg->name);
} else {
*s = CMAddArg(new_args,
arg->name,
diff -r cc846858f60c -r b36fabb5b945 std_invokemethod.h
--- a/std_invokemethod.h Wed Feb 06 08:27:12 2008 -0800
+++ b/std_invokemethod.h Mon Feb 11 15:52:26 2008 -0800
@@ -45,6 +45,7 @@ struct method_arg {
struct method_arg {
char *name;
CMPIType type;
+ bool optional;
};
struct method_handler {
Show replies by thread