Re: [PATCH net-next 4/8] libceph: use min() to simplify the code

From
Simon Horman <horms@kernel.org>
Date
2024-08-24 18:12:18
Also in
ceph-devel, linux-bluetooth, linux-nfs
Reply to
Li Zetao, 2024-08-22
On Thu, Aug 22, 2024 at 09:39:04PM +0800, Li Zetao wrote:
quoted hunk ↗ jump to hunk
When resolving name in ceph_dns_resolve_name(), the end address of name
is determined by the minimum value of delim_p and colon_p. So using min()
here is more in line with the context.

Signed-off-by: Li Zetao <redacted>
---
 net/ceph/messenger.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 3c8b78d9c4d1..d1b5705dc0c6 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -1254,7 +1254,7 @@ static int ceph_dns_resolve_name(const char *name, size_t namelen,
 	colon_p = memchr(name, ':', namelen);
 
 	if (delim_p && colon_p)
-		end = delim_p < colon_p ? delim_p : colon_p;
+		end = min(delim_p, colon_p);
Both delim_p, and colon_p are char *, so this seems correct to me.

And the code being replaced does appear to be a min() operation in
both form and function.

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

However, I don't believe libceph changes usually don't go through next-next.
So I think this either needs to be reposted or get some acks from
one of the maintainers.

Ilya, Xiubo, perhaps you can offer some guidance here?
 	else if (!delim_p && colon_p)
 		end = colon_p;
 	else {
-- 
2.34.1
Thread (25 messages) 25 messages, 9 authors, last reply 2024-09-12
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help