[PATCH] netfilter: conntrack: Use max() instead of doing it manually

Subsystems: netfilter, networking [general], the rest

STALE1736d

2 messages, 2 authors, 2022-01-09 · open the first message on its own page

[PATCH] netfilter: conntrack: Use max() instead of doing it manually

From: Jiapeng Chong <hidden>
Date: 2021-12-25 17:12:57

Fix following coccicheck warning:

./include/net/netfilter/nf_conntrack.h:282:16-17: WARNING opportunity
for max().

Reported-by: Abaci Robot <redacted>
Signed-off-by: Jiapeng Chong <redacted>
---
 include/net/netfilter/nf_conntrack.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h
index 871489df63c6..a4a14f3a5e38 100644
--- a/include/net/netfilter/nf_conntrack.h
+++ b/include/net/netfilter/nf_conntrack.h
@@ -279,7 +279,7 @@ static inline unsigned long nf_ct_expires(const struct nf_conn *ct)
 {
 	s32 timeout = READ_ONCE(ct->timeout) - nfct_time_stamp;
 
-	return timeout > 0 ? timeout : 0;
+	return max(timeout, 0);
 }
 
 static inline bool nf_ct_is_expired(const struct nf_conn *ct)
-- 
2.20.1.7.g153144c

Re: [PATCH] netfilter: conntrack: Use max() instead of doing it manually

From: Pablo Neira Ayuso <pablo@netfilter.org>
Date: 2022-01-09 22:32:09

On Sun, Dec 26, 2021 at 01:12:41AM +0800, Jiapeng Chong wrote:
Fix following coccicheck warning:

./include/net/netfilter/nf_conntrack.h:282:16-17: WARNING opportunity
for max().
Applied to nf-next.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help