diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-05-20 07:54:32 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-05-20 14:57:09 +0200 |
commit | 580bf61304c1b8115367a0f484fd34ebd17d3b64 (patch) | |
tree | e5eb073c5ce884afdfa333ba12e5e08221601019 | |
parent | systemctl: use strextend_with_separator() (diff) | |
download | systemd-580bf61304c1b8115367a0f484fd34ebd17d3b64.tar.xz systemd-580bf61304c1b8115367a0f484fd34ebd17d3b64.zip |
sysv-generator: use strextend_with_separator()
-rw-r--r-- | src/sysv-generator/sysv-generator.c | 33 |
1 files changed, 5 insertions, 28 deletions
diff --git a/src/sysv-generator/sysv-generator.c b/src/sysv-generator/sysv-generator.c index cef141fbac..bf23c48662 100644 --- a/src/sysv-generator/sysv-generator.c +++ b/src/sysv-generator/sysv-generator.c @@ -533,7 +533,7 @@ static int load_sysv(SysvStub *s) { * continuation */ size_t k; - char *j; + const char *j; k = strlen(t); if (k > 0 && t[k-1] == '\\') @@ -542,19 +542,8 @@ static int load_sysv(SysvStub *s) { state = NORMAL; j = strstrip(t); - if (!isempty(j)) { - char *d = NULL; - - if (chkconfig_description) - d = strjoin(chkconfig_description, " ", j); - else - d = strdup(j); - if (!d) - return log_oom(); - - free(chkconfig_description); - chkconfig_description = d; - } + if (!isempty(j) && !strextend_with_separator(&chkconfig_description, " ", j)) + return log_oom(); } else if (IN_SET(state, LSB, LSB_DESCRIPTION)) { @@ -604,20 +593,8 @@ static int load_sysv(SysvStub *s) { const char *j; j = strstrip(t); - if (!isempty(j)) { - char *d = NULL; - - if (long_description) - d = strjoin(long_description, " ", t); - else - d = strdup(j); - if (!d) - return log_oom(); - - free(long_description); - long_description = d; - } - + if (!isempty(j) && !strextend_with_separator(&long_description, " ", j)) + return log_oom(); } else state = LSB; } |