[PATCH] identify_ppc_sys_by_name_and_id function implementation final

Vitaly Bordug vbordug at ru.mvista.com
Tue Aug 16 23:36:37 EST 2005


Kumar Gala wrote:
> On Aug 12, 2005, at 11:30 AM, Vitaly Bordug wrote:
> 
>> Kumar Gala wrote:
>>
>>> Can you do a sizeof instead?
>>>
>>> #define num_ele sizeof(ppc_sys_specs[])/sizeof(struct ppc_sys_spec)
>>>
>>> Something like matchted[num_ele] ??
>>>
>>>
>>
>> That's what the first I tried actually :)
>> gcc is not happy with it:
>>
>> arch/ppc/syslib/ppc_sys.c: In function `find_chip_by_name_and_id':
>> arch/ppc/syslib/ppc_sys.c:54: error: parse error before ']' token
>>
>> and if I remove [] from the ppc_sys_specs, it outputs:
>>
>> arch/ppc/syslib/ppc_sys.c: In function `find_chip_by_name_and_id':
>> arch/ppc/syslib/ppc_sys.c:54: error: invalid application of  `sizeof' to
>> incomplete type `({anonymous})'
>>
>> So I cannot use sizeof this case, I think...
> 
> 
> Realized the same thing.  I'm thinking that your original method is  the 
> best solution to just do this on the stack.  In general the  number or 
> processors (array size) is going to be less than 100.  So  at most this 
> array is going to end up being 100 bytes on the stack.   I dont think 
> that's a big deal at the point we are calling this
> 
Thus, are there any modifications needed for the original approach?
Or maybe it's simpler to add say MAX_PPC_SPECS to ppc_sys.h since this 
list will be limited anyway? We could have the simple array with static 
size then, and additional ppc_sys_specs sanity check (whether it has 
"default" element with both 0 id and "" name) could be easily 
implemented as well.


-- 
Sincerely,
Vitaly



More information about the Linuxppc-embedded mailing list