Skip to contentSkip to conversation

net: ipa: remove the redundant assignment to variable trans_id

PATCH In review Colin Ian King 3 participants 4 messages Jan 16, 2024 – Jan 26, 2024

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: ipa: remove the redundant assignment to variable trans_id

The variable trans_id is being modulo'd by channel->tre_count and the value is being re-assigned back to trans_id even though the variable is not used after this operation. The assignment is redundant. Remove the assignment and just replace it with the modulo operator.

Cleans up clang scan build warning:
warning: Although the value stored to 'trans_id' is used in the enclosing expression, the value is never actually read from 'trans_id' [deadcode.DeadStores]

---
 drivers/net/ipa/gsi_trans.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ipa/gsi_trans.c +1 -1
index ee6fb00b71eb..f5dafc2f53ab 100644
@@ -247,7 +247,7 @@ struct gsi_trans *gsi_channel_trans_complete(struct gsi_channel *channel)
 			return NULL;
 	}
 
-	return &trans_info->trans[trans_id %= channel->tre_count];
+	return &trans_info->trans[trans_id % channel->tre_count];
 }
 
 /* Move a transaction from allocated to committed state */
Signature · 1 line
2.39.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Colin Ian King

The variable trans_id is being modulo'd by channel->tre_count and the value is being re-assigned back to trans_id even though the variable is not used after this operation. The assignment is redundant. Remove the assignment and just replace it with the modulo operator.

Quoted 6 lines

Cleans up clang scan build warning:
warning: Although the value stored to 'trans_id' is used in the enclosing expression, the value is never actually read from 'trans_id' [deadcode.DeadStores]

This looks good. I saw this before but hadn't gotten around to fixing it yet. Thank you!

Quoted 17 lines
---
  drivers/net/ipa/gsi_trans.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ipa/gsi_trans.c +1 -1
index ee6fb00b71eb..f5dafc2f53ab 100644
@@ -247,7 +247,7 @@ struct gsi_trans *gsi_channel_trans_complete(struct gsi_channel *channel)
  			return NULL;
  	}
 
-	return &trans_info->trans[trans_id %= channel->tre_count];
+	return &trans_info->trans[trans_id % channel->tre_count];
  }
 
  /* Move a transaction from allocated to committed state */
reviewer
#2 lore raw
In reply to Colin Ian King
Quoted 6 lines · Colin Ian King

The variable trans_id is being modulo'd by channel->tre_count and the value is being re-assigned back to trans_id even though the variable is not used after this operation. The assignment is redundant. Remove the assignment and just replace it with the modulo operator.

Quoted 6 lines

Cleans up clang scan build warning:
warning: Although the value stored to 'trans_id' is used in the enclosing expression, the value is never actually read from 'trans_id' [deadcode.DeadStores]

## Form letter - net-next-closed

[adapted from text by Jakub]

Hi Colin,

The merge window for v6.8 has begun and therefore net-next is closed for new drivers, features, code refactoring and optimizations. We are currently accepting bug fixes only.

Please repost when net-next reopens on or after 22nd January.

RFC patches sent for review only are obviously welcome at any time.

See: https://www.kernel.org/doc/html/next/process/maintainer-netdev.html#development-cycle
--
pw-bot: defer

#3 lore raw
Quoted 7 lines · Simon Horman
Quoted 6 lines · Colin Ian King

The variable trans_id is being modulo'd by channel->tre_count and the value is being re-assigned back to trans_id even though the variable is not used after this operation. The assignment is redundant. Remove the assignment and just replace it with the modulo operator.

Quoted 6 lines
Quoted 6 lines

Cleans up clang scan build warning:
warning: Although the value stored to 'trans_id' is used in the enclosing expression, the value is never actually read from 'trans_id' [deadcode.DeadStores]

Colin, net-next is open now and you are welcome to send v2 of this patch.
https://netdev.bots.linux.dev/net-next.html

-Alex

Quoted 18 lines

## Form letter - net-next-closed

[adapted from text by Jakub]

Hi Colin,

The merge window for v6.8 has begun and therefore net-next is closed for new drivers, features, code refactoring and optimizations. We are currently accepting bug fixes only.

Please repost when net-next reopens on or after 22nd January.

RFC patches sent for review only are obviously welcome at any time.

See: https://www.kernel.org/doc/html/next/process/maintainer-netdev.html#development-cycle
--
pw-bot: defer