[Libvirt-cim] [PATCH] [CU] Add support to read/write array of strings to properties which expect them

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Wed Jun 3 15:31:09 UTC 2009


> diff -r 1cb3975921d5 -r 639fb266e1e6 eo_parser.c
> --- a/eo_parser.c	Mon Apr 27 16:11:32 2009 -0700
> +++ b/eo_parser.c	Tue Jun 02 10:55:14 2009 -0300
> @@ -169,6 +169,29 @@
>          return CMPI_sint8;
>  }
> 
> +inline CMPIStatus ins_chars_into_cmstr_arr(const CMPIBroker *broker,
> +                                           CMPIArray *arr,
> +                                           CMPICount index,
> +                                           char *str)

No need to make this inline.

> +{
> +        CMPIString *cm_str;
> +        CMPIStatus s = {CMPI_RC_OK, NULL};
> +        
> +        cm_str = CMNewString(broker, str, &s);
> +        if (s.rc != CMPI_RC_OK || CMIsNullObject(cm_str)) {
> +                CU_DEBUG("Error creating CMPIString");
> +                goto out;
> +        }
> +
> +        s = CMSetArrayElementAt(arr, index, &cm_str, CMPI_string);
> +        if (s.rc != CMPI_RC_OK)
> +                CU_DEBUG("Error setting array element %u\n"
> +                         "Error code: %d", index, s.rc);
> +
> + out:
> +        return s;
> +}
> +
>  /*
>   * Local Variables:
>   * mode: C
> diff -r 1cb3975921d5 -r 639fb266e1e6 eo_parser_xml.h
> --- a/eo_parser_xml.h	Mon Apr 27 16:11:32 2009 -0700
> +++ b/eo_parser_xml.h	Tue Jun 02 10:55:14 2009 -0300
> @@ -31,6 +31,11 @@
>                        char *prop,
>                        CMPIInstance *inst);
> 
> +inline CMPIStatus ins_chars_into_cmstr_arr(const CMPIBroker *broker,
> +                                           CMPIArray *arr,
> +                                           CMPICount index,
> +                                           char *str);

Same here - you can remove the inline.


>  	/* NOTE - this rule only applies after a 'INSTANCE OF' has been read in */
>  <READCLASSNAME>[A-Za-z][A-Za-z0-9_]* {
>  	BEGIN INITIAL; /* Go back to normal parsing rules now */
> diff -r 1cb3975921d5 -r 639fb266e1e6 eo_util_parser.y


> +                        
> +                       str_arr_out:
> +                        free(stringarraypropname);
> +                        for (i = 0; i < stringarraysize - 1; i++)
> +                                free(stringarray[i]);
> +                        free($1);
> +
> +                        if (s.rc != CMPI_RC_OK) {
> +                                return RC_INVALID_CLASS; 

I would return s.c instead of RC_INVALID_CLASS, because the issue here 
isn't an invalid class.  The issue is in parsing the attribute's array 
value.

Really, the eo_parse_parseinstance() should take a CMPIStatus variable 
(or we should return one somehow) so that we can set the error code and 
error message properly.  But that's something to fix later on.

> +                        }
> +                         
> +                        }
> +        ;



-- 
Kaitlin Rupert
IBM Linux Technology Center
kaitlin at linux.vnet.ibm.com




More information about the Libvirt-cim mailing list