]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
time-util: do not carry musl-specific fallback logic on glibc systems
authorMike Yuan <me@yhndnzj.com>
Wed, 12 Nov 2025 20:53:41 +0000 (21:53 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 13 Nov 2025 08:40:20 +0000 (09:40 +0100)
Follow-up for 3ac4d68498dd378e2b3acd2bb86f4700263532d0

We have no sensible way to detect why strptime() fails, hence
the fallback path as it is now would fire on glibc systems too,
pointlessly. Let's guard it behind ifdeffery.

src/basic/time-util.c

index 40d1bf1e090fdfedc9f869d8e89ca29b7215c3f3..c612606a72ae0bdd718fed727d5c1bbb5104dd65 100644 (file)
@@ -634,8 +634,6 @@ const char* get_tzname(bool dst) {
 }
 
 int parse_gmtoff(const char *t, long *ret) {
-        int r;
-
         assert(t);
 
         struct tm tm;
@@ -647,6 +645,11 @@ int parse_gmtoff(const char *t, long *ret) {
                 return 0;
         }
 
+#ifdef __GLIBC__
+        return -EINVAL;
+#else
+        int r;
+
         /* musl v1.2.5 does not support %z specifier in strptime(). Since
          * https://github.com/kraj/musl/commit/fced99e93daeefb0192fd16304f978d4401d1d77
          * %z is supported, but it only supports strict RFC-822/ISO 8601 format, that is, 4 digits with sign
@@ -714,6 +717,7 @@ finalize:
         }
 
         return 0;
+#endif
 }
 
 static int parse_timestamp_impl(