Intel-Wired-Lan Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Alan Brady <alan.brady@intel.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: willemdebruijn.kernel@gmail.com, netdev@vger.kernel.org,
	aleksander.lobakin@intel.com, intel-wired-lan@lists.osuosl.org,
	przemyslaw.kitszel@intel.com, igor.bagnucki@intel.com
Subject: Re: [Intel-wired-lan] [PATCH v4 00/10 iwl-next] idpf: refactor virtchnl messages
Date: Tue, 6 Feb 2024 11:18:48 -0800	[thread overview]
Message-ID: <d93d8608-be23-401a-b163-da7ce4dc476f@intel.com> (raw)
In-Reply-To: <20240206105737.50149937@kernel.org>

On 2/6/2024 10:57 AM, Jakub Kicinski wrote:
> On Mon,  5 Feb 2024 19:37:54 -0800 Alan Brady wrote:
>> The motivation for this series has two primary goals. We want to enable
>> support of multiple simultaneous messages and make the channel more
>> robust. The way it works right now, the driver can only send and receive
>> a single message at a time and if something goes really wrong, it can
>> lead to data corruption and strange bugs.
> 
> Coccinelle points out some potential places to use min()
> 
> testing/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c:1956:17-18: WARNING opportunity for min()
> testing/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c:1271:17-18: WARNING opportunity for min()
> testing/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c:1319:17-18: WARNING opportunity for min()
> testing/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c:2640:17-18: WARNING opportunity for min()
> testing/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c:1295:17-18: WARNING opportunity for min()
> testing/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c:2157:17-18: WARNING opportunity for min()
> testing/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c:3582:17-18: WARNING opportunity for min()

We did run coccinelle check and see the min suggestions. It's triggering 
on these statements I added:

return reply_sz < 0 ? reply_sz : 0;

A min here would change it to:

return min(reply_sz, 0);

I didn't really like that because it's misleading as though we're 
returning the size of the reply and might accidentally encourage someone 
to change it to a max. Here reply_sz will be negative if an error was 
returned from message sending. But this function we only want to return 
0 or negative. By being explicit in what we want to do, it seems clearer 
to me what the intention is but I could be wrong.

We can definitely change it however if that's preferred here.

  reply	other threads:[~2024-02-06 19:19 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-06  3:37 [Intel-wired-lan] [PATCH v4 00/10 iwl-next] idpf: refactor virtchnl messages Alan Brady
2024-02-06  3:37 ` [Intel-wired-lan] [PATCH v4 01/10 iwl-next] idpf: implement virtchnl transaction manager Alan Brady
2024-02-20 14:30   ` Alexander Lobakin
2024-02-20 16:23     ` Alan Brady
2024-02-06  3:37 ` [Intel-wired-lan] [PATCH v4 02/10 iwl-next] idpf: refactor vport virtchnl messages Alan Brady
2024-02-06  3:37 ` [Intel-wired-lan] [PATCH v4 03/10 iwl-next] idpf: refactor queue related " Alan Brady
2024-02-06  3:37 ` [Intel-wired-lan] [PATCH v4 04/10 iwl-next] idpf: refactor remaining " Alan Brady
2024-02-06  3:37 ` [Intel-wired-lan] [PATCH v4 05/10 iwl-next] idpf: add async_handler for MAC filter messages Alan Brady
2024-02-06  3:38 ` [Intel-wired-lan] [PATCH v4 06/10 iwl-next] idpf: refactor idpf_recv_mb_msg Alan Brady
2024-02-06  3:38 ` [Intel-wired-lan] [PATCH v4 07/10 iwl-next] idpf: cleanup virtchnl cruft Alan Brady
2024-02-06  3:38 ` [Intel-wired-lan] [PATCH v4 08/10 iwl-next] idpf: prevent deinit uninitialized virtchnl core Alan Brady
2024-02-06  3:38 ` [Intel-wired-lan] [PATCH v4 09/10 iwl-next] idpf: fix minor controlq issues Alan Brady
2024-02-06  3:38 ` [Intel-wired-lan] [PATCH v4 10/10 iwl-next] idpf: remove dealloc vector msg err in idpf_intr_rel Alan Brady
2024-02-06 17:02 ` [Intel-wired-lan] [PATCH v4 00/10 iwl-next] idpf: refactor virtchnl messages Alexander Lobakin
2024-02-14 14:49   ` Alexander Lobakin
2024-02-14 17:06     ` Alan Brady
2024-02-20 13:47     ` Alexander Lobakin
2024-02-06 18:57 ` Jakub Kicinski
2024-02-06 19:18   ` Alan Brady [this message]
2024-02-06 20:03     ` Jakub Kicinski
2024-02-06 22:50       ` Keller, Jacob E
2024-02-06 23:17         ` Jakub Kicinski

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=d93d8608-be23-401a-b163-da7ce4dc476f@intel.com \
    --to=alan.brady@intel.com \
    --cc=aleksander.lobakin@intel.com \
    --cc=igor.bagnucki@intel.com \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=przemyslaw.kitszel@intel.com \
    --cc=willemdebruijn.kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox