public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg <gvrose8192@gmail.com>
To: Joe Perches <joe@perches.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Andy Whitcroft <apw@canonical.com>,
	Dan Carpenter <dan.carpenter@oracle.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] checkpatch: Don't test for prefer ether_addr_<foo>
Date: Wed, 31 Aug 2016 10:57:55 -0700	[thread overview]
Message-ID: <1472666275.3889.2.camel@gmail.com> (raw)
In-Reply-To: <dc32ec66d24647f4cdf824c8dfbbc59aa7ce7b7d.1472665676.git.joe@perches.com>

On Wed, 2016-08-31 at 10:48 -0700, Joe Perches wrote:
> < sigh > Comment these tests out.
> 
> These are just too enticing to people that don't verify that
> both source and dest addresses really must be __aligned(2).
> 
> It helps make Dan Carpenter happy too.

Having just been snagged by this it will make me happy too.

- Greg

> 
> Signed-off-by: Joe Perches <joe@perches.com>
> cc: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  scripts/checkpatch.pl | 70 +++++++++++++++++++++++++--------------------------
>  1 file changed, 35 insertions(+), 35 deletions(-)
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index bdc12d9..3f7245c 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -5568,46 +5568,46 @@ sub process {
>  		}
>  
>  # Check for memcpy(foo, bar, ETH_ALEN) that could be ether_addr_copy(foo, bar)
> -		if ($^V && $^V ge 5.10.0 &&
> -		    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" . "$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)/;
> -			}
> -		}
> +#		if ($^V && $^V ge 5.10.0 &&
> +#		    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" . "$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)/;
> +#			}
> +#		}
>  
>  # 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")
> -		}
> +#		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")
> +#		}
>  
>  # 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 &&
> -		    defined $stat &&
> -		    $stat =~ /^\+(?:.*?)\bmemset\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\,\s*ETH_ALEN\s*\)/) {
> -
> -			my $ms_val = $7;
> -
> -			if ($ms_val =~ /^(?:0x|)0+$/i) {
> -				if (WARN("PREFER_ETH_ZERO_ADDR",
> -					 "Prefer eth_zero_addr over memset()\n" . "$here\n$stat\n") &&
> -				    $fix) {
> -					$fixed[$fixlinenr] =~ s/\bmemset\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*,\s*ETH_ALEN\s*\)/eth_zero_addr($2)/;
> -				}
> -			} elsif ($ms_val =~ /^(?:0xff|255)$/i) {
> -				if (WARN("PREFER_ETH_BROADCAST_ADDR",
> -					 "Prefer eth_broadcast_addr() over memset()\n" . "$here\n$stat\n") &&
> -				    $fix) {
> -					$fixed[$fixlinenr] =~ s/\bmemset\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*,\s*ETH_ALEN\s*\)/eth_broadcast_addr($2)/;
> -				}
> -			}
> -		}
> +#		if ($^V && $^V ge 5.10.0 &&
> +#		    defined $stat &&
> +#		    $stat =~ /^\+(?:.*?)\bmemset\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\,\s*ETH_ALEN\s*\)/) {
> +#
> +#			my $ms_val = $7;
> +#
> +#			if ($ms_val =~ /^(?:0x|)0+$/i) {
> +#				if (WARN("PREFER_ETH_ZERO_ADDR",
> +#					 "Prefer eth_zero_addr over memset()\n" . "$here\n$stat\n") &&
> +#				    $fix) {
> +#					$fixed[$fixlinenr] =~ s/\bmemset\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*,\s*ETH_ALEN\s*\)/eth_zero_addr($2)/;
> +#				}
> +#			} elsif ($ms_val =~ /^(?:0xff|255)$/i) {
> +#				if (WARN("PREFER_ETH_BROADCAST_ADDR",
> +#					 "Prefer eth_broadcast_addr() over memset()\n" . "$here\n$stat\n") &&
> +#				    $fix) {
> +#					$fixed[$fixlinenr] =~ s/\bmemset\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*,\s*ETH_ALEN\s*\)/eth_broadcast_addr($2)/;
> +#				}
> +#			}
> +#		}
>  
>  # typecasts on min/max could be min_t/max_t
>  		if ($^V && $^V ge 5.10.0 &&

  reply	other threads:[~2016-08-31 17:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-31 17:48 [PATCH] checkpatch: Don't test for prefer ether_addr_<foo> Joe Perches
2016-08-31 17:57 ` Greg [this message]
2016-09-01 10:32 ` Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1472666275.3889.2.camel@gmail.com \
    --to=gvrose8192@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=apw@canonical.com \
    --cc=dan.carpenter@oracle.com \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox