chiark / gitweb /
Parse "timeout=0" as infinity in various generators (#6264)
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 3 Jul 2017 12:29:32 +0000 (08:29 -0400)
committerSven Eden <yamakuzure@gmx.net>
Tue, 25 Jul 2017 07:46:53 +0000 (09:46 +0200)
This extends 2d79a0bbb9f651656384a0a86ed814e6306fb5dd to the kernel
command line parsing.

The parsing is changed a bit to only understand "0" as infinity. If units are
specified, parse normally, e.g. "0s" is just 0. This makes it possible to
provide a zero timeout if necessary.

Simple test is added.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1462378.

src/basic/time-util.c
src/basic/time-util.h

index 7da7ea41c1a632e5896eec40eebbb6dc845e1b8b..d8997666e5e7dfd4c097c2de5268a8f7d91b17f9 100644 (file)
@@ -1024,6 +1024,16 @@ int parse_sec(const char *t, usec_t *usec) {
 }
 
 #if 0 /// UNNEEDED by elogind
+int parse_sec_fix_0(const char *t, usec_t *usec) {
+        t += strspn(t, WHITESPACE);
+        if (streq(t, "0")) {
+                *usec = USEC_INFINITY;
+                return 0;
+        }
+
+        return parse_sec(t, usec);
+}
+
 int parse_nsec(const char *t, nsec_t *nsec) {
         static const struct {
                 const char *suffix;
index 58b8c53006a6b4d753fbf5eb6814ce3c31567618..6bf0f72efa1e647ce8b333b7db014976537d52e1 100644 (file)
@@ -147,6 +147,9 @@ int parse_timestamp(const char *t, usec_t *usec);
 #endif // 0
 
 int parse_sec(const char *t, usec_t *usec);
+#if 0 /// UNNEEDED by elogind
+int parse_sec_fix_0(const char *t, usec_t *usec);
+#endif // 0
 int parse_time(const char *t, usec_t *usec, usec_t default_unit);
 #if 0 /// UNNEEDED by elogind
 int parse_nsec(const char *t, nsec_t *nsec);