public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Suraj Upadhyay <usuraj35@gmail.com>
To: Joe Perches <joe@perches.com>
Cc: Dan Carpenter <dan.carpenter@oracle.com>,
	GR-Linux-NIC-Dev@marvell.com, gregkh@linuxfoundation.org,
	devel@driverdev.osuosl.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 6/6] staging: qlge: qlge_ethtool: Remove one byte memset.
Date: Wed, 15 Jul 2020 01:24:56 +0530	[thread overview]
Message-ID: <20200714195456.GB14742@blackclown> (raw)
In-Reply-To: <ce637b26b496dd99be8f272e6ec82333338321dc.camel@perches.com>

[-- Attachment #1: Type: text/plain, Size: 3559 bytes --]

On Tue, Jul 14, 2020 at 12:22:05PM -0700, Joe Perches wrote:
> On Wed, 2020-07-15 at 00:36 +0530, Suraj Upadhyay wrote:
> > On Tue, Jul 14, 2020 at 11:57:23AM -0700, Joe Perches wrote:
> > > On Mon, 2020-07-13 at 17:17 +0300, Dan Carpenter wrote:
> > > > On Mon, Jul 13, 2020 at 05:52:22PM +0530, Suraj Upadhyay wrote:
> > > > > Use direct assignment instead of using memset with just one byte as an
> > > > > argument.
> > > > > Issue found by checkpatch.pl.
> > > > > 
> > > > > Signed-off-by: Suraj Upadhyay <usuraj35@gmail.com>
> > > > > ---
> > > > > Hii Maintainers,
> > > > > 	Please correct me if I am wrong here.
> > > > > ---
> > > > > 
> > > > >  drivers/staging/qlge/qlge_ethtool.c | 4 ++--
> > > > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > > > > 
> > > > > diff --git a/drivers/staging/qlge/qlge_ethtool.c b/drivers/staging/qlge/qlge_ethtool.c
> > > > > index 16fcdefa9687..d44b2dae9213 100644
> > > > > --- a/drivers/staging/qlge/qlge_ethtool.c
> > > > > +++ b/drivers/staging/qlge/qlge_ethtool.c
> > > > > @@ -516,8 +516,8 @@ static void ql_create_lb_frame(struct sk_buff *skb,
> > > > >  	memset(skb->data, 0xFF, frame_size);
> > > > >  	frame_size &= ~1;
> > > > >  	memset(&skb->data[frame_size / 2], 0xAA, frame_size / 2 - 1);
> > > > > -	memset(&skb->data[frame_size / 2 + 10], 0xBE, 1);
> > > > > -	memset(&skb->data[frame_size / 2 + 12], 0xAF, 1);
> > > > > +	skb->data[frame_size / 2 + 10] = (unsigned char)0xBE;
> > > > > +	skb->data[frame_size / 2 + 12] = (unsigned char)0xAF;
> > > > 
> > > > Remove the casting.
> > > > 
> > > > I guess this is better than the original because now it looks like
> > > > ql_check_lb_frame().  It's still really weird looking though.
> > > 
> > > There are several of these in the intel drivers too:
> > > 
> > > drivers/net/ethernet/intel/e1000/e1000_ethtool.c:       memset(&skb->data[frame_size / 2 + 10], 0xBE, 1);
> > > drivers/net/ethernet/intel/e1000/e1000_ethtool.c:       memset(&skb->data[frame_size / 2 + 12], 0xAF, 1);
> > > drivers/net/ethernet/intel/e1000e/ethtool.c:    memset(&skb->data[frame_size / 2 + 10], 0xBE, 1);
> > > drivers/net/ethernet/intel/e1000e/ethtool.c:    memset(&skb->data[frame_size / 2 + 12], 0xAF, 1);
> > > drivers/net/ethernet/intel/igb/igb_ethtool.c:   memset(&skb->data[frame_size + 10], 0xBE, 1);
> > > drivers/net/ethernet/intel/igb/igb_ethtool.c:   memset(&skb->data[frame_size + 12], 0xAF, 1);
> > > drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c:       memset(&skb->data[frame_size + 10], 0xBE, 1);
> > > drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c:       memset(&skb->data[frame_size + 12], 0xAF, 1);
> > > drivers/staging/qlge/qlge_ethtool.c:    memset(&skb->data[frame_size / 2 + 10], 0xBE, 1);
> > > drivers/staging/qlge/qlge_ethtool.c:    memset(&skb->data[frame_size / 2 + 12], 0xAF, 1);
> > 
> > Thanks to point this out,
> > 	I will be sending a patchset for that soon.
> 
> 
> It _might_ be useful to create and use a standard
> mechanism for the loopback functions:
> 
> 	<foo>create_lbtest_frame
> and
> 	<foo>check_lbtest_frame
> 
> Maybe use something like:
> 
> 	ether_loopback_frame_create
> and
> 	ether_loopback_frame_check
> 
I thought about it  but then again the fram_size is sometimes divided by two

e.g. `frame_size /= 2;` or `frame_size >>= 1;`.

and sometimes it is subtracted by one. i.e. `frame_size &= ~1;`.

Anyway, I sent my layman patchset to the lkml and intel maintainers.

Forgive my brevity.

Thanks, 

Suraj Upadhyay. 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

      reply	other threads:[~2020-07-14 19:55 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-13 12:14 [PATCH 0/6] staging: qlge: General cleanup and refactor Suraj Upadhyay
2020-07-13 12:15 ` [PATCH 1/6] staging: qlge: qlge.h: Function definition arguments should have names Suraj Upadhyay
2020-07-13 12:15 ` [PATCH 2/6] staging: qlge: qlge.h: Insert line after declaration Suraj Upadhyay
2020-07-13 12:16 ` [PATCH 3/6] staging: qlge: qlge_dbg: Simplify while statements Suraj Upadhyay
2020-07-13 12:20 ` [PATCH 4/6] staging: qlge: qlge_main: " Suraj Upadhyay
2020-07-13 13:38   ` Greg KH
2020-07-13 14:12   ` Dan Carpenter
2020-07-14  5:41   ` Benjamin Poirier
2020-07-13 12:21 ` [PATCH 5/6] staging: qlge: qlge_mpi: " Suraj Upadhyay
2020-07-13 12:22 ` [PATCH 6/6] staging: qlge: qlge_ethtool: Remove one byte memset Suraj Upadhyay
2020-07-13 14:17   ` Dan Carpenter
2020-07-14 18:57     ` Joe Perches
2020-07-14 19:06       ` Suraj Upadhyay
2020-07-14 19:22         ` Joe Perches
2020-07-14 19:54           ` Suraj Upadhyay [this message]

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=20200714195456.GB14742@blackclown \
    --to=usuraj35@gmail.com \
    --cc=GR-Linux-NIC-Dev@marvell.com \
    --cc=dan.carpenter@oracle.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@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