]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/strutils: add ul_ prefix to strconcat() functions
authorKarel Zak <kzak@redhat.com>
Mon, 30 Jun 2025 09:15:30 +0000 (11:15 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 9 Sep 2025 09:46:53 +0000 (11:46 +0200)
Addresses: https://github.com/util-linux/util-linux/issues/3626
Signed-off-by: Karel Zak <kzak@redhat.com>
(cherry picked from commit c128ee3ea488174230065f6a35286e01e98996f8)

include/strutils.h
lib/strutils.c
lib/strv.c
libmount/src/tab.c
misc-utils/getopt.c
misc-utils/logger.c
sys-utils/ipcutils.c

index 82d1505fe37774cf3e2f47cc1d5d91b33df69447..d7b99a150b231db23f1b81a0a61a2beeea3f4bfa 100644 (file)
@@ -441,9 +441,9 @@ static inline char *ul_next_string(char *p, char *end)
        return NULL;
 }
 
-extern char *strnconcat(const char *s, const char *suffix, size_t b);
-extern char *strconcat(const char *s, const char *suffix);
-extern char *strfconcat(const char *s, const char *format, ...)
+extern char *ul_strnconcat(const char *s, const char *suffix, size_t b);
+extern char *ul_strconcat(const char *s, const char *suffix);
+extern char *ul_strfconcat(const char *s, const char *format, ...)
                 __attribute__ ((__format__ (__printf__, 2, 3)));
 
 extern int strappend(char **a, const char *b);
index 52d26d9e79fd53d54afc2f608f216cb3e0b49833..805ddbfca4c2b52d79d66a61110850bf256050ba 100644 (file)
@@ -951,7 +951,7 @@ int streq_paths(const char *a, const char *b)
 }
 
 /* concatenate two strings to a new string, the size of the second string is limited by @b */
-char *strnconcat(const char *s, const char *suffix, size_t b)
+char *ul_strnconcat(const char *s, const char *suffix, size_t b)
 {
         size_t a;
         char *r;
@@ -982,13 +982,13 @@ char *strnconcat(const char *s, const char *suffix, size_t b)
 }
 
 /* concatenate two strings to a new string */
-char *strconcat(const char *s, const char *suffix)
+char *ul_strconcat(const char *s, const char *suffix)
 {
-        return strnconcat(s, suffix, suffix ? strlen(suffix) : 0);
+        return ul_strnconcat(s, suffix, suffix ? strlen(suffix) : 0);
 }
 
 /* concatenate @s and string defined by @format to a new string */
-char *strfconcat(const char *s, const char *format, ...)
+char *ul_strfconcat(const char *s, const char *format, ...)
 {
        va_list ap;
        char *val, *res;
@@ -1001,7 +1001,7 @@ char *strfconcat(const char *s, const char *format, ...)
        if (sz < 0)
                return NULL;
 
-       res = strnconcat(s, val, sz);
+       res = ul_strnconcat(s, val, sz);
        free(val);
        return res;
 }
index 6946f409b142ea68ac59b4c5c29191bbe3306034..bd006e353a8103a76bdf137980caf10a3a63722c 100644 (file)
@@ -164,7 +164,7 @@ int ul_strv_extend_strv_concat(char ***a, char **b, const char *suffix) {
         UL_STRV_FOREACH(s, b) {
                 char *v;
 
-                v = strconcat(*s, suffix);
+                v = ul_strconcat(*s, suffix);
                 if (!v)
                         return -ENOMEM;
 
index c8433674f9f4197b23afe3f4eec5b383b416c289..bde55b73d7e0456c41eebbe6ffad4c592768f477 100644 (file)
@@ -1900,7 +1900,7 @@ int __mnt_table_is_fs_mounted(struct libmnt_table *tb, struct libmnt_fs *fstab_f
                        src = mnt_fs_get_srcpath(rootfs);
                        if (fstype && strncmp(fstype, "nfs", 3) == 0 && root) {
                                /* NFS stores the root at the end of the source */
-                               src = src2 = strconcat(src, root);
+                               src = src2 = ul_strconcat(src, root);
                                free(root);
                                root = NULL;
                        }
index ae35baaf8d1543d62dc9e193624eb3c958c21723..67d5737fd1256e81d9a052f08251f04cc1116c9d 100644 (file)
@@ -280,7 +280,7 @@ static void add_short_options(struct getopt_control *ctl, char *options)
 {
        free(ctl->optstr);
        if (*options != '+' && getenv("POSIXLY_CORRECT"))
-               ctl->optstr = strconcat("+", options);
+               ctl->optstr = ul_strconcat("+", options);
        else
                ctl->optstr = xstrdup(options);
        if (!ctl->optstr)
index 52566c649fca5be4f78c87540d9a8c02f09b0950..9c50c5a6fcd1f222ac7d0e3c54c5df9a9e5c6fc8 100644 (file)
@@ -670,7 +670,7 @@ static char *strdup_structured_data_list(struct list_head *ls)
 
                if (!one)
                        continue;
-               res = strconcat(tmp, one);
+               res = ul_strconcat(tmp, one);
                free(tmp);
                free(one);
        }
@@ -688,7 +688,7 @@ static char *get_structured_data_string(struct logger_ctl *ctl)
                usr = strdup_structured_data_list(&ctl->user_sds);
 
        if (sys && usr) {
-               res = strconcat(sys, usr);
+               res = ul_strconcat(sys, usr);
                free(sys);
                free(usr);
        } else
index a755849fb56cda48bf5c8073cc9d897ad88dd83c..0dbdf3bd88f233ee9f65b0f9cc3d95c9caa0c9b3 100644 (file)
@@ -715,7 +715,7 @@ int posix_ipc_msg_get_info(const char *name, struct posix_msg_data **msgds)
                }
                fclose(f);
 
-               p->mname = strconcat("/", de->d_name);
+               p->mname = ul_strconcat("/", de->d_name);
 
                mqd_t mq = mq_open(p->mname, O_RDONLY);
                struct mq_attr attr;