]> 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>
Mon, 30 Jun 2025 09:18:09 +0000 (11:18 +0200)
Addresses: https://github.com/util-linux/util-linux/issues/3626
Signed-off-by: Karel Zak <kzak@redhat.com>
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 2cea6e6e815059583e9faba8823b324ad5cf9d17..db95f79cb8588a372fc063f859ab32c8fb799d5b 100644 (file)
@@ -456,9 +456,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 2316ada11fd7eee6f7f6957aa6d06302b396872b..f25d8aba1d65369cfe908b1837f5a23a2678ea78 100644 (file)
@@ -964,7 +964,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;
@@ -995,13 +995,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;
@@ -1014,7 +1014,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 4cd3cda3ab1439dc310f4d0e7682eac3e45cbca8..ca68d964835f1950ef46702bff8399557852f2ed 100644 (file)
@@ -279,7 +279,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 4883c7e43f9335b423d9421c0220a37f6257b841..83b39542f661b7583b2ce4d49996f97d80ec8877 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 e3da523b7cddf9433660be728b27ebbd41cae834..c130103fd8b01d75b13f5abe9296e846a2c4109b 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;