]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
nulstr-util: make ret_size in strv_make_nulstr() optional
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 8 May 2023 11:06:33 +0000 (20:06 +0900)
committerMike Yuan <me@yhndnzj.com>
Mon, 8 May 2023 13:40:56 +0000 (21:40 +0800)
src/basic/nulstr-util.c

index 2acc61886bd98fa9d3782940563f56dfcb970e20..06fa219bd197552c8be61b07e3e9e789f016ce15 100644 (file)
@@ -88,7 +88,6 @@ int strv_make_nulstr(char * const *l, char **ret, size_t *ret_size) {
         size_t n = 0;
 
         assert(ret);
-        assert(ret_size);
 
         STRV_FOREACH(i, l) {
                 size_t z;
@@ -114,7 +113,8 @@ int strv_make_nulstr(char * const *l, char **ret, size_t *ret_size) {
                 m[n] = '\0';
 
         *ret = TAKE_PTR(m);
-        *ret_size = n;
+        if (ret_size)
+                *ret_size = n;
 
         return 0;
 }
@@ -125,7 +125,6 @@ int set_make_nulstr(Set *s, char **ret, size_t *ret_size) {
         _cleanup_free_ char **strv = NULL;
 
         assert(ret);
-        assert(ret_size);
 
         strv = set_get_strv(s);
         if (!strv)