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

so that people don't use "auto" in it.

Both arguments are cast to specific types so it's OK to move them
to function arguments:

	s64 __x = (dividend);
	s32 __d = (divisor);

Delete useless () while I'm at it.

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

diff --git a/include/linux/math64.h b/include/linux/math64.h
index 3ab235c8a94c..7ecae251b0f4 100644
--- a/include/linux/math64.h
+++ b/include/linux/math64.h
@@ -335,21 +335,20 @@ static inline u64 DIV_U64_ROUND_CLOSEST(u64 dividend, u32 divisor)
 
 /**
  * DIV_S64_ROUND_CLOSEST - signed 64bit divide with 32bit divisor rounded to nearest integer
- * @dividend: signed 64bit dividend
- * @divisor: signed 32bit divisor
+ * @x: signed 64bit dividend
+ * @d: signed 32bit divisor
  *
  * Divide signed 64bit dividend by signed 32bit divisor
  * and round to closest integer.
  *
  * Return: dividend / divisor rounded to nearest integer
  */
-#define DIV_S64_ROUND_CLOSEST(dividend, divisor)(	\
-{							\
-	s64 __x = (dividend);				\
-	s32 __d = (divisor);				\
-	((__x > 0) == (__d > 0)) ?			\
-		div_s64((__x + (__d / 2)), __d) :	\
-		div_s64((__x - (__d / 2)), __d);	\
-}							\
-)
+static inline s64 DIV_S64_ROUND_CLOSEST(s64 x, s32 d)
+{
+	if ((x > 0) == (d > 0)) {
+		return div_s64(x + d / 2, d);
+	} else {
+		return div_s64(x - d / 2, d);
+	}
+}
 #endif /* _LINUX_MATH64_H */
-- 
2.40.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ