rtc: minor cleanup in RTC_Linux_TimePreInit()
This commit is contained in:
parent
c6e064200d
commit
5fce101f85
1 changed files with 7 additions and 10 deletions
17
rtc_linux.c
17
rtc_linux.c
|
@ -979,9 +979,8 @@ RTC_Linux_TimePreInit(void)
|
||||||
int fd, status;
|
int fd, status;
|
||||||
struct rtc_time rtc_raw, rtc_raw_retry;
|
struct rtc_time rtc_raw, rtc_raw_retry;
|
||||||
struct tm rtc_tm;
|
struct tm rtc_tm;
|
||||||
time_t rtc_t, estimated_correct_rtc_t;
|
time_t rtc_t;
|
||||||
long interval;
|
double accumulated_error;
|
||||||
double accumulated_error = 0.0;
|
|
||||||
struct timeval new_sys_time, old_sys_time;
|
struct timeval new_sys_time, old_sys_time;
|
||||||
|
|
||||||
coefs_file_name = CNF_GetRtcFile();
|
coefs_file_name = CNF_GetRtcFile();
|
||||||
|
@ -1021,16 +1020,14 @@ RTC_Linux_TimePreInit(void)
|
||||||
/* Work out approximatation to correct time (to about the
|
/* Work out approximatation to correct time (to about the
|
||||||
nearest second) */
|
nearest second) */
|
||||||
if (valid_coefs_from_file) {
|
if (valid_coefs_from_file) {
|
||||||
interval = rtc_t - file_ref_time;
|
accumulated_error = file_ref_offset +
|
||||||
accumulated_error = file_ref_offset + (double)(interval) * 1.0e-6 * file_rate_ppm;
|
(rtc_t - file_ref_time) * 1.0e-6 * file_rate_ppm;
|
||||||
|
|
||||||
/* Correct time */
|
|
||||||
estimated_correct_rtc_t = rtc_t - (long)(0.5 + accumulated_error);
|
|
||||||
} else {
|
} else {
|
||||||
estimated_correct_rtc_t = rtc_t - (long)(0.5 + accumulated_error);
|
accumulated_error = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
new_sys_time.tv_sec = estimated_correct_rtc_t;
|
/* Correct time */
|
||||||
|
new_sys_time.tv_sec = rtc_t - (time_t)(0.5 + accumulated_error);
|
||||||
new_sys_time.tv_usec = 0;
|
new_sys_time.tv_usec = 0;
|
||||||
|
|
||||||
/* Set system time only if the step is larger than 1 second */
|
/* Set system time only if the step is larger than 1 second */
|
||||||
|
|
Loading…
Reference in a new issue