diff options
Diffstat (limited to 'scripts/checkpatch.pl')
-rwxr-xr-x | scripts/checkpatch.pl | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index e3c7fc0dca3..4c0383da1c9 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
@@ -859,7 +859,7 @@ sub annotate_values { | |||
859 | $av_preprocessor = 0; | 859 | $av_preprocessor = 0; |
860 | } | 860 | } |
861 | 861 | ||
862 | } elsif ($cur =~ /^(\(\s*$Type\s*)\)/) { | 862 | } elsif ($cur =~ /^(\(\s*$Type\s*)\)/ && $av_pending eq '_') { |
863 | print "CAST($1)\n" if ($dbg_values > 1); | 863 | print "CAST($1)\n" if ($dbg_values > 1); |
864 | push(@av_paren_type, $type); | 864 | push(@av_paren_type, $type); |
865 | $type = 'C'; | 865 | $type = 'C'; |
@@ -2743,6 +2743,11 @@ sub process { | |||
2743 | WARN("plain inline is preferred over $1\n" . $herecurr); | 2743 | WARN("plain inline is preferred over $1\n" . $herecurr); |
2744 | } | 2744 | } |
2745 | 2745 | ||
2746 | # Check for __attribute__ packed, prefer __packed | ||
2747 | if ($line =~ /\b__attribute__\s*\(\s*\(.*\bpacked\b/) { | ||
2748 | WARN("__packed is preferred over __attribute__((packed))\n" . $herecurr); | ||
2749 | } | ||
2750 | |||
2746 | # check for sizeof(&) | 2751 | # check for sizeof(&) |
2747 | if ($line =~ /\bsizeof\s*\(\s*\&/) { | 2752 | if ($line =~ /\bsizeof\s*\(\s*\&/) { |
2748 | WARN("sizeof(& should be avoided\n" . $herecurr); | 2753 | WARN("sizeof(& should be avoided\n" . $herecurr); |
@@ -2785,10 +2790,15 @@ sub process { | |||
2785 | } | 2790 | } |
2786 | 2791 | ||
2787 | # check for pointless casting of kmalloc return | 2792 | # check for pointless casting of kmalloc return |
2788 | if ($line =~ /\*\s*\)\s*k[czm]alloc\b/) { | 2793 | if ($line =~ /\*\s*\)\s*[kv][czm]alloc(_node){0,1}\b/) { |
2789 | WARN("unnecessary cast may hide bugs, see http://c-faq.com/malloc/mallocnocast.html\n" . $herecurr); | 2794 | WARN("unnecessary cast may hide bugs, see http://c-faq.com/malloc/mallocnocast.html\n" . $herecurr); |
2790 | } | 2795 | } |
2791 | 2796 | ||
2797 | # check for multiple semicolons | ||
2798 | if ($line =~ /;\s*;\s*$/) { | ||
2799 | WARN("Statements terminations use 1 semicolon\n" . $herecurr); | ||
2800 | } | ||
2801 | |||
2792 | # check for gcc specific __FUNCTION__ | 2802 | # check for gcc specific __FUNCTION__ |
2793 | if ($line =~ /__FUNCTION__/) { | 2803 | if ($line =~ /__FUNCTION__/) { |
2794 | WARN("__func__ should be used instead of gcc specific __FUNCTION__\n" . $herecurr); | 2804 | WARN("__func__ should be used instead of gcc specific __FUNCTION__\n" . $herecurr); |
@@ -2892,6 +2902,11 @@ sub process { | |||
2892 | ERROR("lockdep_no_validate class is reserved for device->mutex.\n" . $herecurr); | 2902 | ERROR("lockdep_no_validate class is reserved for device->mutex.\n" . $herecurr); |
2893 | } | 2903 | } |
2894 | } | 2904 | } |
2905 | |||
2906 | if ($line =~ /debugfs_create_file.*S_IWUGO/ || | ||
2907 | $line =~ /DEVICE_ATTR.*S_IWUGO/ ) { | ||
2908 | WARN("Exporting world writable files is usually an error. Consider more restrictive permissions.\n" . $herecurr); | ||
2909 | } | ||
2895 | } | 2910 | } |
2896 | 2911 | ||
2897 | # If we have no input at all, then there is nothing to report on | 2912 | # If we have no input at all, then there is nothing to report on |