From: Miroslav Lichvar Date: Wed, 19 Mar 2014 16:38:34 +0000 (+0100) Subject: tempcomp: use macro to set maximum allowed compensation X-Git-Tag: 1.30-pre1~131 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0a56c0e8c19a8c3514b37cfc718876d221420f40;p=thirdparty%2Fchrony.git tempcomp: use macro to set maximum allowed compensation --- diff --git a/tempcomp.c b/tempcomp.c index 55bd0917..e4fefedf 100644 --- a/tempcomp.c +++ b/tempcomp.c @@ -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) {