History

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.

Joe Perches committed 13 years ago

Commit 2b7ab451 parent 507e5141 file · +12 −7Browse files

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

Unified · Split

scripts/checkpatch.pl+12−7
@@ -1769,11 +1769,11 @@ sub process { · 1768 unmodified lines
1769 # extract the filename as it passes1769 # 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 { · 2097 unmodified lines
3877 }3877 }
3878 3878
3879# Check for __inline__ and __inline, prefer inline3879# 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 { · 3 unmodified lines
3887 }3888 }
3888 3889
3889# Check for __attribute__ packed, prefer __packed3890# 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 __aligned3897# 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 __printf3904# 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 { · 3 unmodified lines
3909 }3913 }
3910 3914
3911# Check for __attribute__ format(scanf, prefer __scanf3915# 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) {