aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/checkpatch.pl
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/checkpatch.pl')
-rwxr-xr-xscripts/checkpatch.pl8
1 files changed, 8 insertions, 0 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 517da26d9a2d..6185eb67df94 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3507,6 +3507,14 @@ sub process {
3507 "unnecessary cast may hide bugs, see http://c-faq.com/malloc/mallocnocast.html\n" . $herecurr); 3507 "unnecessary cast may hide bugs, see http://c-faq.com/malloc/mallocnocast.html\n" . $herecurr);
3508 } 3508 }
3509 3509
3510# alloc style
3511# p = alloc(sizeof(struct foo), ...) should be p = alloc(sizeof(*p), ...)
3512 if ($^V && $^V ge 5.10.0 &&
3513 $line =~ /\b($Lval)\s*\=\s*(?:$balanced_parens)?\s*([kv][mz]alloc(?:_node)?)\s*\(\s*(sizeof\s*\(\s*struct\s+$Lval\s*\))/) {
3514 CHK("ALLOC_SIZEOF_STRUCT",
3515 "Prefer $3(sizeof(*$1)...) over $3($4...)\n" . $herecurr);
3516 }
3517
3510# check for krealloc arg reuse 3518# check for krealloc arg reuse
3511 if ($^V && $^V ge 5.10.0 && 3519 if ($^V && $^V ge 5.10.0 &&
3512 $line =~ /\b($Lval)\s*\=\s*(?:$balanced_parens)?\s*krealloc\s*\(\s*\1\s*,/) { 3520 $line =~ /\b($Lval)\s*\=\s*(?:$balanced_parens)?\s*krealloc\s*\(\s*\1\s*,/) {