Skip to content

Commit 8f0ea0e

Browse files
committed
timedated: make ntp_synced() static
No need to have this in basic.
1 parent 8f71237 commit 8f0ea0e

File tree

3 files changed

+13
-18
lines changed

3 files changed

+13
-18
lines changed

src/basic/time-util.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include <sys/mman.h>
88
#include <sys/time.h>
99
#include <sys/timerfd.h>
10-
#include <sys/timex.h>
1110
#include <sys/types.h>
1211
#include <unistd.h>
1312

@@ -1245,21 +1244,6 @@ int parse_nsec(const char *t, nsec_t *nsec) {
12451244
return 0;
12461245
}
12471246

1248-
bool ntp_synced(void) {
1249-
struct timex txc = {};
1250-
1251-
if (adjtimex(&txc) < 0)
1252-
return false;
1253-
1254-
/* Consider the system clock synchronized if the reported maximum error is smaller than the maximum
1255-
* value (16 seconds). Ignore the STA_UNSYNC flag as it may have been set to prevent the kernel from
1256-
* touching the RTC. */
1257-
if (txc.maxerror >= 16000000)
1258-
return false;
1259-
1260-
return true;
1261-
}
1262-
12631247
int get_timezones(char ***ret) {
12641248
_cleanup_fclose_ FILE *f = NULL;
12651249
_cleanup_strv_free_ char **zones = NULL;

src/basic/time-util.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,6 @@ int parse_sec_def_infinity(const char *t, usec_t *usec);
133133
int parse_time(const char *t, usec_t *usec, usec_t default_unit);
134134
int parse_nsec(const char *t, nsec_t *nsec);
135135

136-
bool ntp_synced(void);
137-
138136
int get_timezones(char ***l);
139137
bool timezone_is_valid(const char *name, int log_level);
140138

src/timedate/timedated.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include <errno.h>
44
#include <sys/stat.h>
5+
#include <sys/timex.h>
56
#include <sys/types.h>
67
#include <unistd.h>
78

@@ -556,6 +557,18 @@ static int unit_enable_or_disable(UnitStatusInfo *u, sd_bus *bus, sd_bus_error *
556557
return 0;
557558
}
558559

560+
static bool ntp_synced(void) {
561+
struct timex txc = {};
562+
563+
if (adjtimex(&txc) < 0)
564+
return false;
565+
566+
/* Consider the system clock synchronized if the reported maximum error is smaller than the maximum
567+
* value (16 seconds). Ignore the STA_UNSYNC flag as it may have been set to prevent the kernel from
568+
* touching the RTC. */
569+
return txc.maxerror < 16000000;
570+
}
571+
559572
static BUS_DEFINE_PROPERTY_GET_GLOBAL(property_get_time, "t", now(CLOCK_REALTIME));
560573
static BUS_DEFINE_PROPERTY_GET_GLOBAL(property_get_ntp_sync, "b", ntp_synced());
561574

0 commit comments

Comments
 (0)