netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Jεan Sacren" <sakiwit@gmail.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: Ariel Elior <aelior@marvell.com>,
	GR-everest-linux-l2@marvell.com, davem@davemloft.net,
	netdev@vger.kernel.org
Subject: Re: [PATCH net-next v2 2/2] net: qed_dev: fix redundant check of rc and against -EINVAL
Date: Sat, 23 Oct 2021 03:26:51 -0600	[thread overview]
Message-ID: <YXPVWzH/ecvMl/vP@mail.gmail.com> (raw)
In-Reply-To: <20211022144720.7d1d9eb6@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>

From: Jakub Kicinski <kuba@kernel.org>
Date: Fri, 22 Oct 2021 14:47:20 -0700
>
> On Thu, 21 Oct 2021 21:37:41 -0600 Jεan Sacren wrote:
> > From: Jean Sacren <sakiwit@gmail.com>
> > 
> > We should first check rc alone and then check it against -EINVAL to
> > avoid repeating the same operation multiple times.
> > 
> > We should also remove the check of !rc in this expression since it is
> > always true:
> > 
> > 	(!rc && !resc_lock_params.b_granted)
> > 
> > Signed-off-by: Jean Sacren <sakiwit@gmail.com>
> 
> The code seems to be written like this on purpose. You're adding
> indentation levels, and making the structure less readable IMO.
> 
> If you want to avoid checking rc / !rc multiple times you can just
> code it as:
> 
> 	if (rc == -EINVAL)
> 		...
> 	else if (rc)
> 		...
> 	else if (!granted)
> 		...
> 	else
> 		...
> 
> I'm not sure I see the point of the re-factoring.

Agreed.

  reply	other threads:[~2021-10-23  9:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-22  3:37 [PATCH net-next v2 0/2] Small fixes for redundant checks Jεan Sacren
2021-10-22  3:37 ` [PATCH net-next v2 2/2] net: qed_dev: fix redundant check of rc and against -EINVAL Jεan Sacren
2021-10-22 21:47   ` Jakub Kicinski
2021-10-23  9:26     ` Jεan Sacren [this message]
2021-10-22  3:37 ` [PATCH net-next v2 1/2] net: qed_ptp: " Jεan Sacren
2021-10-22  5:27   ` [EXT] " Prabhakar Kushwaha
  -- strict thread matches above, loose matches on Subject: below --
2021-10-22  5:28 [PATCH net-next v2 2/2] net: qed_dev: " Prabhakar Kushwaha

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=YXPVWzH/ecvMl/vP@mail.gmail.com \
    --to=sakiwit@gmail.com \
    --cc=GR-everest-linux-l2@marvell.com \
    --cc=aelior@marvell.com \
    --cc=davem@davemloft.net \
    --cc=kuba@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;
as well as URLs for NNTP newsgroup(s).