Re: Bug in kernel-doc ("-" misinterpretation)

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

 



Hi Vegard,

On 12/19/24 11:10 PM, Vegard Nossum wrote:
> 
> On 20/12/2024 06:02, Randy Dunlap wrote:
>> On 12/19/24 10:37 AM, John Ousterhout wrote:
>>> kernel-doc gets confused by code like the following:
>>>
>>> /**
>>>   * define HOMA_MIN_DEFAULT_PORT - The 16-bit port space is divided into
>>>   * two nonoverlapping regions. Ports 1-32767 are reserved exclusively
>>>   * for well-defined server ports. The remaining ports are used for client
>>>   * ports; these are allocated automatically by Homa. Port 0 is reserved.
>>>   */
>>> #define HOMA_MIN_DEFAULT_PORT 0x8000
>>>
>>> It seems to use the last "-" on the line (the one in "16-bit") rather
>>> than the first one, so it produces the following false error message:
>>>
>>> homa.h:50: warning: expecting prototype for HOMA_MIN_DEFAULT_PORT -
>>> The 16(). Prototype was for HOMA_MIN_DEFAULT_PORT() instead
>>>
>>> There are similar problems if there is a ":" later on the line.
>>
>>
>> @Vegard, can you look at this, please?
>> I have already looked but didn't arrive at a solution.
>>
>>
>> It appears to be these lines in process_name() that are confusing the function name
>> and following description:
>>
>>          # Look for foo() or static void foo() - description; or misspelt
>>          # identifier
>>          elsif (/^$decl_start$fn_type?(\w+)\s*$parenthesis?\s*$decl_end?$/ ||
>>              /^$decl_start$fn_type?(\w+.*)$parenthesis?\s*$decl_end$/) {
>>              $identifier = $1;
>>
>> Thanks.
> 
> Hi,
> 
> Is it just a matter of making that capture group less greedy?

Yes, should be.

> diff --git a/scripts/kernel-doc b/scripts/kernel-doc
> index f66070176ba31..ba9bc8760ff82 100755
> --- a/scripts/kernel-doc
> +++ b/scripts/kernel-doc
> @@ -2085,7 +2085,7 @@ sub process_name($$) {
>          # Look for foo() or static void foo() - description; or misspelt
>          # identifier
>          elsif (/^$decl_start$fn_type?(\w+)\s*$parenthesis?\s*$decl_end?$/ ||
> -            /^$decl_start$fn_type?(\w+.*)$parenthesis?\s*$decl_end$/) {
> +            /^$decl_start$fn_type?(\w+.*?)$parenthesis?\s*$decl_end$/) {
>              $identifier = $1;
>              $decl_type = 'function';
>              $identifier =~ s/^define\s+//;
> 
> We could also use [^-:]* instead of .* I guess.

Yes, either (both) of those works.
I slightly prefer the alternative since it is stronger in some way (IMO).

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