diff options
author | Lennart Poettering <lennart@poettering.net> | 2023-09-08 17:02:11 +0200 |
---|---|---|
committer | Luca Boccassi <luca.boccassi@gmail.com> | 2023-09-08 21:59:44 +0200 |
commit | 0df7d525763ce76269c414d9c0a9ee9978edf299 (patch) | |
tree | 1f75d063077ba0dca01a637404b017d921cb9254 /src/core/job.c | |
parent | conf-parser: parse main config first only if not symlinked to/as drop-in (diff) | |
download | systemd-0df7d525763ce76269c414d9c0a9ee9978edf299.tar.xz systemd-0df7d525763ce76269c414d9c0a9ee9978edf299.zip |
serialize: add common deserialize_read_line() helper and use it everywhere
This introduces a common helper replacing three very similar uses.
Prompted by review of: #27890
Diffstat (limited to 'src/core/job.c')
-rw-r--r-- | src/core/job.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/src/core/job.c b/src/core/job.c index acf8a78f41..e7d1f65dbc 100644 --- a/src/core/job.c +++ b/src/core/job.c @@ -1233,21 +1233,15 @@ int job_deserialize(Job *j, FILE *f) { assert(f); for (;;) { - _cleanup_free_ char *line = NULL; - char *l, *v; + _cleanup_free_ char *l = NULL; size_t k; + char *v; - r = read_line(f, LONG_LINE_MAX, &line); + r = deserialize_read_line(f, &l); if (r < 0) - return log_error_errno(r, "Failed to read serialization line: %m"); - if (r == 0) - return 0; - - l = strstrip(line); - - /* End marker */ - if (isempty(l)) - return 0; + return r; + if (r == 0) /* eof or end marker */ + break; k = strcspn(l, "="); @@ -1326,6 +1320,8 @@ int job_deserialize(Job *j, FILE *f) { } else log_debug("Unknown job serialization key: %s", l); } + + return 0; } int job_coldplug(Job *j) { |