]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sysv-generator: use strextend_with_separator() 19672/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 20 May 2021 05:54:32 +0000 (14:54 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 20 May 2021 12:57:09 +0000 (21:57 +0900)
src/sysv-generator/sysv-generator.c

index cef141fbacbcb7912c98496bb324aedaae1c9265..bf23c48662162708a31017e077c1195513b7e774 100644 (file)
@@ -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;
                         }