All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alison Schofield <amsfield22@gmail.com>
To: Julia Lawall <julia.lawall@lip6.fr>,
	Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Cc: outreachy-kernel@googlegroups.com
Subject: Re: [Outreachy kernel] [PATCH] staging: gdmwm: move constant to right side of comparison test
Date: Sat, 10 Oct 2015 23:37:08 -0700	[thread overview]
Message-ID: <20151011063707.GA6423@Ubuntu-D830> (raw)
In-Reply-To: <alpine.DEB.2.02.1510100921000.2062@localhost6.localdomain6>

On Sat, Oct 10, 2015 at 09:22:27AM +0200, Julia Lawall wrote:
> On Sat, 10 Oct 2015, Sudip Mukherjee wrote:
> 
> > On Thu, Oct 08, 2015 at 11:13:23PM -0700, Alison Schofield wrote:
> > > Move constant to right side of comparison test per checkpatch.pl:
> > > WARNING: Comparisons should place the constant on the right side of the
> > > test
> > > 
> > > Signed-off-by: Alison Schofield <amsfield22@gmail.com>
> > > ---
> > >  drivers/staging/gdm72xx/gdm_wimax.c | 4 ++--
> > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/drivers/staging/gdm72xx/gdm_wimax.c b/drivers/staging/gdm72xx/gdm_wimax.c
> > > index 6e8dbaf..69f00cc 100644
> > > --- a/drivers/staging/gdm72xx/gdm_wimax.c
> > > +++ b/drivers/staging/gdm72xx/gdm_wimax.c
> > > @@ -581,8 +581,8 @@ static int gdm_wimax_get_prepared_info(struct net_device *dev, char *buf,
> > >  		}
> > >  
> > >  		pos += gdm_wimax_hci_get_tlv(&buf[pos], &T, &L, &V);
> > > -		if (T == TLV_T(T_MAC_ADDRESS)) {
> > > -			if (L != dev->addr_len) {
> > > +		if (TLV_T(T_MAC_ADDRESS) == T) {
> > 
> > Is it correct? T and L are variables which are getting its values from
> > gdm_wimax_hci_get_tlv(). TLV_T is a macro which is ((x) & 0xff).
> > 
> > Do we use it like:
> > 
> > if ((T_MAC_ADDRESS & 0xff) == T)
> > 
> > or do we use like:
> > 
> > if (T == (T_MAC_ADDRESS & 0xff))
> 
> I'm not sure there is such a semantic intent to the rule.  Do something 
> complex and then see if it is like T, looks better to me than see if T is 
> like doing something complex.  The checkpatch/commit message is indeed 
> misleading, but the layout of characters looks better.
> 
> julia

Let me see if I have the correct understanding.

T and L are variables, not constants, therefore the checkpatch error and
my subsequent commit msg are misleading.  Regardless of whether this
case should have been flagged by checkpatch the edit improves
readability.

So, I'd lean towards keeping the edit and changing the commit msg & description like this:

	staging: gdmwm: move variable to right side of comparison test
    
	Move variables to right side of comparison test to improve readability.
		
Your thoughts?

alison



  reply	other threads:[~2015-10-11  6:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-09  6:13 [PATCH] staging: gdmwm: move constant to right side of comparison test Alison Schofield
2015-10-10  7:00 ` [Outreachy kernel] " Sudip Mukherjee
2015-10-10  7:22   ` Julia Lawall
2015-10-11  6:37     ` Alison Schofield [this message]
2015-10-11 10:04       ` Julia Lawall
2015-10-12  9:43         ` Sudip Mukherjee
2015-10-12 20:53 ` [PATCH v2] staging: gdmwm: move variables " Alison Schofield

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=20151011063707.GA6423@Ubuntu-D830 \
    --to=amsfield22@gmail.com \
    --cc=julia.lawall@lip6.fr \
    --cc=outreachy-kernel@googlegroups.com \
    --cc=sudipm.mukherjee@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.