public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Lennart Franzen <lennart@lfdomain.com>,
	Alexandru Tachici <alexandru.tachici@analog.com>,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
	netdev@vger.kernel.org
Subject: Re: [PATCH net] net: ethernet: adi: adin1110: Fix some error handling path in adin1110_read_fifo()
Date: Fri, 4 Oct 2024 14:47:22 +0300	[thread overview]
Message-ID: <63dbd539-2f94-4b68-ab4e-c49e7b9d2ddd@stanley.mountain> (raw)
In-Reply-To: <8ff73b40f50d8fa994a454911b66adebce8da266.1727981562.git.christophe.jaillet@wanadoo.fr>

On Thu, Oct 03, 2024 at 08:53:15PM +0200, Christophe JAILLET wrote:
> If 'frame_size' is too small or if 'round_len' is an error code, it is
> likely that an error code should be returned to the caller.
> 
> Actually, 'ret' is likely to be 0, so if one of these sanity checks fails,
> 'success' is returned.
> 
> Return -EINVAL instead.
> 
> Fixes: bc93e19d088b ("net: ethernet: adi: Add ADIN1110 support")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> This patch is speculative.
> If returning 0 is what was intended, then an explicit 0 would be better.

I have an unpublished Smatch warning for these:

drivers/net/ethernet/adi/adin1110.c:321 adin1110_read_fifo() info: returning a literal zero is cleaner
drivers/net/ethernet/adi/adin1110.c:325 adin1110_read_fifo() info: returning a literal zero is cleaner

It's a pity that deliberately doing a "return ret;" when ret is zero is so
common.  Someone explained to me that it was "done deliberately to express that
we were propagating the success from frob_whatever()".  No no no!

I don't review these warnings unless I'm fixing a bug in the driver because
they're too common.  The only ones I review are:

	ret = frob();
	if (!ret)
		return ret;

Maybe 20% of the time those warnings indicate a reversed if statement.

Your heuristic here is very clever and I'll try steal it to create a new more
specific warning.

regards,
dan carpenter


  parent reply	other threads:[~2024-10-04 11:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-03 18:53 [PATCH net] net: ethernet: adi: adin1110: Fix some error handling path in adin1110_read_fifo() Christophe JAILLET
2024-10-04 11:37 ` Simon Horman
2024-10-04 13:15   ` Christophe JAILLET
2024-10-07 15:45     ` Simon Horman
2024-10-04 11:47 ` Dan Carpenter [this message]
2024-10-04 13:27   ` Christophe JAILLET
2024-10-04 18:09   ` Jakub Kicinski
2024-10-07 15:46     ` Simon Horman
2024-10-07 17:35       ` Julia Lawall
2024-10-08  0:10 ` patchwork-bot+netdevbpf

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=63dbd539-2f94-4b68-ab4e-c49e7b9d2ddd@stanley.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=alexandru.tachici@analog.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kuba@kernel.org \
    --cc=lennart@lfdomain.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox