Handle multi-line memcpy() properly.

Signed-off-by: Mateusz Kulikowski <mateusz.kulikow...@gmail.com>
---
 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 netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to