From: Miroslav Lichvar Date: Fri, 19 Aug 2016 15:58:30 +0000 (+0200) Subject: sourcestats: return success when loading dump file with no samples X-Git-Tag: 3.0-pre1~122 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=af664e6cece89d92ad4bef20b397615de622ee18;p=thirdparty%2Fchrony.git sourcestats: return success when loading dump file with no samples --- diff --git a/sourcestats.c b/sourcestats.c index 82fc5f5e..d8a69878 100644 --- a/sourcestats.c +++ b/sourcestats.c @@ -866,7 +866,7 @@ SST_LoadFromFile(SST_Stats inst, FILE *in) if (fgets(line, sizeof(line), in) && sscanf(line, "%d", &inst->n_samples) == 1 && - inst->n_samples > 0 && inst->n_samples <= MAX_SAMPLES) { + inst->n_samples >= 0 && inst->n_samples <= MAX_SAMPLES) { for (i=0; in_samples; i++) { if (!fgets(line, sizeof(line), in) || @@ -903,6 +903,9 @@ SST_LoadFromFile(SST_Stats inst, FILE *in) return 0; } + if (!inst->n_samples) + return 1; + inst->last_sample = inst->n_samples - 1; inst->runs_samples = 0;