Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Petr Machata <petrm@nvidia.com>
Cc: Ido Schimmel <idosch@idosch.org>,
netdev@vger.kernel.org, davem@davemloft.net, kuba@kernel.org,
jiri@mellanox.com, mlxsw@mellanox.com,
Ido Schimmel <idosch@mellanox.com>
Subject: Re: [PATCH net-next 03/11] mlxsw: spectrum_policer: Add policer core
Date: Tue, 18 Aug 2020 07:10:04 -0500 [thread overview]
Message-ID: <20200818121004.GA1491413@bjorn-Precision-5520> (raw)
In-Reply-To: <87wo1we1li.fsf@nvidia.com>
On Tue, Aug 18, 2020 at 11:37:45AM +0200, Petr Machata wrote:
> Ido Schimmel <idosch@idosch.org> writes:
> > On Mon, Aug 17, 2020 at 10:38:24AM -0500, Bjorn Helgaas wrote:
> >> You've likely seen this already, but Coverity found this problem:
> >>
> >> *** CID 1466147: Control flow issues (DEADCODE)
> >> /drivers/net/ethernet/mellanox/mlxsw/spectrum_policer.c: 380 in mlxsw_sp_policers_init()
> >> 374 }
> >> 375
> >> 376 return 0;
> >> 377
> >> 378 err_family_register:
> >> 379 for (i--; i >= 0; i--) {
> >> >>> CID 1466147: Control flow issues (DEADCODE)
> >> >>> Execution cannot reach this statement: "struct mlxsw_sp_policer_fam...".
> >> 380 struct mlxsw_sp_policer_family *family;
> >> 381
> >> 382 family = mlxsw_sp->policer_core->family_arr[i];
> >> 383 mlxsw_sp_policer_family_unregister(mlxsw_sp, family);
> >> 384 }
> >> 385 err_init:
> >>
> >> I think the problem is that MLXSW_SP_POLICER_TYPE_MAX is 0 because
> >>
> >> > +enum mlxsw_sp_policer_type {
> >> > + MLXSW_SP_POLICER_TYPE_SINGLE_RATE,
> >> > +
> >> > + __MLXSW_SP_POLICER_TYPE_MAX,
> >> > + MLXSW_SP_POLICER_TYPE_MAX = __MLXSW_SP_POLICER_TYPE_MAX - 1,
> >> > +};
> >>
> >> so we can only execute the family_register loop once, with i == 0,
> >> and if we get to err_family_register via the error exit:
> >>
> >> > + for (i = 0; i < MLXSW_SP_POLICER_TYPE_MAX + 1; i++) {
> >> > + err = mlxsw_sp_policer_family_register(mlxsw_sp, mlxsw_sp_policer_family_arr[i]);
> >> > + if (err)
> >> > + goto err_family_register;
> >>
> >> i will be 0, so i-- sets i to -1, so we don't enter the
> >> family_unregister loop body since -1 is not >= 0.
> >
> > Thanks for the report, but isn't the code doing the right thing here? I
> > mean, it's dead code now, but as soon as we add another family it will
> > be executed. It seems error prone to remove it only to please Coverity
> > and then add it back when it's actually needed.
>
> Agreed.
You're right, I missed the forest for the trees. Sorry for the noise.
Bjorn
next prev parent reply other threads:[~2020-08-18 12:10 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-15 8:27 [PATCH net-next 00/11] mlxsw: Offload tc police action Ido Schimmel
2020-07-15 8:27 ` [PATCH net-next 01/11] mlxsw: reg: Add policer bandwidth limits Ido Schimmel
2020-07-15 8:27 ` [PATCH net-next 02/11] mlxsw: resources: Add resource identifier for global policers Ido Schimmel
2020-07-15 8:27 ` [PATCH net-next 03/11] mlxsw: spectrum_policer: Add policer core Ido Schimmel
2020-08-17 15:38 ` Bjorn Helgaas
2020-08-18 6:41 ` Ido Schimmel
2020-08-18 9:37 ` Petr Machata
2020-08-18 12:10 ` Bjorn Helgaas [this message]
2020-07-15 8:27 ` [PATCH net-next 04/11] mlxsw: spectrum_policer: Add devlink resource support Ido Schimmel
2020-07-15 8:27 ` [PATCH net-next 05/11] mlxsw: core_acl_flex_actions: Work around hardware limitation Ido Schimmel
2020-07-15 8:27 ` [PATCH net-next 06/11] mlxsw: core_acl_flex_actions: Add police action Ido Schimmel
2020-07-15 8:27 ` [PATCH net-next 07/11] mlxsw: spectrum_acl: Offload FLOW_ACTION_POLICE Ido Schimmel
2020-07-15 8:27 ` [PATCH net-next 08/11] selftests: forwarding: Add tc-police tests Ido Schimmel
2020-07-15 8:27 ` [PATCH net-next 09/11] selftests: mlxsw: tc_restrictions: Test tc-police restrictions Ido Schimmel
2020-07-15 8:27 ` [PATCH net-next 10/11] selftests: mlxsw: Add scale test for tc-police Ido Schimmel
2020-07-15 8:27 ` [PATCH net-next 11/11] selftests: mlxsw: Test policers' occupancy Ido Schimmel
2020-07-16 1:13 ` [PATCH net-next 00/11] mlxsw: Offload tc police action 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=20200818121004.GA1491413@bjorn-Precision-5520 \
--to=helgaas@kernel.org \
--cc=davem@davemloft.net \
--cc=idosch@idosch.org \
--cc=idosch@mellanox.com \
--cc=jiri@mellanox.com \
--cc=kuba@kernel.org \
--cc=mlxsw@mellanox.com \
--cc=netdev@vger.kernel.org \
--cc=petrm@nvidia.com \
--subject='Re: [PATCH net-next 03/11] mlxsw: spectrum_policer: Add policer core' \
/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
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).