aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2013-11-12 18:10:14 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-11-12 22:09:25 -0500
commit2b7ab45395dc4d91ef30985f76d90a8f28f58c27 (patch)
treee15c7ed2dd28389a1155daad6d3f178d9d69ff2e /scripts
parent507e51418ca0c98640310aa02450720825b2b6b1 (diff)
checkpatch: don't require kernel style __attribute__ shortcuts in uapi paths
Avoid prescribing kernel styled shortcuts for gcc extensions of __attribute__((foo)) in the uapi include paths. Fix $realfile filename when using -f/--file to not remove first level directory as if the filename was used in a -P1 patch. Only strip the first level directory (typically a or b) for P1 patches. Signed-off-by: Joe Perches <joe@perches.com> Cc: "Dixit, Ashutosh" <ashutosh.dixit@intel.com> Cc: Andy Whitcroft <apw@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/checkpatch.pl19
1 files changed, 12 insertions, 7 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 6e0f1ec0d6f2..1eb5d2fa8d20 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1769,11 +1769,11 @@ sub process {
1769 # extract the filename as it passes 1769 # extract the filename as it passes
1770 if ($line =~ /^diff --git.*?(\S+)$/) { 1770 if ($line =~ /^diff --git.*?(\S+)$/) {
1771 $realfile = $1; 1771 $realfile = $1;
1772 $realfile =~ s@^([^/]*)/@@; 1772 $realfile =~ s@^([^/]*)/@@ if (!$file);
1773 $in_commit_log = 0; 1773 $in_commit_log = 0;
1774 } elsif ($line =~ /^\+\+\+\s+(\S+)/) { 1774 } elsif ($line =~ /^\+\+\+\s+(\S+)/) {
1775 $realfile = $1; 1775 $realfile = $1;
1776 $realfile =~ s@^([^/]*)/@@; 1776 $realfile =~ s@^([^/]*)/@@ if (!$file);
1777 $in_commit_log = 0; 1777 $in_commit_log = 0;
1778 1778
1779 $p1_prefix = $1; 1779 $p1_prefix = $1;
@@ -3877,7 +3877,8 @@ sub process {
3877 } 3877 }
3878 3878
3879# Check for __inline__ and __inline, prefer inline 3879# Check for __inline__ and __inline, prefer inline
3880 if ($line =~ /\b(__inline__|__inline)\b/) { 3880 if ($realfile !~ m@\binclude/uapi/@ &&
3881 $line =~ /\b(__inline__|__inline)\b/) {
3881 if (WARN("INLINE", 3882 if (WARN("INLINE",
3882 "plain inline is preferred over $1\n" . $herecurr) && 3883 "plain inline is preferred over $1\n" . $herecurr) &&
3883 $fix) { 3884 $fix) {
@@ -3887,19 +3888,22 @@ sub process {
3887 } 3888 }
3888 3889
3889# Check for __attribute__ packed, prefer __packed 3890# Check for __attribute__ packed, prefer __packed
3890 if ($line =~ /\b__attribute__\s*\(\s*\(.*\bpacked\b/) { 3891 if ($realfile !~ m@\binclude/uapi/@ &&
3892 $line =~ /\b__attribute__\s*\(\s*\(.*\bpacked\b/) {
3891 WARN("PREFER_PACKED", 3893 WARN("PREFER_PACKED",
3892 "__packed is preferred over __attribute__((packed))\n" . $herecurr); 3894 "__packed is preferred over __attribute__((packed))\n" . $herecurr);
3893 } 3895 }
3894 3896
3895# Check for __attribute__ aligned, prefer __aligned 3897# Check for __attribute__ aligned, prefer __aligned
3896 if ($line =~ /\b__attribute__\s*\(\s*\(.*aligned/) { 3898 if ($realfile !~ m@\binclude/uapi/@ &&
3899 $line =~ /\b__attribute__\s*\(\s*\(.*aligned/) {
3897 WARN("PREFER_ALIGNED", 3900 WARN("PREFER_ALIGNED",
3898 "__aligned(size) is preferred over __attribute__((aligned(size)))\n" . $herecurr); 3901 "__aligned(size) is preferred over __attribute__((aligned(size)))\n" . $herecurr);
3899 } 3902 }
3900 3903
3901# Check for __attribute__ format(printf, prefer __printf 3904# Check for __attribute__ format(printf, prefer __printf
3902 if ($line =~ /\b__attribute__\s*\(\s*\(\s*format\s*\(\s*printf/) { 3905 if ($realfile !~ m@\binclude/uapi/@ &&
3906 $line =~ /\b__attribute__\s*\(\s*\(\s*format\s*\(\s*printf/) {
3903 if (WARN("PREFER_PRINTF", 3907 if (WARN("PREFER_PRINTF",
3904 "__printf(string-index, first-to-check) is preferred over __attribute__((format(printf, string-index, first-to-check)))\n" . $herecurr) && 3908 "__printf(string-index, first-to-check) is preferred over __attribute__((format(printf, string-index, first-to-check)))\n" . $herecurr) &&
3905 $fix) { 3909 $fix) {
@@ -3909,7 +3913,8 @@ sub process {
3909 } 3913 }
3910 3914
3911# Check for __attribute__ format(scanf, prefer __scanf 3915# Check for __attribute__ format(scanf, prefer __scanf
3912 if ($line =~ /\b__attribute__\s*\(\s*\(\s*format\s*\(\s*scanf\b/) { 3916 if ($realfile !~ m@\binclude/uapi/@ &&
3917 $line =~ /\b__attribute__\s*\(\s*\(\s*format\s*\(\s*scanf\b/) {
3913 if (WARN("PREFER_SCANF", 3918 if (WARN("PREFER_SCANF",
3914 "__scanf(string-index, first-to-check) is preferred over __attribute__((format(scanf, string-index, first-to-check)))\n" . $herecurr) && 3919 "__scanf(string-index, first-to-check) is preferred over __attribute__((format(scanf, string-index, first-to-check)))\n" . $herecurr) &&
3915 $fix) { 3920 $fix) {