🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
2 messages
2 total messages Started by Chelsy Ratnawat Fri, 16 Oct 2026 06:50
[PATCH v2] net/rxrpc: Simplify rxrpcpeerseq_next()
#3867
Author: Chelsy Ratnawat
Date: Fri, 16 Oct 2026 06:50
50 lines
9217 bytes
Remove the redundant initialization and conditional handling of n,
as it is always set to 1. Use the constant directly when updating
*_pos and starting the hlist iteration.

Signed-off-by: Chelsy Ratnawat <chelsyratnawat2001@gmail.com>
---
Changes in v2: 
 - Remove n, as it is triggering unused variable warning.

 net/rxrpc/proc.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/net/rxrpc/proc.c b/net/rxrpc/proc.c
index e9a27fa7b25d..5b780fc3f289 100644
--- a/net/rxrpc/proc.c
+++ b/net/rxrpc/proc.c
@@ -352,7 +352,7 @@ static void *rxrpc_peer_seq_start(struct seq_file *seq, loff_t *_pos)
 static void *rxrpc_peer_seq_next(struct seq_file *seq, void *v, loff_t *_pos)
 {
 	struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq));
-	unsigned int bucket, n;
+	unsigned int bucket;
 	unsigned int shift = 32 - HASH_BITS(rxnet->peer_hash);
 	void *p;
 
@@ -367,19 +367,14 @@ static void *rxrpc_peer_seq_next(struct seq_file *seq, void *v, loff_t *_pos)
 
 	for (;;) {
 		bucket++;
-		n = 1;
-		*_pos = (bucket << shift) | n;
+		*_pos = (bucket << shift) | 1;
 
 		if (bucket >= HASH_SIZE(rxnet->peer_hash)) {
 			*_pos = UINT_MAX;
 			return NULL;
 		}
-		if (n == 0) {
-			*_pos += 1;
-			n++;
-		}
 
-		p = seq_hlist_start_rcu(&rxnet->peer_hash[bucket], n - 1);
+		p = seq_hlist_start_rcu(&rxnet->peer_hash[bucket], 0);
 		if (p)
 			return p;
 	}
-- 
2.53.0
Re: [PATCH v2] net/rxrpc: Simplify rxrpcpeerseq_next()
#6036
Author: Simon Horman
Date: Wed, 21 Oct 2026 14:48
12 lines
8098 bytes
On Thu, Oct 15, 2026 at 11:50:11PM -0700, Chelsy Ratnawat wrote:
> Remove the redundant initialization and conditional handling of n,
> as it is always set to 1. Use the constant directly when updating
> *_pos and starting the hlist iteration.
> 
> Signed-off-by: Chelsy Ratnawat <chelsyratnawat2001@gmail.com>

It might be nice to use some #define rather than the magic values 0 and 1.
But as a clean-up I think there is value in this as makes the logic clearer.

Reviewed-by: Simon Horman <horms@kernel.org>
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads