mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: "Andy Shevchenko" <andy@kernel.org>, "Björn Töpel" <bjorn@kernel.org>
Cc: "Andy Whitcroft" <apw@canonical.com>,
	"Dwaipayan Ray" <dwaipayanray1@gmail.com>,
	"Lukas Bulwahn" <lukas.bulwahn@gmail.com>,
	linux-kernel@vger.kernel.org, "Björn Töpel" <bjorn@rivosinc.com>
Subject: Re: [RFC PATCH] checkpatch: Support __initconst combined with struct definition
Date: Tue, 11 Apr 2023 18:53:42 -0700	[thread overview]
Message-ID: <2b966f46a5f60de629681527bb00401830118947.camel@perches.com> (raw)
In-Reply-To: <ZDVixjH5qLoy1jTW@smile.fi.intel.com>

On Tue, 2023-04-11 at 16:38 +0300, Andy Shevchenko wrote:
> On Wed, Mar 01, 2023 at 10:43:20AM +0100, Björn Töpel wrote:
> > From: Björn Töpel <bjorn@rivosinc.com>
> > 
> > Checkpatch sometimes report a false positive for __initconst. E.g., for the
> > following snippet:
> > 
> >  | static const struct strspn_test {
> >  | 	const char str[16];
> >  | 	const char accept[16];
> >  | 	const char reject[16];
> >  | 	unsigned a;
> >  | 	unsigned r;
> >  | } tests[] __initconst = {
> >  | 	{ "foobar", "", "", 0, 6 },
> >  | 	{ "abba", "abc", "ABBA", 4, 4 },
> >  | 	{ "abba", "a", "b", 1, 1 },
> >  | 	{ "", "abc", "abc", 0, 0},
> >  | };
> > 
> > checkpatch would report:
> > 
> >  | ERROR: Use of __initconst requires a separate use of const
> >  | #190: FILE: ./test_string.c:190:
> >  | +	} tests[] __initconst = {
> > 
> > Improve the reporting by trying harder to find the 'const'.
> 
> Joe, what do you think about this?

I think the ctx_block_outer_rev  function doesn't handle patch
context blocks and the loop at best needs to be changed to include

	last if $rawlines[$line] =~ /^@/);.

And the loop parsing couldn't handle structs with embedded
unions or structs.

I also think that checkpatch will always have false negatives
and false positives and this might not be that useful as likely
most compilers should now be able to identify this as well.


      reply	other threads:[~2023-04-12  1:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-01  9:43 Björn Töpel
2023-04-11 13:38 ` Andy Shevchenko
2023-04-12  1:53   ` Joe Perches [this message]

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=2b966f46a5f60de629681527bb00401830118947.camel@perches.com \
    --to=joe@perches.com \
    --cc=andy@kernel.org \
    --cc=apw@canonical.com \
    --cc=bjorn@kernel.org \
    --cc=bjorn@rivosinc.com \
    --cc=dwaipayanray1@gmail.com \
    --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

all inboxes | Powered by JetHome®