#include <sys/mman.h>
#include <sys/time.h>
#include <sys/timerfd.h>
-#include <sys/timex.h>
#include <sys/types.h>
#include <unistd.h>
s = extract_multiplier(p + strspn(p, WHITESPACE), &multiplier);
if (s == p && *s != '\0')
- /* Don't allow '12.34.56', but accept '12.34 .56' or '12.34s.56'*/
+ /* Don't allow '12.34.56', but accept '12.34 .56' or '12.34s.56' */
return -EINVAL;
p = s;
r += k;
}
- /* Don't allow "0.-0", "3.+1", "3. 1", "3.sec" or "3.hoge"*/
+ /* Don't allow "0.-0", "3.+1", "3. 1", "3.sec" or "3.hoge" */
if (b == e + 1)
return -EINVAL;
}
s = extract_nsec_multiplier(p + strspn(p, WHITESPACE), &multiplier);
if (s == p && *s != '\0')
- /* Don't allow '12.34.56', but accept '12.34 .56' or '12.34s.56'*/
+ /* Don't allow '12.34.56', but accept '12.34 .56' or '12.34s.56' */
return -EINVAL;
p = s;
r += k;
}
- /* Don't allow "0.-0", "3.+1", "3. 1", "3.sec" or "3.hoge"*/
+ /* Don't allow "0.-0", "3.+1", "3. 1", "3.sec" or "3.hoge" */
if (b == e + 1)
return -EINVAL;
}
return 0;
}
-bool ntp_synced(void) {
- struct timex txc = {};
-
- if (adjtimex(&txc) < 0)
- return false;
-
- /* Consider the system clock synchronized if the reported maximum error is smaller than the maximum
- * value (16 seconds). Ignore the STA_UNSYNC flag as it may have been set to prevent the kernel from
- * touching the RTC. */
- if (txc.maxerror >= 16000000)
- return false;
-
- return true;
-}
-
int get_timezones(char ***ret) {
_cleanup_fclose_ FILE *f = NULL;
_cleanup_strv_free_ char **zones = NULL;
- size_t n_zones = 0, n_allocated = 0;
+ size_t n_zones = 0;
int r;
assert(ret);
if (!zones)
return -ENOMEM;
- n_allocated = 2;
n_zones = 1;
f = fopen("/usr/share/zoneinfo/zone1970.tab", "re");
if (f) {
for (;;) {
- _cleanup_free_ char *line = NULL;
- char *p, *w;
+ _cleanup_free_ char *line = NULL, *w = NULL;
+ char *p;
size_t k;
r = read_line(f, LONG_LINE_MAX, &line);
if (!w)
return -ENOMEM;
- if (!GREEDY_REALLOC(zones, n_allocated, n_zones + 2)) {
- free(w);
+ if (!GREEDY_REALLOC(zones, n_zones + 2))
return -ENOMEM;
- }
- zones[n_zones++] = w;
+ zones[n_zones++] = TAKE_PTR(w);
zones[n_zones] = NULL;
}
r = readlink_malloc("/etc/localtime", &t);
if (r == -ENOENT) {
- /* If the symlink does not exist, assume "UTC", like glibc does*/
+ /* If the symlink does not exist, assume "UTC", like glibc does */
z = strdup("UTC");
if (!z)
return -ENOMEM;