lkml.org 
[lkml]   [2015]   [Apr]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 2/2] checkpatch: suggest using eth_zero_addr() and eth_broadcast_addr()
From
Date
On Sun, 2015-04-19 at 21:04 +0200, Mateusz Kulikowski wrote:
> Suggest using eth_zero_addr() or eth_broadcast_addr() if memset is used instead.

Hi Mateusz, this is OK but here are some notes:

> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -5042,6 +5042,22 @@ sub process {
[]
> +# check for memset(foo, 0x0, ETH_ALEN) that could be eth_zero_addr
> +# check for memset(foo, 0xFF, ETH_ALEN) that could be eth_broadcast_addr
> + if ($^V && $^V ge 5.10.0 &&
> + $line =~ /^\+(?:.*?)\bmemset\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\,\s*ETH_ALEN\s*\)/s) {

Please align the $line with the $^V above it.

> +
> + my $ms_val = $7;
> +
> + if ($ms_val =~ /^(0x|)0$/i) {

I've seen 0x00 many times so: /^(?:0x|)0+$/

> + WARN("PREFER_ETH_ZERO_ADDR",
> + "Prefer eth_zero_addr over memset()\n" . $herecurr);

Please align to the initial open quote here:

WARN("PREFER_ETH_ZERO_ADDR",
"Prefer eth_zero_addr over memset()\n" . $herecurr);

> + } elsif ($ms_val =~ /^0xff$/i) {

255 here too so: /^(?:0xff|255)$/

> + WARN("PREFER_ETH_BROADCAST_ADDR",
> + "Prefer eth_broadcast_addr() over memset()\n" . $herecurr);

Please align to open quote




\
 
 \ /
  Last update: 2015-04-19 22:41    [W:0.132 / U:1.444 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site