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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1487169069-15721-2-git-send-email-immortalguardian1@gmail.com>
Date:   Wed, 15 Feb 2017 17:31:02 +0300
From:   Andrey Drobyshev <immortalguardian1@...il.com>
To:     linux-kernel@...r.kernel.org
Cc:     gq@...msu.su, giometti@...eenne.com
Subject: [PATCH 1/8] hardpps: simple fixes replacing clumsy code with abs() macro.

From: Alexander GQ Gerasiov <gq@...msu.su>

Here are some trivial fixes, including:
  * simplify comparisons by using abs() macro
  * remove unnecessary variables
  * remove duplicate headers
  * fix typos

Signed-off-by: Alexander GQ Gerasiov <gq@...msu.su>
---
 kernel/time/ntp.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
index edf19cc..d20891e 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -16,7 +16,6 @@
 #include <linux/mm.h>
 #include <linux/module.h>
 #include <linux/rtc.h>
-#include <linux/math64.h>
 
 #include "ntp_internal.h"
 #include "timekeeping_internal.h"
@@ -874,7 +873,7 @@ static inline void pps_inc_freq_interval(void)
  */
 static long hardpps_update_freq(struct pps_normtime freq_norm)
 {
-	long delta, delta_mod;
+	long delta;
 	s64 ftemp;
 
 	/* check if the frequency interval was too long */
@@ -896,7 +895,7 @@ static long hardpps_update_freq(struct pps_normtime freq_norm)
 			freq_norm.sec);
 	delta = shift_right(ftemp - pps_freq, NTP_SCALE_SHIFT);
 	pps_freq = ftemp;
-	if (delta > PPS_MAXWANDER || delta < -PPS_MAXWANDER) {
+	if (abs(delta) > PPS_MAXWANDER) {
 		printk_deferred(KERN_WARNING
 				"hardpps: PPSWANDER: change=%ld\n", delta);
 		time_status |= STA_PPSWANDER;
@@ -910,10 +909,7 @@ static long hardpps_update_freq(struct pps_normtime freq_norm)
 	 * frequency changes, but is used only for performance
 	 * monitoring
 	 */
-	delta_mod = delta;
-	if (delta_mod < 0)
-		delta_mod = -delta_mod;
-	pps_stabil += (div_s64(((s64)delta_mod) <<
+	pps_stabil += (div_s64(((s64)abs(delta)) <<
 				(NTP_SCALE_SHIFT - SHIFT_USEC),
 				NSEC_PER_USEC) - pps_stabil) >> PPS_INTMIN;
 
@@ -994,10 +990,8 @@ void __hardpps(const struct timespec64 *phase_ts, const struct timespec64 *raw_t
 	freq_norm = pps_normalize_ts(timespec64_sub(*raw_ts, pps_fbase));
 
 	/* check that the signal is in the range
-	 * [1s - MAXFREQ us, 1s + MAXFREQ us], otherwise reject it */
-	if ((freq_norm.sec == 0) ||
-			(freq_norm.nsec > MAXFREQ * freq_norm.sec) ||
-			(freq_norm.nsec < -MAXFREQ * freq_norm.sec)) {
+	 * [1s - MAXFREQ ns, 1s + MAXFREQ ns], otherwise reject it */
+	if (abs(freq_norm.nsec) > MAXFREQ * freq_norm.sec) {
 		time_status |= STA_PPSJITTER;
 		/* restart the frequency calibration interval */
 		pps_fbase = *raw_ts;
-- 
2.1.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ