public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: ezequiel.garcia@free-electrons.com ('Ezequiel Garcia')
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 1/4] ethernet: Add new driver for Marvell Armada 375 network unit
Date: Thu, 10 Jul 2014 14:07:16 -0300	[thread overview]
Message-ID: <20140710170716.GA17727@arch.cereza> (raw)
In-Reply-To: <063D6719AE5E284EB5DD2968C1650D6D172700F9@AcuExch.aculab.com>

On 10 Jul 03:26 PM, David Laight wrote:
> From: Ezequiel Garcia
> ...
> > > > +/* Compare tcam data bytes with a pattern */
> > > > +static bool mvpp2_prs_tcam_data_cmp(struct mvpp2_prs_entry *pe,
> > > > +				    unsigned int offs, unsigned int size,
> > > > +					   unsigned char *bytes)
> > > > +{
> > > > +	unsigned char byte, mask;
> > > > +	int i;
> 
> Hmm. should be 'unsigned int' for the comparison against 'size'.
> 

Right. I've reworked this entirely, because it was barely readable,
and now the size parameter is gone.

> > > > +
> > > > +	for (i = 0; i < size; i++) {
> > > > +		mvpp2_prs_tcam_data_byte_get(pe, offs + i, &byte, &mask);
> > > > +
> > > > +		if (byte != bytes[i])
> > > > +			return false;
> > >
> > > Please reduce the scope of "byte" and "mask".
> > >
> > 
> > Agreed. This applies on several other places, I'll fix them all.
> > 
> > > > +	}
> > > > +	return true;
> 
> Not sure about other people, but I prefer variables to be defined
> at the top of a function so that I can find them.
> Minimising the scope tends to make code harder to read.
> 
> If this was a big function, then reducing the scope of 'temporary'
> variables need for a few lines (like the above loop) can make sense
> because it reduces the clutter at the top of the function.
> 

Yeah, that makes sense. I'm fine either way; I'll be submitting v4 now
addressing most of Francois' feedback. Feel free to complain if you think
some function is not readable enough and can be improved.

Thanks for taking a look,
-- 
Ezequiel Garc?a, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com

      reply	other threads:[~2014-07-10 17:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-07 18:45 [PATCH v3 net-next 0/4] Network driver for Armada 375 SoC Ezequiel Garcia
2014-07-07 18:45 ` [PATCH v3 2/4] ARM: mvebu: Add support for the network controller in " Ezequiel Garcia
2014-07-07 18:45 ` [PATCH v3 3/4] ARM: mvebu: Enable the network controller in Armada 375 DB board Ezequiel Garcia
2014-07-07 18:45 ` [PATCH v3 4/4] ARM: mvebu: enable Armada 375 network driver in mvebu_v7_defconfig Ezequiel Garcia
     [not found] ` <1404758751-2346-2-git-send-email-ezequiel.garcia@free-electrons.com>
2014-07-07 22:18   ` [PATCH v3 1/4] ethernet: Add new driver for Marvell Armada 375 network unit Francois Romieu
2014-07-10 15:19     ` Ezequiel Garcia
2014-07-10 15:26       ` David Laight
2014-07-10 17:07         ` 'Ezequiel Garcia' [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=20140710170716.GA17727@arch.cereza \
    --to=ezequiel.garcia@free-electrons.com \
    --cc=linux-arm-kernel@lists.infradead.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