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]
Date:   Sun, 01 Apr 2018 21:42:09 +0100
From:   David Howells <dhowells@...hat.com>
To:     linux-kernel@...r.kernel.org
Subject: [PATCH 19/45] C++: Turn ktime_add/sub_ns() into inline template
 functions

Turn ktime ns arithmetic functions into template functions to handle the
nanosecond value type conversion correctly.

Signed-off-by: David Howells <dhowells@...hat.com>
---

 include/linux/ktime.h |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/include/linux/ktime.h b/include/linux/ktime.h
index 5b9fddbaac41..d46a16f23ffc 100644
--- a/include/linux/ktime.h
+++ b/include/linux/ktime.h
@@ -58,13 +58,21 @@ static inline ktime_t ktime_set(const s64 secs, const unsigned long nsecs)
  * Add a ktime_t variable and a scalar nanosecond value.
  * res = kt + nsval:
  */
-#define ktime_add_ns(kt, nsval)		((kt) + (nsval))
+template <typename NSVAL>
+static inline ktime_t ktime_add_ns(ktime_t kt, NSVAL nsval)
+{
+	return kt + nsval;
+}
 
 /*
  * Subtract a scalar nanosecod from a ktime_t variable
  * res = kt - nsval:
  */
-#define ktime_sub_ns(kt, nsval)		((kt) - (nsval))
+template <typename NSVAL>
+static inline ktime_t ktime_sub_ns(ktime_t kt, NSVAL nsval)
+{
+	return kt - nsval;
+}
 
 /* convert a timespec to ktime_t format: */
 static inline ktime_t timespec_to_ktime(struct timespec ts)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ