From: Joe Perches <joe@perches.com>
To: Kees Cook <keescook@chromium.org>,
Andrew Morton <akpm@linux-foundation.org>
Cc: Matthew Wilcox <willy@infradead.org>,
Stephen Rothwell <sfr@canb.auug.org.au>,
Jonathan Corbet <corbet@lwn.net>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: Re: [PATCH] scripts: kernel-doc: Ignore __alloc_size() attribute
Date: Mon, 11 Oct 2021 11:23:33 -0700 [thread overview]
Message-ID: <2d6bf6a7413fafce51a7e1d80c959b57faeb4b75.camel@perches.com> (raw)
In-Reply-To: <20211011180650.3603988-1-keescook@chromium.org>
On Mon, 2021-10-11 at 11:06 -0700, Kees Cook wrote:
> Fixes "Compiler Attributes: add __alloc_size() for better bounds checking"
> so that the __alloc_size() macro is ignored for function prototypes when
> generating kerndoc. Avoids warnings like:
>
> ./include/linux/slab.h:662: warning: Function parameter or member '1' not described in '__alloc_size'
> ./include/linux/slab.h:662: warning: Function parameter or member '2' not described in '__alloc_size'
> ./include/linux/slab.h:662: warning: expecting prototype for kcalloc(). Prototype was for __alloc_size() instead
[]
> diff --git a/scripts/kernel-doc b/scripts/kernel-doc
[]
> @@ -1789,6 +1789,7 @@ sub dump_function($$) {
> $prototype =~ s/__weak +//;
> $prototype =~ s/__sched +//;
> $prototype =~ s/__printf\s*\(\s*\d*\s*,\s*\d*\s*\) +//;
> + $prototype =~ s/__alloc_size\s*\(\s*\d+\s*(?:,\s*\d+\s*)?\) +//;
> my $define = $prototype =~ s/^#\s*define\s+//; #ak added
> $prototype =~ s/__attribute_const__ +//;
> $prototype =~ s/__attribute__\s*\(\(
Perhaps all this would be more intelligible and a bit more future-proof
using a regex that consumes all the various __<foo> prefixed attributes.
Maybe:
my $balanced_parens = qr/(\((?:[^\(\)]++|(?-1))*\))/;
$prototype =~ s/\b__\w+\s*(?:$balanced_parens)?\s*//g;
next prev parent reply other threads:[~2021-10-11 18:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-11 18:06 Kees Cook
2021-10-11 18:23 ` Joe Perches [this message]
2021-10-12 20:23 ` Jonathan Corbet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2d6bf6a7413fafce51a7e1d80c959b57faeb4b75.camel@perches.com \
--to=joe@perches.com \
--cc=akpm@linux-foundation.org \
--cc=corbet@lwn.net \
--cc=keescook@chromium.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=sfr@canb.auug.org.au \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox