Skip to content

Commit da3ecf0

Browse files
vegardJonathan Corbet
authored andcommitted
scripts/kernel-doc: fix identifier parsing regex
John 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. The problem is the regex for the identifier, which is a greedy /.*/ that matches everything up to the last - or : (i.e. $decl_end). Fix it by tightening up this regex and not matching those characters as part of the identifier. Link: https://lore.kernel.org/all/CAGXJAmzfRzE=A94NT5ETtj3bZc-=2oLg-9E5Kjh4o_-iuw1q8g@mail.gmail.com/ Reported-by: John Ousterhout <[email protected]> Reviewed-by: Randy Dunlap <[email protected]> Tested-by: Randy Dunlap <[email protected]> Signed-off-by: Vegard Nossum <[email protected]> Signed-off-by: Jonathan Corbet <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent d5af79c commit da3ecf0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

scripts/kernel-doc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2085,7 +2085,7 @@ sub process_name($$) {
20852085
# Look for foo() or static void foo() - description; or misspelt
20862086
# identifier
20872087
elsif (/^$decl_start$fn_type?(\w+)\s*$parenthesis?\s*$decl_end?$/ ||
2088-
/^$decl_start$fn_type?(\w+.*)$parenthesis?\s*$decl_end$/) {
2088+
/^$decl_start$fn_type?(\w+[^-:]*)$parenthesis?\s*$decl_end$/) {
20892089
$identifier = $1;
20902090
$decl_type = 'function';
20912091
$identifier =~ s/^define\s+//;

0 commit comments

Comments
 (0)