Parse "timeout=0" as infinity in various generators (#6264)
This extends 2d79a0bbb9 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.
This commit is contained in:
committed by
Lennart Poettering
parent
131d5e148e
commit
0004f698df
@@ -1009,6 +1009,16 @@ int parse_sec(const char *t, usec_t *usec) {
|
||||
return parse_time(t, usec, USEC_PER_SEC);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
@@ -133,6 +133,7 @@ int timestamp_deserialize(const char *value, usec_t *timestamp);
|
||||
int parse_timestamp(const char *t, usec_t *usec);
|
||||
|
||||
int parse_sec(const char *t, usec_t *usec);
|
||||
int parse_sec_fix_0(const char *t, usec_t *usec);
|
||||
int parse_time(const char *t, usec_t *usec, usec_t default_unit);
|
||||
int parse_nsec(const char *t, nsec_t *nsec);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user