]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
rtc: use fscanf() to read coefficients
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 18 Aug 2014 15:19:36 +0000 (17:19 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Tue, 19 Aug 2014 08:46:35 +0000 (10:46 +0200)
rtc_linux.c

index 613c5095b60502e2894698b62d0bb47d6a10320a..c45ae2b640024cf5beffdc522533fbdb581c9983 100644 (file)
@@ -431,7 +431,6 @@ static void
 read_coefs_from_file(void)
 {
   FILE *in;
-  char line[256];
 
   if (!tried_to_load_coefs) {
 
@@ -441,18 +440,13 @@ read_coefs_from_file(void)
 
     in = fopen(coefs_file_name, "r");
     if (in) {
-      if (fgets(line, sizeof(line), in)) {
-        if (sscanf(line, "%d%ld%lf%lf",
-                   &valid_coefs_from_file,
-                   &file_ref_time,
-                   &file_ref_offset,
-                   &file_rate_ppm) == 4) {
-        } else {
-          LOG(LOGS_WARN, LOGF_RtcLinux, "Could not parse coefficients line from RTC file %s",
-              coefs_file_name);
-        }
+      if (fscanf(in, "%d%ld%lf%lf",
+                 &valid_coefs_from_file,
+                 &file_ref_time,
+                 &file_ref_offset,
+                 &file_rate_ppm) == 4) {
       } 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);
       }
       fclose(in);