mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-03 15:55:07 -05:00
sourcestats: change ST_GetSelectionData() to return status directly
For better consistency, indicate success (usable data) by returning 1 instead of setting a pointer parameter.
This commit is contained in:
@@ -1010,10 +1010,10 @@ SRC_SelectSource(SRC_Instance updated_inst)
|
||||
n_unreach_sources++;
|
||||
|
||||
si = &sources[i]->sel_info;
|
||||
SST_GetSelectionData(sources[i]->stats, &now,
|
||||
si->select_ok = SST_GetSelectionData(sources[i]->stats, &now,
|
||||
&si->lo_limit, &si->hi_limit, &si->root_distance,
|
||||
&si->std_dev, &first_sample_ago,
|
||||
&si->last_sample_ago, &si->select_ok);
|
||||
&si->last_sample_ago);
|
||||
|
||||
if (!si->select_ok) {
|
||||
++n_badstats_sources;
|
||||
|
||||
@@ -644,22 +644,16 @@ SST_GetFrequencyRange(SST_Stats inst,
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
void
|
||||
SST_GetSelectionData(SST_Stats inst, struct timespec *now,
|
||||
double *offset_lo_limit,
|
||||
double *offset_hi_limit,
|
||||
double *root_distance,
|
||||
double *std_dev,
|
||||
double *first_sample_ago,
|
||||
double *last_sample_ago,
|
||||
int *select_ok)
|
||||
int
|
||||
SST_GetSelectionData(SST_Stats inst, struct timespec *now, double *offset_lo_limit,
|
||||
double *offset_hi_limit, double *root_distance, double *std_dev,
|
||||
double *first_sample_ago, double *last_sample_ago)
|
||||
{
|
||||
double offset, sample_elapsed;
|
||||
int i, j;
|
||||
|
||||
if (!inst->n_samples) {
|
||||
*select_ok = 0;
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
i = get_runsbuf_index(inst, inst->best_single_sample);
|
||||
@@ -680,19 +674,20 @@ SST_GetSelectionData(SST_Stats inst, struct timespec *now,
|
||||
i = get_runsbuf_index(inst, inst->n_samples - 1);
|
||||
*last_sample_ago = UTI_DiffTimespecsToDouble(now, &inst->sample_times[i]);
|
||||
|
||||
*select_ok = inst->regression_ok;
|
||||
|
||||
/* If maxsamples is too small to have a successful regression, enable the
|
||||
selection as a special case for a fast update/print-once reference mode */
|
||||
if (!*select_ok && inst->n_samples < MIN_SAMPLES_FOR_REGRESS &&
|
||||
if (!inst->regression_ok && inst->n_samples < MIN_SAMPLES_FOR_REGRESS &&
|
||||
inst->n_samples == inst->max_samples) {
|
||||
*std_dev = CNF_GetMaxJitter();
|
||||
*select_ok = 1;
|
||||
} else if (!inst->regression_ok) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEBUG_LOG("n=%d off=%f dist=%f sd=%f first_ago=%f last_ago=%f selok=%d",
|
||||
DEBUG_LOG("n=%d off=%f dist=%f sd=%f first_ago=%f last_ago=%f",
|
||||
inst->n_samples, offset, *root_distance, *std_dev,
|
||||
*first_sample_ago, *last_sample_ago, *select_ok);
|
||||
*first_sample_ago, *last_sample_ago);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
@@ -67,15 +67,10 @@ extern void SST_DoNewRegression(SST_Stats inst);
|
||||
extern void SST_GetFrequencyRange(SST_Stats inst, double *lo, double *hi);
|
||||
|
||||
/* Get data needed for selection */
|
||||
extern void
|
||||
SST_GetSelectionData(SST_Stats inst, struct timespec *now,
|
||||
double *offset_lo_limit,
|
||||
double *offset_hi_limit,
|
||||
double *root_distance,
|
||||
double *variance,
|
||||
double *first_sample_ago,
|
||||
double *last_sample_ago,
|
||||
int *select_ok);
|
||||
extern int SST_GetSelectionData(SST_Stats inst, struct timespec *now,
|
||||
double *offset_lo_limit, double *offset_hi_limit,
|
||||
double *root_distance, double *variance,
|
||||
double *first_sample_ago, double *last_sample_ago);
|
||||
|
||||
/* Get data needed when setting up tracking on this source */
|
||||
extern void
|
||||
|
||||
Reference in New Issue
Block a user