Add another test for __attribute__((section("foo"))) uses that should be __section(foo)
Showing the changes to scripts/checkpatch.pl (1 of 1 file). Show all
Unified · Split
| @@ -5886,6 +5886,18 @@ sub process { · 5885 unmodified lines | |||
| 5886 | "__aligned(size) is preferred over __attribute__((aligned(size)))\n" . $herecurr); | 5886 | "__aligned(size) is preferred over __attribute__((aligned(size)))\n" . $herecurr); |
| 5887 | } | 5887 | } |
| 5888 | 5888 | ||
| 5889 | # Check for __attribute__ section, prefer __section | ||
| 5890 | if ($realfile !~ m@\binclude/uapi/@ && | ||
| 5891 | $line =~ /\b__attribute__\s*\(\s*\(.*_*section_*\s*\(\s*("[^"]*")/) { | ||
| 5892 | my $old = substr($rawline, $-[1], $+[1] - $-[1]); | ||
| 5893 | my $new = substr($old, 1, -1); | ||
| 5894 | if (WARN("PREFER_SECTION", | ||
| 5895 | "__section($new) is preferred over __attribute__((section($old)))\n" . $herecurr) && | ||
| 5896 | $fix) { | ||
| 5897 | $fixed[$fixlinenr] =~ s/\b__attribute__\s*\(\s*\(\s*_*section_*\s*\(\s*\Q$old\E\s*\)\s*\)\s*\)/__section($new)/; | ||
| 5898 | } | ||
| 5899 | } | ||
| 5900 | |||
| 5889 | # Check for __attribute__ format(printf, prefer __printf | 5901 | # Check for __attribute__ format(printf, prefer __printf |
| 5890 | if ($realfile !~ m@\binclude/uapi/@ && | 5902 | if ($realfile !~ m@\binclude/uapi/@ && |
| 5891 | $line =~ /\b__attribute__\s*\(\s*\(\s*format\s*\(\s*printf/) { | 5903 | $line =~ /\b__attribute__\s*\(\s*\(\s*format\s*\(\s*printf/) { |