checkpatch: prefer __section over __attribute__((section(...)))
[linux-2.6-block.git] / scripts / checkpatch.pl
index d7466879d50526ad29a3a4c84b38b95bda32e727..1f85a3abbd171adbf6e513c8095ec4d3f0cebc67 100755 (executable)
@@ -5886,6 +5886,18 @@ sub process {
                             "__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
                if ($realfile !~ m@\binclude/uapi/@ &&
                    $line =~ /\b__attribute__\s*\(\s*\(\s*format\s*\(\s*printf/) {