+ checkpatch-add-strict-preference-for-p-=-kmallocsizeofp.patch added to -mm tree
Subject: + checkpatch-add-strict-preference-for-p-=-kmallocsizeofp.patch added to -mm tree
To: [email protected]
From: [email protected]
Date: Tue, 28 May 2013 13:42:06 -0700
The patch titled
Subject: checkpatch: add --strict preference for p = kmalloc(sizeof(*p)...
has been added to the -mm tree. Its filename is
checkpatch-add-strict-preference-for-p-=-kmallocsizeofp.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/SubmitChecklist when testing your code ***
The -mm tree is included into linux-next and is updated there every 3-4 working days
------------------------------------------------------
From: Joe Perches <[email protected]>
Subject: checkpatch: add --strict preference for p = kmalloc(sizeof(*p)...
Add another test for memory allocation style to follow Documentation/CodingStyle:
Chapter 14: Allocating memory
The preferred form for passing a size of a struct is the following:
p = kmalloc(sizeof(*p), ...);
---
scripts/checkpatch.pl | 8 ++++++++ 1 file changed, 8 insertions(+)
scripts/checkpatch.pl renamed from scripts/checkpatch.pl~checkpatch-add-strict-preference-for-p-=-kmallocsizeofp +8 -0
@@ -3507,6 +3507,14 @@ sub process { "unnecessary cast may hide bugs, see http://c-faq.com/malloc/mallocnocast.html\n" . $herecurr); } +# alloc style +# p = alloc(sizeof(struct foo), ...) should be p = alloc(sizeof(*p), ...) + if ($^V && $^V ge 5.10.0 && + $line =~ /\b($Lval)\s*\=\s*(?:$balanced_parens)?\s*([kv][mz]alloc(?:_node)?)\s*\(\s*(sizeof\s*\(\s*struct\s+$Lval\s*\))/) { + CHK("ALLOC_SIZEOF_STRUCT", + "Prefer $3(sizeof(*$1)...) over $3($4...)\n" . $herecurr); + } + # check for krealloc arg reuse if ($^V && $^V ge 5.10.0 && $line =~ /\b($Lval)\s*\=\s*(?:$balanced_parens)?\s*krealloc\s*\(\s*\1\s*,/) {
_
Patches currently in -mm which might be from [email protected] are
linux-next.patch lib-bitmapc-speed-up-bitmap_find_free_region.patch lib-bitmapc-speed-up-bitmap_find_free_region-fix.patch checkpatch-change-camelcase-test-and-make-it-strict.patch checkpatch-warn-when-using-gccs-binary-constant-extension.patch checkpatch-add-strict-preference-for-p-=-kmallocsizeofp.patch