rtc: use fscanf() to read coefficients
This commit is contained in:
parent
7e1a699616
commit
696b05d6e6
1 changed files with 6 additions and 12 deletions
18
rtc_linux.c
18
rtc_linux.c
|
@ -431,7 +431,6 @@ static void
|
||||||
read_coefs_from_file(void)
|
read_coefs_from_file(void)
|
||||||
{
|
{
|
||||||
FILE *in;
|
FILE *in;
|
||||||
char line[256];
|
|
||||||
|
|
||||||
if (!tried_to_load_coefs) {
|
if (!tried_to_load_coefs) {
|
||||||
|
|
||||||
|
@ -441,18 +440,13 @@ read_coefs_from_file(void)
|
||||||
|
|
||||||
in = fopen(coefs_file_name, "r");
|
in = fopen(coefs_file_name, "r");
|
||||||
if (in) {
|
if (in) {
|
||||||
if (fgets(line, sizeof(line), in)) {
|
if (fscanf(in, "%d%ld%lf%lf",
|
||||||
if (sscanf(line, "%d%ld%lf%lf",
|
&valid_coefs_from_file,
|
||||||
&valid_coefs_from_file,
|
&file_ref_time,
|
||||||
&file_ref_time,
|
&file_ref_offset,
|
||||||
&file_ref_offset,
|
&file_rate_ppm) == 4) {
|
||||||
&file_rate_ppm) == 4) {
|
|
||||||
} else {
|
|
||||||
LOG(LOGS_WARN, LOGF_RtcLinux, "Could not parse coefficients line from RTC file %s",
|
|
||||||
coefs_file_name);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
LOG(LOGS_WARN, LOGF_RtcLinux, "Could not read first line from RTC file %s",
|
LOG(LOGS_WARN, LOGF_RtcLinux, "Could not read coefficients from RTC file %s",
|
||||||
coefs_file_name);
|
coefs_file_name);
|
||||||
}
|
}
|
||||||
fclose(in);
|
fclose(in);
|
||||||
|
|
Loading…
Reference in a new issue