mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-04 01:05:06 -05:00
sources: switch unselect_selected_source() to variable arguments
Switch the function to the full printf style, which will be needed to log an integer.
This commit is contained in:
25
sources.c
25
sources.c
@@ -206,8 +206,7 @@ static LOG_FileID logfileid;
|
|||||||
/* Forward prototype */
|
/* Forward prototype */
|
||||||
|
|
||||||
static void update_sel_options(void);
|
static void update_sel_options(void);
|
||||||
static void unselect_selected_source(LOG_Severity severity, const char *format,
|
static void unselect_selected_source(LOG_Severity severity, const char *format, ...);
|
||||||
const char *arg);
|
|
||||||
static void slew_sources(struct timespec *raw, struct timespec *cooked, double dfreq,
|
static void slew_sources(struct timespec *raw, struct timespec *cooked, double dfreq,
|
||||||
double doffset, LCL_ChangeType change_type, void *anything);
|
double doffset, LCL_ChangeType change_type, void *anything);
|
||||||
static void add_dispersion(double dispersion, void *anything);
|
static void add_dispersion(double dispersion, void *anything);
|
||||||
@@ -339,7 +338,7 @@ void SRC_DestroyInstance(SRC_Instance instance)
|
|||||||
if (selected_source_index > dead_index)
|
if (selected_source_index > dead_index)
|
||||||
--selected_source_index;
|
--selected_source_index;
|
||||||
else if (selected_source_index == dead_index)
|
else if (selected_source_index == dead_index)
|
||||||
unselect_selected_source(LOGS_INFO, NULL, NULL);
|
unselect_selected_source(LOGS_INFO, NULL);
|
||||||
|
|
||||||
SRC_SelectSource(NULL);
|
SRC_SelectSource(NULL);
|
||||||
}
|
}
|
||||||
@@ -813,16 +812,24 @@ mark_ok_sources(SRC_Status status)
|
|||||||
call providing a message or selection of another source, which resets the
|
call providing a message or selection of another source, which resets the
|
||||||
report_selection_loss flag. */
|
report_selection_loss flag. */
|
||||||
|
|
||||||
|
FORMAT_ATTRIBUTE_PRINTF(2, 3)
|
||||||
static void
|
static void
|
||||||
unselect_selected_source(LOG_Severity severity, const char *format, const char *arg)
|
unselect_selected_source(LOG_Severity severity, const char *format, ...)
|
||||||
{
|
{
|
||||||
|
char buf[256];
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
if (selected_source_index != INVALID_SOURCE) {
|
if (selected_source_index != INVALID_SOURCE) {
|
||||||
selected_source_index = INVALID_SOURCE;
|
selected_source_index = INVALID_SOURCE;
|
||||||
report_selection_loss = 1;
|
report_selection_loss = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (report_selection_loss && format) {
|
if (report_selection_loss && format) {
|
||||||
log_selection_message(severity, format, arg);
|
va_start(ap, format);
|
||||||
|
vsnprintf(buf, sizeof (buf), format, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
log_selection_message(severity, "%s", buf);
|
||||||
report_selection_loss = 0;
|
report_selection_loss = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -945,7 +952,7 @@ SRC_SelectSource(SRC_Instance updated_inst)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (n_sources == 0) {
|
if (n_sources == 0) {
|
||||||
unselect_selected_source(LOGS_INFO, "Can't synchronise: no sources", NULL);
|
unselect_selected_source(LOGS_INFO, "Can't synchronise: no sources");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1132,7 +1139,7 @@ SRC_SelectSource(SRC_Instance updated_inst)
|
|||||||
if (n_badstats_sources && n_sel_sources && selected_source_index == INVALID_SOURCE &&
|
if (n_badstats_sources && n_sel_sources && selected_source_index == INVALID_SOURCE &&
|
||||||
max_sel_reach_size < SOURCE_REACH_BITS && max_sel_reach >> 1 == max_badstat_reach) {
|
max_sel_reach_size < SOURCE_REACH_BITS && max_sel_reach >> 1 == max_badstat_reach) {
|
||||||
mark_ok_sources(SRC_WAITS_STATS);
|
mark_ok_sources(SRC_WAITS_STATS);
|
||||||
unselect_selected_source(LOGS_INFO, NULL, NULL);
|
unselect_selected_source(LOGS_INFO, NULL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1146,7 +1153,7 @@ SRC_SelectSource(SRC_Instance updated_inst)
|
|||||||
|
|
||||||
if (n_endpoints == 0) {
|
if (n_endpoints == 0) {
|
||||||
/* No sources provided valid endpoints */
|
/* No sources provided valid endpoints */
|
||||||
unselect_selected_source(LOGS_INFO, "Can't synchronise: no selectable sources", NULL);
|
unselect_selected_source(LOGS_INFO, "Can't synchronise: no selectable sources");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1400,7 +1407,7 @@ SRC_SelectSource(SRC_Instance updated_inst)
|
|||||||
/* Before selecting the new synchronisation source wait until the reference
|
/* Before selecting the new synchronisation source wait until the reference
|
||||||
can be updated */
|
can be updated */
|
||||||
if (sources[max_score_index]->updates == 0) {
|
if (sources[max_score_index]->updates == 0) {
|
||||||
unselect_selected_source(LOGS_INFO, NULL, NULL);
|
unselect_selected_source(LOGS_INFO, NULL);
|
||||||
mark_ok_sources(SRC_WAITS_UPDATE);
|
mark_ok_sources(SRC_WAITS_UPDATE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user