Commit 462811d9 authored by Joe Perches's avatar Joe Perches Committed by Linus Torvalds

checkpatch: prefer __section over __attribute__((section(...)))

Add another test for __attribute__((section("foo"))) uses that should be
__section(foo)

Link: http://lkml.kernel.org/r/2f374c3c27054b7f978115270d587c624d9962fc.camel@perches.comSuggested-by: default avatarNick Desaulniers <ndesaulniers@google.com>
Signed-off-by: default avatarJoe Perches <joe@perches.com>
Tested-by: default avatarNick Desaulniers <ndesaulniers@google.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 6dba824e
...@@ -5886,6 +5886,18 @@ sub process { ...@@ -5886,6 +5886,18 @@ sub process {
"__aligned(size) is preferred over __attribute__((aligned(size)))\n" . $herecurr); "__aligned(size) is preferred over __attribute__((aligned(size)))\n" . $herecurr);
} }
# Check for __attribute__ section, prefer __section
if ($realfile !~ m@\binclude/uapi/@ &&
$line =~ /\b__attribute__\s*\(\s*\(.*_*section_*\s*\(\s*("[^"]*")/) {
my $old = substr($rawline, $-[1], $+[1] - $-[1]);
my $new = substr($old, 1, -1);
if (WARN("PREFER_SECTION",
"__section($new) is preferred over __attribute__((section($old)))\n" . $herecurr) &&
$fix) {
$fixed[$fixlinenr] =~ s/\b__attribute__\s*\(\s*\(\s*_*section_*\s*\(\s*\Q$old\E\s*\)\s*\)\s*\)/__section($new)/;
}
}
# Check for __attribute__ format(printf, prefer __printf # Check for __attribute__ format(printf, prefer __printf
if ($realfile !~ m@\binclude/uapi/@ && if ($realfile !~ m@\binclude/uapi/@ &&
$line =~ /\b__attribute__\s*\(\s*\(\s*format\s*\(\s*printf/) { $line =~ /\b__attribute__\s*\(\s*\(\s*format\s*\(\s*printf/) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment