[PATCH v3 4/4] checkpatch: Add multi-line handling for PREFER_ETHER_ADDR_COPY
From: Mateusz Kulikowski
Date: Sun Apr 26 2015 - 12:44:28 EST
Handle multi-line memcpy() properly.
Signed-off-by: Mateusz Kulikowski <mateusz.kulikowski@xxxxxxxxx>
---
scripts/checkpatch.pl | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index c05befe..6311950 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -5027,9 +5027,10 @@ sub process {
# Check for memcpy(foo, bar, ETH_ALEN) that could be ether_addr_copy(foo, bar)
if ($^V && $^V ge 5.10.0 &&
- $line =~ /^\+(?:.*?)\bmemcpy\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\,\s*ETH_ALEN\s*\)/s) {
+ defined $stat &&
+ $stat =~ /^\+(?:.*?)\bmemcpy\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\,\s*ETH_ALEN\s*\)/) {
if (WARN("PREFER_ETHER_ADDR_COPY",
- "Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2)\n" . $herecurr) &&
+ "Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2)\n" . "$here\n$stat\n") &&
$fix) {
$fixed[$fixlinenr] =~ s/\bmemcpy\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\,\s*ETH_ALEN\s*\)/ether_addr_copy($2, $7)/;
}
--
1.8.4.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/