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.
Showing the changes to scripts/checkpatch.pl (1 of 1 file). Show all
Unified · Split
| @@ -1769,11 +1769,11 @@ sub process { · 1768 unmodified lines | ||
| 1769 | 1769 | # extract the filename as it passes |
| 1770 | 1770 | if ($line =~ /^diff --git.*?(\S+)$/) { |
| 1771 | 1771 | $realfile = $1; |
| 1772 | − $realfile =~ s@^([^/]*)/@@; | |
| 1772 | + $realfile =~ s@^([^/]*)/@@ if (!$file); | |
| 1773 | 1773 | $in_commit_log = 0; |
| 1774 | 1774 | } elsif ($line =~ /^\+\+\+\s+(\S+)/) { |
| 1775 | 1775 | $realfile = $1; |
| 1776 | − $realfile =~ s@^([^/]*)/@@; | |
| 1776 | + $realfile =~ s@^([^/]*)/@@ if (!$file); | |
| 1777 | 1777 | $in_commit_log = 0; |
| 1778 | 1778 | |
| 1779 | 1779 | $p1_prefix = $1; |
| @@ -3877,7 +3877,8 @@ sub process { · 2097 unmodified lines | ||
| 3877 | 3877 | } |
| 3878 | 3878 | |
| 3879 | 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 | 3882 | if (WARN("INLINE", |
| 3882 | 3883 | "plain inline is preferred over $1\n" . $herecurr) && |
| 3883 | 3884 | $fix) { |
| @@ -3887,19 +3888,22 @@ sub process { · 3 unmodified lines | ||
| 3887 | 3888 | } |
| 3888 | 3889 | |
| 3889 | 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 | 3893 | WARN("PREFER_PACKED", |
| 3892 | 3894 | "__packed is preferred over __attribute__((packed))\n" . $herecurr); |
| 3893 | 3895 | } |
| 3894 | 3896 | |
| 3895 | 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 | 3900 | WARN("PREFER_ALIGNED", |
| 3898 | 3901 | "__aligned(size) is preferred over __attribute__((aligned(size)))\n" . $herecurr); |
| 3899 | 3902 | } |
| 3900 | 3903 | |
| 3901 | 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 | 3907 | if (WARN("PREFER_PRINTF", |
| 3904 | 3908 | "__printf(string-index, first-to-check) is preferred over __attribute__((format(printf, string-index, first-to-check)))\n" . $herecurr) && |
| 3905 | 3909 | $fix) { |
| @@ -3909,7 +3913,8 @@ sub process { · 3 unmodified lines | ||
| 3909 | 3913 | } |
| 3910 | 3914 | |
| 3911 | 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 | 3918 | if (WARN("PREFER_SCANF", |
| 3914 | 3919 | "__scanf(string-index, first-to-check) is preferred over __attribute__((format(scanf, string-index, first-to-check)))\n" . $herecurr) && |
| 3915 | 3920 | $fix) { |