History

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

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

Joe Perches committed 7 years ago

Commit 462811d1 parent 6dba8241 file · +12 −0Browse files

Showing the changes to scripts/checkpatch.pl (1 of 1 file). Show all

Unified · Split

scripts/checkpatch.pl+12−0
@@ -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 __printf5901# 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/) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t