diff mbox series

[next] drivers: net: xgene: remove redundant assignment to variable offset

Message ID 20240208122012.2597561-1-colin.i.king@gmail.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [next] drivers: net: xgene: remove redundant assignment to variable offset | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1048 this patch: 1048
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 5 maintainers not CCed: morbo@google.com justinstitt@google.com nathan@kernel.org ndesaulniers@google.com llvm@lists.linux.dev
netdev/build_clang success Errors and warnings before: 1065 this patch: 1065
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1065 this patch: 1065
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 7 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-02-10--12-00 (tests: 1262)

Commit Message

Colin Ian King Feb. 8, 2024, 12:20 p.m. UTC
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(-)

Comments

Vadim Fedorenko Feb. 8, 2024, 12:39 p.m. UTC | #1
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.
Dan Carpenter Feb. 8, 2024, 1:40 p.m. UTC | #2
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;
+
 	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 */
Vadim Fedorenko Feb. 8, 2024, 3:07 p.m. UTC | #3
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 */
diff mbox series

Patch

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;