Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 10895d2c authored by Mateusz Kulikowski's avatar Mateusz Kulikowski Committed by Linus Torvalds
Browse files

checkpatch: add multi-line handling for PREFER_ETHER_ADDR_COPY



Handle multi-line memcpy() properly.

Signed-off-by: default avatarMateusz Kulikowski <mateusz.kulikowski@gmail.com>
Acked-by: default avatarJoe Perches <joe@perches.com>
Cc: David Miller <davem@davemloft.net>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 8617cd09
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -5149,9 +5149,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)/;
			}