Re: [RFC 1/1] kernel-doc: Support arrays of pointers struct fields

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 1/27/24 14:41, Sakari Ailus wrote:
> Hi Randy,
> 
> On Sat, Jan 27, 2024 at 01:01:01PM -0800, Randy Dunlap wrote:
>> Hi Sakari,
>>
>> On 1/27/24 10:53, Sakari Ailus wrote:
>>> In a rather unusual arrangement in include/media/v4l2-vp9.h struct
>>> v4l2_vp9_frame_symbol_counts has fields that are arrays of pointers, not a
>>> pointer to an array, which is what's usually done.
>>>
>>
>> Yet another kernel-doc bug. I have a list of 5 or 6 or 8 bugs that are
>> similar to this one, but I didn't have this one.
> 
> :-)
> 
> Regular expressions are not best for parsing C. It seems to be doable in
> practice but imperfect at the same time.
> 
>>
>>
>>> Add support for such arrays of pointers to kernel-doc.
>>>
>>> Signed-off-by: Sakari Ailus <sakari.ailus@xxxxxxxxxxxxxxx>
>>
>>
>> Did this work for you?
>> I still see the same warnings as before this patch is applied.
> 
> Hmm. How did you test this? I did:
> 
> 	$ scripts/kernel-doc include/media/v4l2-vp9.h > /dev/null
> 
> Without this patch I do get a bunch of errors, with this patch there's no
> output. The produced kernel-doc seemed to be fine, too (with the
> redirection removed).
> 

I apologize. I wasn't being careful, just rushing too much.
It works well. Thanks.

Acked-by: Randy Dunlap <rdunlap@xxxxxxxxxxxxx>
Tested-by: Randy Dunlap <rdunlap@xxxxxxxxxxxxx>

>>
>>
>>> ---
>>> Hi Ricardo,
>>>
>>> I tried to ram it together with processing the rest but it seemed
>>> to complicate processing the usual fields.
>>>
>>>  scripts/kernel-doc | 9 +++++++++
>>>  1 file changed, 9 insertions(+)
>>>
>>> diff --git a/scripts/kernel-doc b/scripts/kernel-doc
>>> index e8aefd258a29..728b1ffc0478 100755
>>> --- a/scripts/kernel-doc
>>> +++ b/scripts/kernel-doc
>>> @@ -1509,6 +1509,15 @@ sub create_parameterlist($$$$) {
>>>  	    $type =~ s/([^\(]+\(\*?)\s*$param/$1/;
>>>  	    save_struct_actual($param);
>>>  	    push_parameter($param, $type, $arg, $file, $declaration_name);
>>> +	} elsif ($arg =~ m/\(.+\)\s*\[/) {
>>> +	    # array-of-pointers
>>> +	    $arg =~ tr/#/,/;
>>> +	    $arg =~ m/[^\(]+\(\s*\*\s*([\w\[\]\.]*?)\s*(\s*\[\s*[\w]+\s*\]\s*)*\)/;
>>> +	    $param = $1;
>>> +	    $type = $arg;
>>> +	    $type =~ s/([^\(]+\(\*?)\s*$param/$1/;
>>> +	    save_struct_actual($param);
>>> +	    push_parameter($param, $type, $arg, $file, $declaration_name);
>>>  	} elsif ($arg) {
>>>  	    $arg =~ s/\s*:\s*/:/g;
>>>  	    $arg =~ s/\s*\[/\[/g;
>>
>>
>> Thanks.
> 

-- 
#Randy




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux