]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
tempcomp: use macro to set maximum allowed compensation
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 19 Mar 2014 16:38:34 +0000 (17:38 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Fri, 21 Mar 2014 12:20:24 +0000 (13:20 +0100)
tempcomp.c

index 55bd0917cded047ac445bda0146afd197b589c21..e4fefedf4b3c3588197f7d01ad89fc6f603198b4 100644 (file)
@@ -35,6 +35,9 @@
 #include "sched.h"
 #include "tempcomp.h"
 
+/* Sanity limit (in ppm) */
+#define MAX_COMP 10.0
+
 static SCH_TimeoutID timeout_id;
 
 static LOG_FileID logfileid;
@@ -54,8 +57,7 @@ read_timeout(void *arg)
   if (f && fscanf(f, "%lf", &temp) == 1) {
     comp = k0 + (temp - T0) * k1 + (temp - T0) * (temp - T0) * k2;
 
-    /* Don't allow corrections above 10 ppm */
-    if (fabs(comp) < 10.0) {
+    if (fabs(comp) <= MAX_COMP) {
       comp = LCL_SetTempComp(comp);
 
       if (logfileid != -1) {