linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] checkpatch: Do not warn __initconst for const char *.
@ 2021-08-26  2:19 Masami Hiramatsu
  0 siblings, 0 replies; only message in thread
From: Masami Hiramatsu @ 2021-08-26  2:19 UTC (permalink / raw)
  To: Andy Whitcroft, Joe Perches
  Cc: Dwaipayan Ray, Lukas Bulwahn, linux-kernel, mhiramat

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;


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-08-26  2:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-26  2:19 [PATCH] checkpatch: Do not warn __initconst for const char * Masami Hiramatsu

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).