From: Yu Watanabe Date: Thu, 20 May 2021 05:54:32 +0000 (+0900) Subject: sysv-generator: use strextend_with_separator() X-Git-Tag: v249-rc1~182^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=580bf61304c1b8115367a0f484fd34ebd17d3b64;p=thirdparty%2Fsystemd.git sysv-generator: use strextend_with_separator() --- diff --git a/src/sysv-generator/sysv-generator.c b/src/sysv-generator/sysv-generator.c index cef141fbacb..bf23c486621 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; }