]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
checkpatch: suggest using ether_addr_equal*()
authorMateusz Kulikowski <mateusz.kulikowski@gmail.com>
Thu, 25 Jun 2015 22:03:13 +0000 (15:03 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 26 Jun 2015 00:00:42 +0000 (17:00 -0700)
Check if memcmp() is used to compare ethernet addresses and suggest using
ether_addr_equal() or ether_addr_equal_unaligned()

Signed-off-by: Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
Acked-by: Joe Perches <joe@perches.com>
Cc: David Miller <davem@davemloft.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
scripts/checkpatch.pl

index 69c4716d9e27451fd7a664cc7f0fc0776b5542fb..f04fe88d998df5b7cdbe4a92e87672a648b0f24f 100755 (executable)
@@ -5157,6 +5157,14 @@ sub process {
                        }
                }
 
+# Check for memcmp(foo, bar, ETH_ALEN) that could be ether_addr_equal*(foo, bar)
+               if ($^V && $^V ge 5.10.0 &&
+                   defined $stat &&
+                   $stat =~ /^\+(?:.*?)\bmemcmp\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\,\s*ETH_ALEN\s*\)/) {
+                       WARN("PREFER_ETHER_ADDR_EQUAL",
+                            "Prefer ether_addr_equal() or ether_addr_equal_unaligned() over memcmp()\n" . "$here\n$stat\n")
+               }
+
 # typecasts on min/max could be min_t/max_t
                if ($^V && $^V ge 5.10.0 &&
                    defined $stat &&