Konkret array counts

Roman Rakus rrakus at redhat.com
Wed Feb 6 08:32:17 UTC 2013


On 02/06/2013 04:17 AM, John Dennis wrote:
> On 02/05/2013 05:34 PM, Roman Rakus wrote:
>> On 02/05/2013 10:42 PM, John Dennis wrote:
>>> Oddly there doesn't seem to be an interface (API) in Konkret to get
>>> the size of an array. This seems like a very odd omission.
>>>
>>> For instance, lets say you define a method that has an IN parameter
>>> which is an array of strings, for example sake let's call this array
>>> "Names", your Konkret generated method will have a parameter like this:
>>>
>>> const KStringA *Names
>>>
>>> To do anything with the Names array you have to know how many elements
>>> it has, this proved difficult to figure out.
>>>
>>> The definition of KStringA looks like this:
>>>
>>> typedef struct _KStringA
>>> {
>>>      CMPIUint32 exists;
>>>      CMPIUint32 null;
>>>      const CMPIArray* value;
>>>      char __padding1[16 - sizeof(CMPIArray*)];
>>>      CMPIUint32 count;
>>>      char __padding2[4];
>>> }
>>> KStringA;
>>>
>>> Notice it has a count member. If you were thinking there is an
>>> accessor defined as an inline or macro for the count you'd be wrong.
>>> If you were thinking you could access Names->count and get a valid
>>> value you would be wrong. Apparently it's never initialized.
>>>
>>> I verified that when my method is invoked via YAWN it's passing an
>>> array of strings, I can see it in the generated XML. I also called the
>>> XXX_Args_Print() function that Konkret generated. It also shows the
>>> expected array elements. I also called KStringA_Get(Names, 0) to
>>> retrieve the first element, and lo and behold got the first element.
>>>
>>> But nowhere can I find how many elements are in this array nor a way
>>> to iterate it.
>>>
>>> Apparently there is nothing in Konkret to give you this critical
>>> information. I resorted to calling CMPI directly (which seems like an
>>> API violation) by doing this:
>>>
>>> count = CMGetArrayCount(OptionNames->value, NULL);
>>>
>>> which works.
>>>
>>> But this seems wrong, I shouldn't be reaching in to CMPI data
>>> structures that Konkret is supposed to be hiding from me, *plus*
>>> what's the point of the count member of the KStringA struct? BTW all
>>> KArray types have a count field, by looking at the source code it
>>> appears none of the count fields are initialized, unless you create
>>> the array yourself via of of the K*A_Init() functions which calls
>>> KArray_Init().
>>>
>>> Also, there doesn't seem to be any doc whatsoever in Konkret for
>>> working with arrays. That also seems odd. Are arrays a second thought
>>> in Konkret?
>>>
>>> Comments? Am I missing something?
>>>
>>> John
>>>
>>>
>> It's a known bug: https://bugzilla.redhat.com/show_bug.cgi?id=848480
>
>
> Thank you. Was this bug submitted upstream?
Upstream is now run by Radek Novacek at 
https://github.com/rnovacek/konkretcmpi
>
>> Patches are welcome :)
>
> If I have time I will, but in the interim I'm planning on a workaround
> using either an inline function or a macro. It might be good if we could
> standardize on the workaround so that whenever there is a fundamental
> fix it will be easy to update the code.
Also he already fix it, see bugzilla.

RR


More information about the openlmi-devel mailing list