]> git.alsa-project.org Git - alsa-lib.git/commitdiff
seq: Avoid strlcat()
authorTakashi Iwai <tiwai@suse.de>
Wed, 31 Jul 2024 09:14:08 +0000 (11:14 +0200)
committerTakashi Iwai <tiwai@suse.de>
Wed, 31 Jul 2024 09:20:16 +0000 (11:20 +0200)
strlcat() isn't available in every system, so better to avoid it.
Rewrite the code without strlcat().

Fixes: 6167b8ce3e80 ("seq: Add API helper functions for creating UMP Endpoint and Blocks")
Link: https://lore.kernel.org/0796c157-1ac3-47a3-9d54-ba86f59d64d5@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
src/seq/seqmid.c

index 08c62d5c24b8ab98d5704d6b04522ef9ea252a5e..b30db40752547d37a8bd85ae22e360440ac11b1b 100644 (file)
@@ -635,6 +635,7 @@ static void update_group_ports(snd_seq_t *seq, snd_ump_endpoint_info_t *ep)
                char blknames[64];
                char name[64];
                unsigned int caps = 0;
+               int len;
 
                blknames[0] = 0;
                for (b = 0; b < ep->num_blocks; b++) {
@@ -668,14 +669,13 @@ static void update_group_ports(snd_seq_t *seq, snd_ump_endpoint_info_t *ep)
 
                        if (!*bp->name)
                                continue;
-                       if (*blknames) {
-                               strlcat(blknames, ", ", sizeof(blknames));
-                               strlcat(blknames, (const char *)bp->name,
-                                       sizeof(blknames));
-                       } else {
+                       len = strlen(blknames);
+                       if (len)
+                               snprintf(blknames + len, sizeof(blknames) - len,
+                                        ", %s", bp->name);
+                       else
                                snd_strlcpy(blknames, (const char *)bp->name,
                                            sizeof(blknames));
-                       }
                }
 
                if (!*blknames)