journal-gatewayd: use skip_leading_chars where appropriate

Prompted by c5d6754725
This commit is contained in:
Mike Yuan 2024-04-17 21:50:22 +08:00
parent 3d6d879d26
commit ee0373cb80
No known key found for this signature in database
GPG key ID: 417471C0A40F58B3
2 changed files with 6 additions and 9 deletions

View file

@ -133,7 +133,7 @@ static inline char *truncate_nl(char *s) {
return truncate_nl_full(s, NULL);
}
static inline char *skip_leading_chars(const char *s, const char *bad) {
static inline char* skip_leading_chars(const char *s, const char *bad) {
if (!s)
return NULL;

View file

@ -446,17 +446,14 @@ static int request_parse_range(
return -EINVAL;
m->n_skip = 0;
range_after_eq = startswith(range, "entries=");
if (range_after_eq) {
range_after_eq += strspn(range_after_eq, WHITESPACE);
return request_parse_range_entries(m, range_after_eq);
}
if (range_after_eq)
return request_parse_range_entries(m, skip_leading_chars(range_after_eq, /* bad = */ NULL));
range_after_eq = startswith(range, "realtime=");
if (range_after_eq) {
range_after_eq += strspn(range_after_eq, WHITESPACE);
return request_parse_range_time(m, range_after_eq);
}
if (range_after_eq)
return request_parse_range_time(m, skip_leading_chars(range_after_eq, /* bad = */ NULL));
return 0;
}