* [PATCH] scripts: kernel-doc: Report excess struct member descriptions
@ 2023-12-15 0:14 Kees Cook
2023-12-15 0:21 ` Randy Dunlap
0 siblings, 1 reply; 3+ messages in thread
From: Kees Cook @ 2023-12-15 0:14 UTC (permalink / raw)
To: Jonathan Corbet; +Cc: Kees Cook, linux-doc, linux-kernel, linux-hardening
While missing descriptions were already be reported, missing struct
members were not. For example, previously this output was empty, but now
produces:
$ ./scripts/kernel-doc -none ./drivers/leds/leds-mlxreg.c
./drivers/leds/leds-mlxreg.c:42: warning: Excess struct member 'led_data' description in 'mlxreg_led_data'
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: linux-doc@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
scripts/kernel-doc | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 08a3e603db19..39e730ee1fef 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -1265,6 +1265,18 @@ sub dump_struct($$) {
$declaration .= "\t" . $clause . "\n";
$level++ if ($clause =~ m/(\{)/ && !($clause =~m/\}/));
}
+
+ my %_members;
+ $_members{$_}++ for (@parameterlist);
+
+ while (my ($k, $v) = each %parameterdescs) {
+ if (!exists($_members{$k})) {
+ if (show_warnings("struct", $declaration_name)) {
+ emit_warning("${file}:$.", "Excess struct member '$k' description in '$declaration_name'\n");
+ }
+ }
+ }
+
output_declaration($declaration_name,
'struct',
{'struct' => $declaration_name,
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] scripts: kernel-doc: Report excess struct member descriptions
2023-12-15 0:14 [PATCH] scripts: kernel-doc: Report excess struct member descriptions Kees Cook
@ 2023-12-15 0:21 ` Randy Dunlap
2023-12-15 1:01 ` Kees Cook
0 siblings, 1 reply; 3+ messages in thread
From: Randy Dunlap @ 2023-12-15 0:21 UTC (permalink / raw)
To: Kees Cook, Jonathan Corbet; +Cc: linux-doc, linux-kernel, linux-hardening
Hi Kees,
On 12/14/23 16:14, Kees Cook wrote:
> While missing descriptions were already be reported, missing struct
> members were not. For example, previously this output was empty, but now
> produces:
>
> $ ./scripts/kernel-doc -none ./drivers/leds/leds-mlxreg.c
> ./drivers/leds/leds-mlxreg.c:42: warning: Excess struct member 'led_data' description in 'mlxreg_led_data'
I just made a patch with similar functionality last night:
https://lore.kernel.org/linux-doc/20231214070200.24405-1-rdunlap@infradead.org/
>
> Cc: Jonathan Corbet <corbet@lwn.net>
> Cc: linux-doc@vger.kernel.org
> Signed-off-by: Kees Cook <keescook@chromium.org>
> ---
> scripts/kernel-doc | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/scripts/kernel-doc b/scripts/kernel-doc
> index 08a3e603db19..39e730ee1fef 100755
> --- a/scripts/kernel-doc
> +++ b/scripts/kernel-doc
> @@ -1265,6 +1265,18 @@ sub dump_struct($$) {
> $declaration .= "\t" . $clause . "\n";
> $level++ if ($clause =~ m/(\{)/ && !($clause =~m/\}/));
> }
> +
> + my %_members;
> + $_members{$_}++ for (@parameterlist);
> +
> + while (my ($k, $v) = each %parameterdescs) {
> + if (!exists($_members{$k})) {
> + if (show_warnings("struct", $declaration_name)) {
> + emit_warning("${file}:$.", "Excess struct member '$k' description in '$declaration_name'\n");
> + }
> + }
> + }
> +
> output_declaration($declaration_name,
> 'struct',
> {'struct' => $declaration_name,
--
#Randy
https://people.kernel.org/tglx/notes-about-netiquette
https://subspace.kernel.org/etiquette.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] scripts: kernel-doc: Report excess struct member descriptions
2023-12-15 0:21 ` Randy Dunlap
@ 2023-12-15 1:01 ` Kees Cook
0 siblings, 0 replies; 3+ messages in thread
From: Kees Cook @ 2023-12-15 1:01 UTC (permalink / raw)
To: Randy Dunlap; +Cc: Jonathan Corbet, linux-doc, linux-kernel, linux-hardening
On Thu, Dec 14, 2023 at 04:21:17PM -0800, Randy Dunlap wrote:
> Hi Kees,
>
> On 12/14/23 16:14, Kees Cook wrote:
> > While missing descriptions were already be reported, missing struct
> > members were not. For example, previously this output was empty, but now
> > produces:
> >
> > $ ./scripts/kernel-doc -none ./drivers/leds/leds-mlxreg.c
> > ./drivers/leds/leds-mlxreg.c:42: warning: Excess struct member 'led_data' description in 'mlxreg_led_data'
>
> I just made a patch with similar functionality last night:
>
> https://lore.kernel.org/linux-doc/20231214070200.24405-1-rdunlap@infradead.org/
Ah-ha! So you're as confused as me about where the robot was getting
warnings from! Your patch is better.
-Kees
--
Kees Cook
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-12-15 1:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-15 0:14 [PATCH] scripts: kernel-doc: Report excess struct member descriptions Kees Cook
2023-12-15 0:21 ` Randy Dunlap
2023-12-15 1:01 ` Kees Cook
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox