lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240824074033.2134514-6-lihongbo22@huawei.com>
Date: Sat, 24 Aug 2024 15:40:30 +0800
From: Hongbo Li <lihongbo22@...wei.com>
To: <johannes@...solutions.net>, <davem@...emloft.net>, <edumazet@...gle.com>,
	<kuba@...nel.org>, <pabeni@...hat.com>, <allison.henderson@...cle.com>,
	<dsahern@...nel.org>, <pshelar@....org>
CC: <linux-wireless@...r.kernel.org>, <netdev@...r.kernel.org>,
	<rds-devel@....oracle.com>, <dccp@...r.kernel.org>, <dev@...nvswitch.org>,
	<linux-afs@...ts.infradead.org>, <lihongbo22@...wei.com>
Subject: [PATCH net-next 5/8] net/dccp: Use min()/max() to simplify the code

Let's use min()/max() to simplify the code and fix the
Coccinelle/coccicheck warning reported by minmax.cocci.

Signed-off-by: Hongbo Li <lihongbo22@...wei.com>
---
 net/dccp/ackvec.c | 2 +-
 net/dccp/dccp.h   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/dccp/ackvec.c b/net/dccp/ackvec.c
index 1cba001bb4c8..faadd0190107 100644
--- a/net/dccp/ackvec.c
+++ b/net/dccp/ackvec.c
@@ -305,7 +305,7 @@ void dccp_ackvec_clear_state(struct dccp_ackvec *av, const u64 ackno)
 	 * Deal with overlapping Ack Vectors: don't subtract more than the
 	 * number of packets between tail_ackno and ack_ackno.
 	 */
-	eff_runlen = delta < avr->avr_ack_runlen ? delta : avr->avr_ack_runlen;
+	eff_runlen = min(delta, avr->avr_ack_runlen);
 
 	runlen_now = dccp_ackvec_runlen(av->av_buf + avr->avr_ack_ptr);
 	/*
diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h
index 1f748ed1279d..872d17fb85b5 100644
--- a/net/dccp/dccp.h
+++ b/net/dccp/dccp.h
@@ -149,7 +149,7 @@ static inline u64 dccp_loss_count(const u64 s1, const u64 s2, const u64 ndp)
 	WARN_ON(delta < 0);
 	delta -= ndp + 1;
 
-	return delta > 0 ? delta : 0;
+	return max(delta, 0);
 }
 
 /**
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ