chiark / gitweb /
basic: add log_level argument to timezone_is_valid
authorMike Gilbert <floppym@gentoo.org>
Sat, 12 May 2018 19:20:13 +0000 (15:20 -0400)
committerSven Eden <yamakuzure@gmx.net>
Fri, 24 Aug 2018 14:47:08 +0000 (16:47 +0200)
src/basic/time-util.c
src/basic/time-util.h

index e9838a82a2700be1c6c39d47e1722ba9b1d84fa7..fc9b99f51e70d729a25fc424901e8ac6084354cf 100644 (file)
@@ -890,7 +890,7 @@ int parse_timestamp(const char *t, usec_t *usec) {
         int r;
 
         last_space = strrchr(t, ' ');
-        if (last_space != NULL && timezone_is_valid(last_space + 1))
+        if (last_space != NULL && timezone_is_valid(last_space + 1, LOG_DEBUG))
                 tz = last_space + 1;
 
         if (!tz || endswith_no_case(t, " UTC"))
@@ -1290,7 +1290,7 @@ int get_timezones(char ***ret) {
         return 0;
 }
 
-bool timezone_is_valid(const char *name) {
+bool timezone_is_valid(const char *name, int log_level) {
         bool slash = false;
         const char *p, *t;
         _cleanup_close_ int fd = -1;
@@ -1327,25 +1327,25 @@ bool timezone_is_valid(const char *name) {
 
         fd = open(t, O_RDONLY|O_CLOEXEC);
         if (fd < 0) {
-                log_debug_errno(errno, "Failed to open timezone file '%s': %m", t);
+                log_full_errno(log_level, errno, "Failed to open timezone file '%s': %m", t);
                 return false;
         }
 
         r = fd_verify_regular(fd);
         if (r < 0) {
-                log_debug_errno(r, "Timezone file '%s' is not  a regular file: %m", t);
+                log_full_errno(log_level, r, "Timezone file '%s' is not  a regular file: %m", t);
                 return false;
         }
 
         r = loop_read_exact(fd, buf, 4, false);
         if (r < 0) {
-                log_debug_errno(r, "Failed to read from timezone file '%s': %m", t);
+                log_full_errno(log_level, r, "Failed to read from timezone file '%s': %m", t);
                 return false;
         }
 
         /* Magic from tzfile(5) */
         if (memcmp(buf, "TZif", 4) != 0) {
-                log_debug("Timezone file '%s' has wrong magic bytes", t);
+                log_full(log_level, "Timezone file '%s' has wrong magic bytes", t);
                 return false;
         }
 
@@ -1433,7 +1433,7 @@ int get_timezone(char **tz) {
         if (!e)
                 return -EINVAL;
 
-        if (!timezone_is_valid(e))
+        if (!timezone_is_valid(e, LOG_DEBUG))
                 return -EINVAL;
 
         z = strdup(e);
index 42d4f988936a58bb2af2b6b42b71ebf22aed3b18..1662197d66c9c7a517923a9d7b44baabe0601e07 100644 (file)
@@ -145,7 +145,7 @@ int parse_nsec(const char *t, nsec_t *nsec);
 bool ntp_synced(void);
 
 int get_timezones(char ***l);
-bool timezone_is_valid(const char *name);
+bool timezone_is_valid(const char *name, int log_level);
 
 #endif // 0
 bool clock_boottime_supported(void);