* [PATCH] kernel-doc: fix declaration type determination
@ 2018-10-18 4:07 Randy Dunlap
2018-10-18 9:14 ` Jani Nikula
2018-10-18 18:21 ` Jonathan Corbet
0 siblings, 2 replies; 3+ messages in thread
From: Randy Dunlap @ 2018-10-18 4:07 UTC (permalink / raw)
To: linux-doc, LKML, Jonathan Corbet; +Cc: Kees Cook, Jani Nikula
From: Randy Dunlap <rdunlap@infradead.org>
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: Randy Dunlap <rdunlap@infradead.org>
Tested-by: Kees Cook <keescook@chromium.org>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: linux-doc@vger.kernel.org
---
scripts/kernel-doc | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
--- lnx-419-rc8.orig/scripts/kernel-doc
+++ lnx-419-rc8/scripts/kernel-doc
@@ -1904,13 +1904,13 @@ sub process_name($$) {
++$warnings;
}
- if ($identifier =~ m/^struct/) {
+ if ($identifier =~ m/^struct\b/) {
$decl_type = 'struct';
- } elsif ($identifier =~ m/^union/) {
+ } elsif ($identifier =~ m/^union\b/) {
$decl_type = 'union';
- } elsif ($identifier =~ m/^enum/) {
+ } elsif ($identifier =~ m/^enum\b/) {
$decl_type = 'enum';
- } elsif ($identifier =~ m/^typedef/) {
+ } elsif ($identifier =~ m/^typedef\b/) {
$decl_type = 'typedef';
} else {
$decl_type = 'function';
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] kernel-doc: fix declaration type determination
2018-10-18 4:07 [PATCH] kernel-doc: fix declaration type determination Randy Dunlap
@ 2018-10-18 9:14 ` Jani Nikula
2018-10-18 18:21 ` Jonathan Corbet
1 sibling, 0 replies; 3+ messages in thread
From: Jani Nikula @ 2018-10-18 9:14 UTC (permalink / raw)
To: Randy Dunlap, linux-doc, LKML, Jonathan Corbet; +Cc: Kees Cook
On Wed, 17 Oct 2018, Randy Dunlap <rdunlap@infradead.org> wrote:
> From: Randy Dunlap <rdunlap@infradead.org>
>
> 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.
My perl is all cargo cult, so can't really review, but based on the
description this is what should be done,
Acked-by: Jani Nikula <jani.nikula@intel.com>
> 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.
I used to do diff -r on pre and post change clean documentation builds
to verify this type of stuff.
BR,
Jani.
>
> Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
> Tested-by: Kees Cook <keescook@chromium.org>
> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> Cc: Jonathan Corbet <corbet@lwn.net>
> Cc: linux-doc@vger.kernel.org
> ---
> scripts/kernel-doc | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> --- lnx-419-rc8.orig/scripts/kernel-doc
> +++ lnx-419-rc8/scripts/kernel-doc
> @@ -1904,13 +1904,13 @@ sub process_name($$) {
> ++$warnings;
> }
>
> - if ($identifier =~ m/^struct/) {
> + if ($identifier =~ m/^struct\b/) {
> $decl_type = 'struct';
> - } elsif ($identifier =~ m/^union/) {
> + } elsif ($identifier =~ m/^union\b/) {
> $decl_type = 'union';
> - } elsif ($identifier =~ m/^enum/) {
> + } elsif ($identifier =~ m/^enum\b/) {
> $decl_type = 'enum';
> - } elsif ($identifier =~ m/^typedef/) {
> + } elsif ($identifier =~ m/^typedef\b/) {
> $decl_type = 'typedef';
> } else {
> $decl_type = 'function';
>
>
--
Jani Nikula, Intel Open Source Graphics Center
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] kernel-doc: fix declaration type determination
2018-10-18 4:07 [PATCH] kernel-doc: fix declaration type determination Randy Dunlap
2018-10-18 9:14 ` Jani Nikula
@ 2018-10-18 18:21 ` Jonathan Corbet
1 sibling, 0 replies; 3+ messages in thread
From: Jonathan Corbet @ 2018-10-18 18:21 UTC (permalink / raw)
To: Randy Dunlap; +Cc: linux-doc, LKML, Kees Cook, Jani Nikula
On Wed, 17 Oct 2018 21:07:27 -0700
Randy Dunlap <rdunlap@infradead.org> wrote:
> From: Randy Dunlap <rdunlap@infradead.org>
>
> 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: Randy Dunlap <rdunlap@infradead.org>
Applied, thanks.
jon
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-10-18 18:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-18 4:07 [PATCH] kernel-doc: fix declaration type determination Randy Dunlap
2018-10-18 9:14 ` Jani Nikula
2018-10-18 18:21 ` Jonathan Corbet
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.