From: Aditya <yashsri421@gmail.com>
To: Jonathan Corbet <corbet@lwn.net>
Cc: lukas.bulwahn@gmail.com, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-kernel-mentees@lists.linuxfoundation.org
Subject: Re: [RFC] scripts: kernel-doc: fix typedef support for struct parsing
Date: Tue, 23 Feb 2021 17:55:36 +0530 [thread overview]
Message-ID: <19d41289-cf8e-881d-cc0d-9c7e193db242@gmail.com> (raw)
In-Reply-To: <875z2jlr2j.fsf@meer.lwn.net>
On 23/2/21 3:10 am, Jonathan Corbet wrote:
> Aditya Srivastava <yashsri421@gmail.com> writes:
>
>> There are files in kernel, which use 'typedef struct' syntax for defining
>> struct. For eg, include/linux/zstd.h, drivers/scsi/megaraid/mega_common.h,
>> etc.
>> However, kernel-doc still does not support it, causing a parsing error.
>>
>> For eg, running scripts/kernel-doc -none on include/linux/zstd.h emits:
>> "error: Cannot parse struct or union!"
>>
>> Add support for parsing it.
>>
>> Signed-off-by: Aditya Srivastava <yashsri421@gmail.com>
>> ---
>> scripts/kernel-doc | 12 ++++++++++--
>> 1 file changed, 10 insertions(+), 2 deletions(-)
>>
>> diff --git a/scripts/kernel-doc b/scripts/kernel-doc
>> index 8b5bc7bf4bb8..46e904dc3f87 100755
>> --- a/scripts/kernel-doc
>> +++ b/scripts/kernel-doc
>> @@ -1201,12 +1201,20 @@ sub dump_union($$) {
>> sub dump_struct($$) {
>> my $x = shift;
>> my $file = shift;
>> + my $decl_type;
>> + my $members;
>>
>> if ($x =~ /(struct|union)\s+(\w+)\s*\{(.*)\}(\s*(__packed|__aligned|____cacheline_aligned_in_smp|____cacheline_aligned|__attribute__\s*\(\([a-z0-9,_\s\(\)]*\)\)))*/) {
>> - my $decl_type = $1;
>> + $decl_type = $1;
>> $declaration_name = $2;
>> - my $members = $3;
>> + $members = $3;
>> + } elsif ($x =~ /typedef\s+(struct|union)\s*\{(.*)\}(?:\s*(?:__packed|__aligned|____cacheline_aligned_in_smp|____cacheline_aligned|__attribute__\s*\(\([a-z0-9,_\s\(\)]*\)\)))*\s*(\w*)\s*;/) {
>
> So this isn't your fault, but these regexes are really getting out of
> hand. I would *really* like to see some effort made into making this
> code more understandable / maintainable as we tweak this stuff. So:
>
> - Splitting out the common part, as suggested by Lukas, would be really
> useful. That would also avoid the problem of only occurrence being
> edited the next tine we add a new qualifier.
>
> - Splitting out other subsections of the regex and giving them symbolic
> names would also help.
>
> - We really could use some comments before these branches saying what
> they are doing; it is *not* obvious from the code.
>
> See what I'm getting at here?
>
Yep.
Thanks for the feedback Lukas and Jonathan. I'll get back with a v2
for the patch.
Thanks
Aditya
next prev parent reply other threads:[~2021-02-23 12:26 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-22 16:03 [RFC] scripts: kernel-doc: fix typedef support for struct parsing Aditya Srivastava
2021-02-22 17:49 ` Lukas Bulwahn
2021-02-22 21:40 ` Jonathan Corbet
2021-02-23 12:25 ` Aditya [this message]
2021-02-24 13:30 ` [RFC v2] scripts: kernel-doc: fix typedef support for struct/union parsing Aditya Srivastava
2021-02-25 11:48 ` Lukas Bulwahn
2021-02-25 14:50 ` [RFC v3] " Aditya Srivastava
2021-03-01 21:51 ` Jonathan Corbet
2021-03-06 4:35 ` Matthew Wilcox
2021-03-06 6:25 ` Lukas Bulwahn
2021-03-06 7:48 ` Aditya
2021-03-06 15:20 ` Matthew Wilcox
2021-03-07 7:36 ` Aditya
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=19d41289-cf8e-881d-cc0d-9c7e193db242@gmail.com \
--to=yashsri421@gmail.com \
--cc=corbet@lwn.net \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel-mentees@lists.linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lukas.bulwahn@gmail.com \
/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