]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
sourcestats: clamp minsamples and maxsamples in initialization
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 10 Feb 2022 14:24:25 +0000 (15:24 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 10 Feb 2022 15:31:46 +0000 (16:31 +0100)
Don't leave the variables set to values outside their effective range.
This has no functional impact, but makes it clear what is the precedence
of the two settings.

sourcestats.c

index 0f2dedb816ab952fd85d2a92c843ac4962ce305a..986956f84a6be0fda764ceb53b2b99977e49eb9e 100644 (file)
@@ -211,8 +211,8 @@ SST_CreateInstance(uint32_t refid, IPAddr *addr, int min_samples, int max_sample
   SST_Stats inst;
   inst = MallocNew(struct SST_Stats_Record);
 
-  inst->min_samples = min_samples;
-  inst->max_samples = max_samples;
+  inst->max_samples = max_samples > 0 ? CLAMP(1, max_samples, MAX_SAMPLES) : MAX_SAMPLES;
+  inst->min_samples = CLAMP(1, min_samples, inst->max_samples);
   inst->fixed_min_delay = min_delay;
   inst->fixed_asymmetry = asymmetry;