LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@kernel.org>
To: Andy Whitcroft <apw@canonical.com>, Joe Perches <joe@perches.com>
Cc: Dwaipayan Ray <dwaipayanray1@gmail.com>,
Lukas Bulwahn <lukas.bulwahn@gmail.com>,
linux-kernel@vger.kernel.org, mhiramat@kernel.org
Subject: [PATCH] checkpatch: Do not warn __initconst for const char *.
Date: Thu, 26 Aug 2021 11:19:21 +0900 [thread overview]
Message-ID: <162994436171.204899.977391959489238226.stgit@devnote2> (raw)
checkpatch.pl warns if an '__initdata' variable has 'const'
attribute to use __initconst, but it doesn't check that attribute
affects the type of a pointer or the variable. Thus it reports an
false error if 'const char *' variable is '__initdata'. e.g.
ERROR: Use of const init definition must use __initconst
#32: FILE: lib/bootconfig.c:32:
+static const char *xbc_err_msg __initdata;
To fix this issue, this ensures that the 'const' does not
follows any type string and a pointer ('*') too.
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
scripts/checkpatch.pl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 461d4221e4a4..c04213a7b633 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -6330,7 +6330,7 @@ sub process {
}
# check for $InitAttributeData (ie: __initdata) with const
- if ($line =~ /\bconst\b/ && $line =~ /($InitAttributeData)/) {
+ if ($line =~ /\bconst\b/ && $line !~ /\bconst\b[^\*\(]+\*/ && $line =~ /($InitAttributeData)/) {
my $attr = $1;
$attr =~ /($InitAttributePrefix)(.*)/;
my $attr_prefix = $1;
reply other threads:[~2021-08-26 2:20 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=162994436171.204899.977391959489238226.stgit@devnote2 \
--to=mhiramat@kernel.org \
--cc=apw@canonical.com \
--cc=dwaipayanray1@gmail.com \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lukas.bulwahn@gmail.com \
--subject='Re: [PATCH] checkpatch: Do not warn __initconst for const char *.' \
/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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).