chiark / gitweb /
silent a few more gcc warnings
[elogind.git] / src / shared / time-util.c
index 860be61e8b7b8af74a9e13c9b50da782776bf182..7bb7d4ec5a50aadf378ddcab0002488b335e5f27 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <time.h>
 #include <string.h>
+#include <sys/timex.h>
 
 #include "util.h"
 #include "time-util.h"
@@ -282,7 +283,7 @@ char *format_timespan(char *buf, size_t l, usec_t t, usec_t accuracy) {
         /* The result of this function can be parsed with parse_sec */
 
         for (i = 0; i < ELEMENTSOF(table); i++) {
-                int k;
+                int k = 0;
                 size_t n;
                 bool done = false;
                 usec_t a, b;
@@ -792,3 +793,15 @@ int parse_nsec(const char *t, nsec_t *nsec) {
 
         return 0;
 }
+
+bool ntp_synced(void) {
+        struct timex txc = {};
+
+        if (adjtimex(&txc) < 0)
+                return false;
+
+        if (txc.status & STA_UNSYNC)
+                return false;
+
+        return true;
+}