]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
sourcestats: return success when loading dump file with no samples
authorMiroslav Lichvar <mlichvar@redhat.com>
Fri, 19 Aug 2016 15:58:30 +0000 (17:58 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Mon, 22 Aug 2016 13:05:48 +0000 (15:05 +0200)
sourcestats.c

index 82fc5f5eb81e43f7ee1a309adbf6c67551536510..d8a6987837de27de3d9a13a8c4b180e3643d5fdc 100644 (file)
@@ -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; i<inst->n_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;