Commit cf419d54 authored by Randy Dunlap's avatar Randy Dunlap Committed by Jonathan Corbet

kernel-doc: fix declaration type determination

Make declaration type determination more robust.

When scripts/kernel-doc is deciding if some kernel-doc notation
contains an enum, a struct, a union, a typedef, or a function,
it does a pattern match on the beginning of the string, looking
for a match with one of "struct", "union", "enum", or "typedef",
and otherwise defaults to a function declaration type.
However, if a function or a function-like macro has a name that
begins with "struct" (e.g., struct_size()), then kernel-doc
incorrectly decides that this is a struct declaration.

Fix this by looking for the declaration type keywords having an
ending word boundary (\b), so that "struct_size" will not match
a struct declaration.

I compared lots of html before/after output from core-api, driver-api,
and networking.  There were no differences in any of the files that
I checked.
Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
Acked-by: default avatarJani Nikula <jani.nikula@intel.com>
Tested-by: default avatarKees Cook <keescook@chromium.org>
Signed-off-by: default avatarJonathan Corbet <corbet@lwn.net>
parent 418ca3de
...@@ -1904,13 +1904,13 @@ sub process_name($$) { ...@@ -1904,13 +1904,13 @@ sub process_name($$) {
++$warnings; ++$warnings;
} }
if ($identifier =~ m/^struct/) { if ($identifier =~ m/^struct\b/) {
$decl_type = 'struct'; $decl_type = 'struct';
} elsif ($identifier =~ m/^union/) { } elsif ($identifier =~ m/^union\b/) {
$decl_type = 'union'; $decl_type = 'union';
} elsif ($identifier =~ m/^enum/) { } elsif ($identifier =~ m/^enum\b/) {
$decl_type = 'enum'; $decl_type = 'enum';
} elsif ($identifier =~ m/^typedef/) { } elsif ($identifier =~ m/^typedef\b/) {
$decl_type = 'typedef'; $decl_type = 'typedef';
} else { } else {
$decl_type = 'function'; $decl_type = 'function';
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment