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: <20230518154648.581643-5-adobriyan@gmail.com>
Date:   Thu, 18 May 2023 18:46:46 +0300
From:   Alexey Dobriyan <adobriyan@...il.com>
To:     akpm@...ux-foundation.org
Cc:     linux-kernel@...r.kernel.org, adobriyan@...il.com
Subject: [PATCH 5/8] auto: promote DIV64_U64_ROUND_CLOSEST macro to function

Same explanation as for DIV64_U64_ROUND_UP: div64_u64() wants "u64" in
the first argument so using anything wider in calculations before that
doesn't matter.

Signed-off-by: Alexey Dobriyan <adobriyan@...il.com>
---
 include/linux/math64.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/linux/math64.h b/include/linux/math64.h
index 7e0e2625dc35..d8770c8a9cff 100644
--- a/include/linux/math64.h
+++ b/include/linux/math64.h
@@ -313,8 +313,10 @@ static inline u64 DIV64_U64_ROUND_UP(u64 ll, u64 d)
  *
  * Return: dividend / divisor rounded to nearest integer
  */
-#define DIV64_U64_ROUND_CLOSEST(dividend, divisor)	\
-	({ u64 _tmp = (divisor); div64_u64((dividend) + _tmp / 2, _tmp); })
+static inline u64 DIV64_U64_ROUND_CLOSEST(u64 dividend, u64 divisor)
+{
+	return div64_u64(dividend + divisor / 2, divisor);
+}
 
 /**
  * DIV_U64_ROUND_CLOSEST - unsigned 64bit divide with 32bit divisor rounded to nearest integer
-- 
2.40.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ