]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
rtc: return status from preinit function
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 18 Aug 2014 15:03:55 +0000 (17:03 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Tue, 19 Aug 2014 08:46:35 +0000 (10:46 +0200)
rtc.c
rtc_linux.c
rtc_linux.h

diff --git a/rtc.c b/rtc.c
index 90828d0f12bd4a0417b28273d04bcc52e4495fe7..e559813f098b8cf55987ce9d11ac930c12859312 100644 (file)
--- a/rtc.c
+++ b/rtc.c
@@ -42,7 +42,7 @@ static int driver_initialised = 0;
 static struct {
   int  (*init)(void);
   void (*fini)(void);
-  void (*time_pre_init)(void);
+  int  (*time_pre_init)(void);
   void (*time_init)(void (*after_hook)(void*), void *anything);
   void (*start_measurements)(void);
   int  (*write_parameters)(void);
index 66d35e9127c9dc8d71e959a9c0e4f2c777f84393..613c5095b60502e2894698b62d0bb47d6a10320a 100644 (file)
@@ -973,7 +973,7 @@ RTC_Linux_WriteParameters(void)
    etc in this case, since we have fewer requirements regarding the
    RTC behaviour than we do for the rest of the module. */
 
-void
+int
 RTC_Linux_TimePreInit(void)
 {
   int fd, status;
@@ -991,7 +991,7 @@ RTC_Linux_TimePreInit(void)
   fd = open(CNF_GetRtcDevice(), O_RDONLY);
 
   if (fd < 0) {
-    return; /* Can't open it, and won't be able to later */
+    return 0; /* Can't open it, and won't be able to later */
   }
 
   /* Retry reading the rtc until both read attempts give the same sec value.
@@ -1007,6 +1007,8 @@ RTC_Linux_TimePreInit(void)
   /* Read system clock */
   LCL_ReadCookedTime(&old_sys_time, NULL);
 
+  close(fd);
+
   if (status >= 0) {
     /* Convert to seconds since 1970 */
     rtc_tm.tm_sec = rtc_raw.tm_sec;
@@ -1047,10 +1049,11 @@ RTC_Linux_TimePreInit(void)
       }
     } else {
       LOG(LOGS_WARN, LOGF_RtcLinux, "Could not convert RTC reading to seconds since 1/1/1970");
+      return 0;
     }
   }
 
-  close(fd);
+  return 1;
 }
 
 /* ================================================== */
index 4ac13e173c46b25fb9bd1962125f5ed56f257912..8cf23a62d17417e4da654b54fe9f8115c7561e6b 100644 (file)
@@ -30,7 +30,7 @@
 
 extern int RTC_Linux_Initialise(void);
 extern void RTC_Linux_Finalise(void);
-extern void RTC_Linux_TimePreInit(void);
+extern int RTC_Linux_TimePreInit(void);
 extern void RTC_Linux_TimeInit(void (*after_hook)(void *), void *anything);
 extern void RTC_Linux_StartMeasurements(void);