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
17691769 # extract the filename as it passes
17701770 if ($line =~ /^diff --git.*?(\S+)$/) {
17711771 $realfile = $1;
1772− $realfile =~ s@^([^/]*)/@@;
1772+ $realfile =~ s@^([^/]*)/@@ if (!$file);
17731773 $in_commit_log = 0;
17741774 } elsif ($line =~ /^\+\+\+\s+(\S+)/) {
17751775 $realfile = $1;
1776− $realfile =~ s@^([^/]*)/@@;
1776+ $realfile =~ s@^([^/]*)/@@ if (!$file);
17771777 $in_commit_log = 0;
17781778
17791779 $p1_prefix = $1;
@@ -3877,7 +3877,8 @@ sub process { · 2097 unmodified lines
38773877 }
38783878
38793879 # 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/) {
38813882 if (WARN("INLINE",
38823883 "plain inline is preferred over $1\n" . $herecurr) &&
38833884 $fix) {
@@ -3887,19 +3888,22 @@ sub process { · 3 unmodified lines
38873888 }
38883889
38893890 # 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/) {
38913893 WARN("PREFER_PACKED",
38923894 "__packed is preferred over __attribute__((packed))\n" . $herecurr);
38933895 }
38943896
38953897 # 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/) {
38973900 WARN("PREFER_ALIGNED",
38983901 "__aligned(size) is preferred over __attribute__((aligned(size)))\n" . $herecurr);
38993902 }
39003903
39013904 # 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/) {
39033907 if (WARN("PREFER_PRINTF",
39043908 "__printf(string-index, first-to-check) is preferred over __attribute__((format(printf, string-index, first-to-check)))\n" . $herecurr) &&
39053909 $fix) {
@@ -3909,7 +3913,8 @@ sub process { · 3 unmodified lines
39093913 }
39103914
39113915 # 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/) {
39133918 if (WARN("PREFER_SCANF",
39143919 "__scanf(string-index, first-to-check) is preferred over __attribute__((format(scanf, string-index, first-to-check)))\n" . $herecurr) &&
39153920 $fix) {