diff options
Diffstat (limited to 'scripts/checkpatch.pl')
| -rwxr-xr-x | scripts/checkpatch.pl | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 954f4914c4af..a81fc66e62cc 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
| @@ -5165,6 +5165,29 @@ sub process { | |||
| 5165 | "Prefer ether_addr_equal() or ether_addr_equal_unaligned() over memcmp()\n" . "$here\n$stat\n") | 5165 | "Prefer ether_addr_equal() or ether_addr_equal_unaligned() over memcmp()\n" . "$here\n$stat\n") |
| 5166 | } | 5166 | } |
| 5167 | 5167 | ||
| 5168 | # check for memset(foo, 0x0, ETH_ALEN) that could be eth_zero_addr | ||
| 5169 | # check for memset(foo, 0xFF, ETH_ALEN) that could be eth_broadcast_addr | ||
| 5170 | if ($^V && $^V ge 5.10.0 && | ||
| 5171 | defined $stat && | ||
| 5172 | $stat =~ /^\+(?:.*?)\bmemset\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\,\s*ETH_ALEN\s*\)/) { | ||
| 5173 | |||
| 5174 | my $ms_val = $7; | ||
| 5175 | |||
| 5176 | if ($ms_val =~ /^(?:0x|)0+$/i) { | ||
| 5177 | if (WARN("PREFER_ETH_ZERO_ADDR", | ||
| 5178 | "Prefer eth_zero_addr over memset()\n" . "$here\n$stat\n") && | ||
| 5179 | $fix) { | ||
| 5180 | $fixed[$fixlinenr] =~ s/\bmemset\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*,\s*ETH_ALEN\s*\)/eth_zero_addr($2)/; | ||
| 5181 | } | ||
| 5182 | } elsif ($ms_val =~ /^(?:0xff|255)$/i) { | ||
| 5183 | if (WARN("PREFER_ETH_BROADCAST_ADDR", | ||
| 5184 | "Prefer eth_broadcast_addr() over memset()\n" . "$here\n$stat\n") && | ||
| 5185 | $fix) { | ||
| 5186 | $fixed[$fixlinenr] =~ s/\bmemset\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*,\s*ETH_ALEN\s*\)/eth_broadcast_addr($2)/; | ||
| 5187 | } | ||
| 5188 | } | ||
| 5189 | } | ||
| 5190 | |||
| 5168 | # typecasts on min/max could be min_t/max_t | 5191 | # typecasts on min/max could be min_t/max_t |
| 5169 | if ($^V && $^V ge 5.10.0 && | 5192 | if ($^V && $^V ge 5.10.0 && |
| 5170 | defined $stat && | 5193 | defined $stat && |
