From: Vadim Fedorenko <vadim.fedorenko@linux.dev>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Colin Ian King <colin.i.king@gmail.com>,
Iyappan Subramanian <iyappan@os.amperecomputing.com>,
Keyur Chudgar <keyur@os.amperecomputing.com>,
Quan Nguyen <quan@os.amperecomputing.com>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
netdev@vger.kernel.org, kernel-janitors@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH][next] drivers: net: xgene: remove redundant assignment to variable offset
Date: Thu, 8 Feb 2024 10:07:27 -0500 [thread overview]
Message-ID: <1b4f32d0-a203-4c97-94e1-93ec40364c3c@linux.dev> (raw)
In-Reply-To: <4e0d27a6-37be-4b6e-a60e-508bcb0884cb@moroto.mountain>
On 08/02/2024 13:40, Dan Carpenter wrote:
> On Thu, Feb 08, 2024 at 12:39:24PM +0000, Vadim Fedorenko wrote:
>> On 08.02.2024 12:20, Colin Ian King wrote:
>>> The variable offset is being initialized with a value that is never
>>> read, it is being re-assigned later on in either path of an if
>>> statement before being used. The initialization is redundant and
>>> can be removed.
>>>
>>> Cleans up clang scan build warning:
>>> drivers/net/ethernet/apm/xgene/xgene_enet_cle.c:736:2: warning: Value
>>> stored to 'offset' is never read [deadcode.DeadStores]
>>>
>>> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
>>> ---
>>> drivers/net/ethernet/apm/xgene/xgene_enet_cle.c | 1 -
>>> 1 file changed, 1 deletion(-)
>>>
>>> diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_cle.c b/drivers/net/ethernet/apm/xgene/xgene_enet_cle.c
>>> index de5464322311..8f104642897b 100644
>>> --- a/drivers/net/ethernet/apm/xgene/xgene_enet_cle.c
>>> +++ b/drivers/net/ethernet/apm/xgene/xgene_enet_cle.c
>>> @@ -733,7 +733,6 @@ static int xgene_cle_setup_rss(struct xgene_enet_pdata *pdata)
>>> u32 offset, val = 0;
>>> int i, ret = 0;
>>> - offset = CLE_PORT_OFFSET;
>>> for (i = 0; i < cle->parsers; i++) {
>>> if (cle->active_parser != PARSER_ALL)
>>> offset = cle->active_parser * CLE_PORT_OFFSET;
>>
>> It looks like more refactoring can be done here.
>> "if (cle->active_parser != PARSER_ALL)" is static, no need to check it inside
>> the loop.
>>
>
> You still need to check... I don't really think it's an improvement.
>
> regards,
> dan carpenter
>
> diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_cle.c b/drivers/net/ethernet/apm/xgene/xgene_enet_cle.c
> index de5464322311..61e31cc55771 100644
> --- a/drivers/net/ethernet/apm/xgene/xgene_enet_cle.c
> +++ b/drivers/net/ethernet/apm/xgene/xgene_enet_cle.c
> @@ -733,11 +733,11 @@ static int xgene_cle_setup_rss(struct xgene_enet_pdata *pdata)
> u32 offset, val = 0;
> int i, ret = 0;
>
> - offset = CLE_PORT_OFFSET;
> + if (cle->active_parser != PARSER_ALL)
> + offset = cle->active_parser * CLE_PORT_OFFSET;
> +
I think we can add "else" here and avoid the loop in case of !=
PARSER_ALL and avoid "if" in the loop, wdyt?
> for (i = 0; i < cle->parsers; i++) {
> - if (cle->active_parser != PARSER_ALL)
> - offset = cle->active_parser * CLE_PORT_OFFSET;
> - else
> + if (cle->active_parser == PARSER_ALL)
> offset = i * CLE_PORT_OFFSET;
>
> /* enable RSS */
prev parent reply other threads:[~2024-02-08 15:07 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-08 12:20 [PATCH][next] drivers: net: xgene: remove redundant assignment to variable offset Colin Ian King
2024-02-08 12:39 ` Vadim Fedorenko
2024-02-08 13:40 ` Dan Carpenter
2024-02-08 15:07 ` Vadim Fedorenko [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=1b4f32d0-a203-4c97-94e1-93ec40364c3c@linux.dev \
--to=vadim.fedorenko@linux.dev \
--cc=colin.i.king@gmail.com \
--cc=dan.carpenter@linaro.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=iyappan@os.amperecomputing.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=keyur@os.amperecomputing.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=quan@os.amperecomputing.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