Commit 309c00c73f053a905d144b430d4fb55d811085e2
Committed by
Linus Torvalds
1 parent
b0781216e7
Exists in
master
and in
39 other branches
checkpatch: warn about memset with swapped arguments
Because the second and third arguments of memset have the same type, it turns out to be really easy to mix them up. This bug comes up time after time, so checkpatch should really be checking for it at patch submission time. Signed-off-by: Dave Jones <davej@redhat.com> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Andy Whitcroft <apw@shadowen.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 1 changed file with 5 additions and 0 deletions Side-by-side Diff
scripts/checkpatch.pl
... | ... | @@ -2902,6 +2902,11 @@ |
2902 | 2902 | $line =~ /DEVICE_ATTR.*S_IWUGO/ ) { |
2903 | 2903 | WARN("Exporting world writable files is usually an error. Consider more restrictive permissions.\n" . $herecurr); |
2904 | 2904 | } |
2905 | + | |
2906 | + # Check for memset with swapped arguments | |
2907 | + if ($line =~ /memset.*\,(\ |)(0x|)0(\ |0|)\);/) { | |
2908 | + ERROR("memset size is 3rd argument, not the second.\n" . $herecurr); | |
2909 | + } | |
2905 | 2910 | } |
2906 | 2911 | |
2907 | 2912 | # If we have no input at all, then there is nothing to report on |