From f9af2f97339e219d6cf3a26291f82047705aa529 Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Thu, 10 Feb 2022 15:24:25 +0100 Subject: [PATCH] sourcestats: clamp minsamples and maxsamples in initialization 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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sourcestats.c b/sourcestats.c index 0f2dedb..986956f 100644 --- a/sourcestats.c +++ b/sourcestats.c @@ -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;