- Backport upstream fixes: PCM sw_params behavior fix, UCM additions and corrections, dshare position overflow fix, build fixes for Android: 0001-pcm-Preserve-period_event-in-snd_pcm_hw_sw_params-ca.patch 0004-ucm-Add-ucm-files-for-DB820c-board.patch 0005-ucm-bytcr-PlatformEnableSeq.conf-update-some-comment.patch 0006-pcm-dshare-Fix-overflow-when-slave_hw_ptr-rolls-over.patch 0007-test-latency-use-frame-bytes-correctly-in-writebuf.patch 0008-conf-pcm-dmix-add-CHANNELS-argument.patch 0009-Android-avoid-using-versionsort.patch 0010-pcm-add-the-missing-strings.h-include.patch 0011-alisp-add-the-missing-include.patch 0012-add-snd_strlcpy-and-use-it-everywhere.patch 0013-pcm-rate-plugin-fix-signess-in-snd_pcm_rate_avail_up.patch - Drop -Iinclude/alsa from alsa.pc (bsc#1130333) 0014-Drop-I-includedir-alsa-from-alsa.pc.patch OBS-URL: https://build.opensuse.org/request/show/689240 OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/alsa?expand=0&rev=245
521 lines
19 KiB
Diff
521 lines
19 KiB
Diff
From 1755df1d9e6e2ec1e83e5367a224f81884aefffa Mon Sep 17 00:00:00 2001
|
|
From: Jaroslav Kysela <perex@perex.cz>
|
|
Date: Mon, 25 Mar 2019 16:45:43 +0100
|
|
Subject: [PATCH 12/14] add snd_strlcpy() and use it everywhere
|
|
|
|
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
|
|
---
|
|
include/local.h | 1 +
|
|
src/control/control.c | 6 +++---
|
|
src/error.c | 22 ++++++++++++++++++++++
|
|
src/pcm/pcm_direct.c | 6 +++---
|
|
src/pcm/pcm_ioplug.c | 6 +++---
|
|
src/pcm/pcm_null.c | 6 +++---
|
|
src/seq/seq.c | 10 +++++-----
|
|
src/topology/ctl.c | 9 ++++-----
|
|
src/topology/dapm.c | 16 ++++++++--------
|
|
src/topology/data.c | 8 ++++----
|
|
src/topology/elem.c | 6 +++---
|
|
src/topology/pcm.c | 28 ++++++++++++++--------------
|
|
src/topology/text.c | 2 +-
|
|
src/topology/tplg_local.h | 9 ---------
|
|
14 files changed, 74 insertions(+), 61 deletions(-)
|
|
|
|
diff --git a/include/local.h b/include/local.h
|
|
index e2cc291e2597..5edad317e955 100644
|
|
--- a/include/local.h
|
|
+++ b/include/local.h
|
|
@@ -236,6 +236,7 @@ int safe_strtol(const char *str, long *val);
|
|
|
|
int snd_send_fd(int sock, void *data, size_t len, int fd);
|
|
int snd_receive_fd(int sock, void *data, size_t len, int *fd);
|
|
+size_t snd_strlcpy(char *dst, const char *src, size_t size);
|
|
|
|
/*
|
|
* error messages
|
|
diff --git a/src/control/control.c b/src/control/control.c
|
|
index 90fab8776e9d..c49b77a39d2a 100644
|
|
--- a/src/control/control.c
|
|
+++ b/src/control/control.c
|
|
@@ -1805,7 +1805,7 @@ void snd_ctl_elem_id_set_subdevice(snd_ctl_elem_id_t *obj, unsigned int val)
|
|
void snd_ctl_elem_id_set_name(snd_ctl_elem_id_t *obj, const char *val)
|
|
{
|
|
assert(obj);
|
|
- strncpy((char *)obj->name, val, sizeof(obj->name));
|
|
+ snd_strlcpy((char *)obj->name, val, sizeof(obj->name));
|
|
}
|
|
|
|
/**
|
|
@@ -2723,7 +2723,7 @@ void snd_ctl_elem_info_set_subdevice(snd_ctl_elem_info_t *obj, unsigned int val)
|
|
void snd_ctl_elem_info_set_name(snd_ctl_elem_info_t *obj, const char *val)
|
|
{
|
|
assert(obj);
|
|
- strncpy((char *)obj->id.name, val, sizeof(obj->id.name));
|
|
+ snd_strlcpy((char *)obj->id.name, val, sizeof(obj->id.name));
|
|
}
|
|
|
|
/**
|
|
@@ -2945,7 +2945,7 @@ void snd_ctl_elem_value_set_subdevice(snd_ctl_elem_value_t *obj, unsigned int va
|
|
void snd_ctl_elem_value_set_name(snd_ctl_elem_value_t *obj, const char *val)
|
|
{
|
|
assert(obj);
|
|
- strncpy((char *)obj->id.name, val, sizeof(obj->id.name));
|
|
+ snd_strlcpy((char *)obj->id.name, val, sizeof(obj->id.name));
|
|
}
|
|
|
|
/**
|
|
diff --git a/src/error.c b/src/error.c
|
|
index 628b7c8870b1..2e617f87a7cf 100644
|
|
--- a/src/error.c
|
|
+++ b/src/error.c
|
|
@@ -177,3 +177,25 @@ static void snd_err_msg_default(const char *file, int line, const char *function
|
|
snd_lib_error_handler_t snd_err_msg = snd_err_msg_default;
|
|
|
|
#endif
|
|
+
|
|
+/**
|
|
+ * \brief Copy a C-string into a sized buffer
|
|
+ * \param dst Where to copy the string to
|
|
+ * \param src Where to copy the string from
|
|
+ * \param size Size of destination buffer
|
|
+ * \retval The source string length
|
|
+ *
|
|
+ * The result is always a valid NUL-terminated string that fits
|
|
+ * in the buffer (unless, of course, the buffer size is zero).
|
|
+ * It does not pad out the result like strncpy() does.
|
|
+ */
|
|
+size_t snd_strlcpy(char *dst, const char *src, size_t size)
|
|
+{
|
|
+ size_t ret = strlen(src);
|
|
+ if (size) {
|
|
+ size_t len = ret >= size ? size - 1 : ret;
|
|
+ memcpy(dst, src, len);
|
|
+ dst[len] = '\0';
|
|
+ }
|
|
+ return ret;
|
|
+}
|
|
diff --git a/src/pcm/pcm_direct.c b/src/pcm/pcm_direct.c
|
|
index 8998943a5844..666a8ce5b130 100644
|
|
--- a/src/pcm/pcm_direct.c
|
|
+++ b/src/pcm/pcm_direct.c
|
|
@@ -766,9 +766,9 @@ int snd_pcm_direct_info(snd_pcm_t *pcm, snd_pcm_info_t * info)
|
|
info->card = -1;
|
|
/* FIXME: fill this with something more useful: we know the hardware name */
|
|
if (pcm->name) {
|
|
- strncpy((char *)info->id, pcm->name, sizeof(info->id));
|
|
- strncpy((char *)info->name, pcm->name, sizeof(info->name));
|
|
- strncpy((char *)info->subname, pcm->name, sizeof(info->subname));
|
|
+ snd_strlcpy((char *)info->id, pcm->name, sizeof(info->id));
|
|
+ snd_strlcpy((char *)info->name, pcm->name, sizeof(info->name));
|
|
+ snd_strlcpy((char *)info->subname, pcm->name, sizeof(info->subname));
|
|
}
|
|
info->subdevices_count = 1;
|
|
return 0;
|
|
diff --git a/src/pcm/pcm_ioplug.c b/src/pcm/pcm_ioplug.c
|
|
index 1e25190a0f71..a437ca326778 100644
|
|
--- a/src/pcm/pcm_ioplug.c
|
|
+++ b/src/pcm/pcm_ioplug.c
|
|
@@ -94,9 +94,9 @@ static int snd_pcm_ioplug_info(snd_pcm_t *pcm, snd_pcm_info_t *info)
|
|
info->stream = pcm->stream;
|
|
info->card = -1;
|
|
if (pcm->name) {
|
|
- strncpy((char *)info->id, pcm->name, sizeof(info->id));
|
|
- strncpy((char *)info->name, pcm->name, sizeof(info->name));
|
|
- strncpy((char *)info->subname, pcm->name, sizeof(info->subname));
|
|
+ snd_strlcpy((char *)info->id, pcm->name, sizeof(info->id));
|
|
+ snd_strlcpy((char *)info->name, pcm->name, sizeof(info->name));
|
|
+ snd_strlcpy((char *)info->subname, pcm->name, sizeof(info->subname));
|
|
}
|
|
info->subdevices_count = 1;
|
|
return 0;
|
|
diff --git a/src/pcm/pcm_null.c b/src/pcm/pcm_null.c
|
|
index 7afe15811e17..ff6162447000 100644
|
|
--- a/src/pcm/pcm_null.c
|
|
+++ b/src/pcm/pcm_null.c
|
|
@@ -71,9 +71,9 @@ static int snd_pcm_null_info(snd_pcm_t *pcm, snd_pcm_info_t * info)
|
|
info->stream = pcm->stream;
|
|
info->card = -1;
|
|
if (pcm->name) {
|
|
- strncpy((char *)info->id, pcm->name, sizeof(info->id));
|
|
- strncpy((char *)info->name, pcm->name, sizeof(info->name));
|
|
- strncpy((char *)info->subname, pcm->name, sizeof(info->subname));
|
|
+ snd_strlcpy((char *)info->id, pcm->name, sizeof(info->id));
|
|
+ snd_strlcpy((char *)info->name, pcm->name, sizeof(info->name));
|
|
+ snd_strlcpy((char *)info->subname, pcm->name, sizeof(info->subname));
|
|
}
|
|
info->subdevices_count = 1;
|
|
return 0;
|
|
diff --git a/src/seq/seq.c b/src/seq/seq.c
|
|
index c6a1ad155bfb..afc884241179 100644
|
|
--- a/src/seq/seq.c
|
|
+++ b/src/seq/seq.c
|
|
@@ -1744,7 +1744,7 @@ void snd_seq_client_info_set_client(snd_seq_client_info_t *info, int client)
|
|
void snd_seq_client_info_set_name(snd_seq_client_info_t *info, const char *name)
|
|
{
|
|
assert(info && name);
|
|
- strncpy(info->name, name, sizeof(info->name));
|
|
+ snd_strlcpy(info->name, name, sizeof(info->name));
|
|
}
|
|
|
|
/**
|
|
@@ -2177,7 +2177,7 @@ void snd_seq_port_info_set_addr(snd_seq_port_info_t *info, const snd_seq_addr_t
|
|
void snd_seq_port_info_set_name(snd_seq_port_info_t *info, const char *name)
|
|
{
|
|
assert(info && name);
|
|
- strncpy(info->name, name, sizeof(info->name));
|
|
+ snd_strlcpy(info->name, name, sizeof(info->name));
|
|
}
|
|
|
|
/**
|
|
@@ -3122,7 +3122,7 @@ unsigned int snd_seq_queue_info_get_flags(const snd_seq_queue_info_t *info)
|
|
void snd_seq_queue_info_set_name(snd_seq_queue_info_t *info, const char *name)
|
|
{
|
|
assert(info && name);
|
|
- strncpy(info->name, name, sizeof(info->name));
|
|
+ snd_strlcpy(info->name, name, sizeof(info->name));
|
|
}
|
|
|
|
/**
|
|
@@ -3198,7 +3198,7 @@ int snd_seq_alloc_named_queue(snd_seq_t *seq, const char *name)
|
|
memset(&info, 0, sizeof(info));
|
|
info.locked = 1;
|
|
if (name)
|
|
- strncpy(info.name, name, sizeof(info.name) - 1);
|
|
+ snd_strlcpy(info.name, name, sizeof(info.name));
|
|
return snd_seq_create_queue(seq, &info);
|
|
}
|
|
|
|
@@ -3279,7 +3279,7 @@ int snd_seq_query_named_queue(snd_seq_t *seq, const char *name)
|
|
int err;
|
|
snd_seq_queue_info_t info;
|
|
assert(seq && name);
|
|
- strncpy(info.name, name, sizeof(info.name));
|
|
+ snd_strlcpy(info.name, name, sizeof(info.name));
|
|
err = seq->ops->get_named_queue(seq, &info);
|
|
if (err < 0)
|
|
return err;
|
|
diff --git a/src/topology/ctl.c b/src/topology/ctl.c
|
|
index 144bf51f0416..9c13b12c4bf4 100644
|
|
--- a/src/topology/ctl.c
|
|
+++ b/src/topology/ctl.c
|
|
@@ -380,7 +380,7 @@ int tplg_parse_control_bytes(snd_tplg_t *tplg,
|
|
|
|
be = elem->bytes_ext;
|
|
be->size = elem->size;
|
|
- elem_copy_text(be->hdr.name, elem->id, SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
+ snd_strlcpy(be->hdr.name, elem->id, SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
be->hdr.type = SND_SOC_TPLG_TYPE_BYTES;
|
|
|
|
tplg_dbg(" Control Bytes: %s\n", elem->id);
|
|
@@ -505,7 +505,7 @@ int tplg_parse_control_enum(snd_tplg_t *tplg, snd_config_t *cfg,
|
|
return -ENOMEM;
|
|
|
|
ec = elem->enum_ctrl;
|
|
- elem_copy_text(ec->hdr.name, elem->id, SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
+ snd_strlcpy(ec->hdr.name, elem->id, SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
ec->hdr.type = SND_SOC_TPLG_TYPE_ENUM;
|
|
ec->size = elem->size;
|
|
tplg->channel_idx = 0;
|
|
@@ -606,7 +606,7 @@ int tplg_parse_control_mixer(snd_tplg_t *tplg,
|
|
|
|
/* init new mixer */
|
|
mc = elem->mixer_ctrl;
|
|
- elem_copy_text(mc->hdr.name, elem->id, SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
+ snd_strlcpy(mc->hdr.name, elem->id, SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
mc->hdr.type = SND_SOC_TPLG_TYPE_MIXER;
|
|
mc->size = elem->size;
|
|
tplg->channel_idx = 0;
|
|
@@ -721,8 +721,7 @@ static int init_ctl_hdr(struct snd_soc_tplg_ctl_hdr *hdr,
|
|
hdr->size = sizeof(struct snd_soc_tplg_ctl_hdr);
|
|
hdr->type = t->type;
|
|
|
|
- elem_copy_text(hdr->name, t->name,
|
|
- SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
+ snd_strlcpy(hdr->name, t->name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
|
|
/* clean up access flag */
|
|
if (t->access == 0)
|
|
diff --git a/src/topology/dapm.c b/src/topology/dapm.c
|
|
index e5d473a89745..97c9695b9ebe 100644
|
|
--- a/src/topology/dapm.c
|
|
+++ b/src/topology/dapm.c
|
|
@@ -348,7 +348,7 @@ static int tplg_parse_line(const char *text,
|
|
unsigned int len, i;
|
|
const char *source = NULL, *sink = NULL, *control = NULL;
|
|
|
|
- elem_copy_text(buf, text, LINE_SIZE);
|
|
+ snd_strlcpy(buf, text, LINE_SIZE);
|
|
|
|
len = strlen(buf);
|
|
if (len <= 2) {
|
|
@@ -488,7 +488,7 @@ int tplg_parse_dapm_widget(snd_tplg_t *tplg,
|
|
tplg_dbg(" Widget: %s\n", elem->id);
|
|
|
|
widget = elem->widget;
|
|
- elem_copy_text(widget->name, elem->id, SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
+ snd_strlcpy(widget->name, elem->id, SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
widget->size = elem->size;
|
|
|
|
snd_config_for_each(i, next, cfg) {
|
|
@@ -523,7 +523,7 @@ int tplg_parse_dapm_widget(snd_tplg_t *tplg,
|
|
if (snd_config_get_string(n, &val) < 0)
|
|
return -EINVAL;
|
|
|
|
- elem_copy_text(widget->sname, val,
|
|
+ snd_strlcpy(widget->sname, val,
|
|
SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
tplg_dbg("\t%s: %s\n", id, val);
|
|
continue;
|
|
@@ -642,11 +642,11 @@ int tplg_add_route(snd_tplg_t *tplg, struct snd_tplg_graph_elem *t)
|
|
return -ENOMEM;
|
|
|
|
line = elem->route;
|
|
- elem_copy_text(line->source, t->src, SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
+ snd_strlcpy(line->source, t->src, SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
if (t->ctl)
|
|
- elem_copy_text(line->control, t->ctl,
|
|
+ snd_strlcpy(line->control, t->ctl,
|
|
SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
- elem_copy_text(line->sink, t->sink, SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
+ snd_strlcpy(line->sink, t->sink, SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
|
|
return 0;
|
|
}
|
|
@@ -684,9 +684,9 @@ int tplg_add_widget_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t)
|
|
w->size = elem->size;
|
|
|
|
w->id = wt->id;
|
|
- elem_copy_text(w->name, wt->name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
+ snd_strlcpy(w->name, wt->name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
if (wt->sname)
|
|
- elem_copy_text(w->sname, wt->sname, SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
+ snd_strlcpy(w->sname, wt->sname, SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
w->reg = wt->reg;
|
|
w->shift = wt->shift;
|
|
w->mask = wt->mask;
|
|
diff --git a/src/topology/data.c b/src/topology/data.c
|
|
index 6b7c3f6ce8f8..70a63d4a1fb9 100644
|
|
--- a/src/topology/data.c
|
|
+++ b/src/topology/data.c
|
|
@@ -473,7 +473,7 @@ static int copy_tuples(struct tplg_elem *elem,
|
|
case SND_SOC_TPLG_TUPLE_TYPE_STRING:
|
|
string = &array->string[j];
|
|
string->token = token_val;
|
|
- elem_copy_text(string->string, tuple->string,
|
|
+ snd_strlcpy(string->string, tuple->string,
|
|
SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
break;
|
|
|
|
@@ -587,7 +587,7 @@ static int parse_tuple_set(snd_config_t *cfg,
|
|
continue;
|
|
|
|
tuple = &set->tuple[set->num_tuples];
|
|
- elem_copy_text(tuple->token, id,
|
|
+ snd_strlcpy(tuple->token, id,
|
|
SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
|
|
switch (type) {
|
|
@@ -597,7 +597,7 @@ static int parse_tuple_set(snd_config_t *cfg,
|
|
break;
|
|
|
|
case SND_SOC_TPLG_TUPLE_TYPE_STRING:
|
|
- elem_copy_text(tuple->string, value,
|
|
+ snd_strlcpy(tuple->string, value,
|
|
SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
tplg_dbg("\t\t%s = %s\n", tuple->token, tuple->string);
|
|
break;
|
|
@@ -818,7 +818,7 @@ int tplg_parse_tokens(snd_tplg_t *tplg, snd_config_t *cfg,
|
|
if (snd_config_get_string(n, &value) < 0)
|
|
continue;
|
|
|
|
- elem_copy_text(tokens->token[tokens->num_tokens].id, id,
|
|
+ snd_strlcpy(tokens->token[tokens->num_tokens].id, id,
|
|
SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
tokens->token[tokens->num_tokens].value = atoi(value);
|
|
tplg_dbg("\t\t %s : %d\n", tokens->token[tokens->num_tokens].id,
|
|
diff --git a/src/topology/elem.c b/src/topology/elem.c
|
|
index 16ad44235dca..a9d1d8547bd2 100644
|
|
--- a/src/topology/elem.c
|
|
+++ b/src/topology/elem.c
|
|
@@ -47,7 +47,7 @@ int tplg_ref_add_elem(struct tplg_elem *elem, struct tplg_elem *elem_ref)
|
|
|
|
ref->type = elem_ref->type;
|
|
ref->elem = elem_ref;
|
|
- elem_copy_text(ref->id, elem_ref->id, SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
+ snd_strlcpy(ref->id, elem_ref->id, SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
|
|
list_add_tail(&ref->list, &elem->ref_list);
|
|
return 0;
|
|
@@ -169,7 +169,7 @@ struct tplg_elem* tplg_elem_new_common(snd_tplg_t *tplg,
|
|
/* do we get name from cfg */
|
|
if (cfg) {
|
|
snd_config_get_id(cfg, &id);
|
|
- elem_copy_text(elem->id, id, SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
+ snd_strlcpy(elem->id, id, SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
elem->id[SNDRV_CTL_ELEM_ID_NAME_MAXLEN - 1] = 0;
|
|
/* as we insert new elem based on the index value, move index
|
|
parsing here */
|
|
@@ -186,7 +186,7 @@ struct tplg_elem* tplg_elem_new_common(snd_tplg_t *tplg,
|
|
}
|
|
}
|
|
} else if (name != NULL)
|
|
- elem_copy_text(elem->id, name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
+ snd_strlcpy(elem->id, name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
|
|
switch (type) {
|
|
case SND_TPLG_TYPE_DATA:
|
|
diff --git a/src/topology/pcm.c b/src/topology/pcm.c
|
|
index 8ebfafd8396b..5f586dc133e7 100644
|
|
--- a/src/topology/pcm.c
|
|
+++ b/src/topology/pcm.c
|
|
@@ -383,7 +383,7 @@ int tplg_parse_stream_caps(snd_tplg_t *tplg,
|
|
|
|
sc = elem->stream_caps;
|
|
sc->size = elem->size;
|
|
- elem_copy_text(sc->name, elem->id, SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
+ snd_strlcpy(sc->name, elem->id, SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
|
|
tplg_dbg(" PCM Capabilities: %s\n", elem->id);
|
|
|
|
@@ -562,7 +562,7 @@ static int tplg_parse_streams(snd_tplg_t *tplg ATTRIBUTE_UNUSED,
|
|
/* store stream caps name, to find and merge
|
|
* the caps in building phase.
|
|
*/
|
|
- elem_copy_text(caps[stream].name, value,
|
|
+ snd_strlcpy(caps[stream].name, value,
|
|
SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
|
|
tplg_dbg("\t\t%s\n\t\t\t%s\n", id, value);
|
|
@@ -586,7 +586,7 @@ static int tplg_parse_fe_dai(snd_tplg_t *tplg ATTRIBUTE_UNUSED,
|
|
|
|
snd_config_get_id(cfg, &id);
|
|
tplg_dbg("\t\tFE DAI %s:\n", id);
|
|
- elem_copy_text(pcm->dai_name, id, SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
+ snd_strlcpy(pcm->dai_name, id, SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
|
|
snd_config_for_each(i, next, cfg) {
|
|
|
|
@@ -653,7 +653,7 @@ int tplg_parse_pcm(snd_tplg_t *tplg,
|
|
|
|
pcm = elem->pcm;
|
|
pcm->size = elem->size;
|
|
- elem_copy_text(pcm->pcm_name, elem->id, SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
+ snd_strlcpy(pcm->pcm_name, elem->id, SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
|
|
tplg_dbg(" PCM: %s\n", elem->id);
|
|
|
|
@@ -754,7 +754,7 @@ int tplg_parse_dai(snd_tplg_t *tplg,
|
|
|
|
dai = elem->dai;
|
|
dai->size = elem->size;
|
|
- elem_copy_text(dai->dai_name, elem->id,
|
|
+ snd_strlcpy(dai->dai_name, elem->id,
|
|
SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
|
|
tplg_dbg(" DAI: %s\n", elem->id);
|
|
@@ -920,7 +920,7 @@ int tplg_parse_link(snd_tplg_t *tplg,
|
|
|
|
link = elem->link;
|
|
link->size = elem->size;
|
|
- elem_copy_text(link->name, elem->id, SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
+ snd_strlcpy(link->name, elem->id, SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
|
|
tplg_dbg(" Link: %s\n", elem->id);
|
|
|
|
@@ -949,7 +949,7 @@ int tplg_parse_link(snd_tplg_t *tplg,
|
|
if (snd_config_get_string(n, &val) < 0)
|
|
return -EINVAL;
|
|
|
|
- elem_copy_text(link->stream_name, val,
|
|
+ snd_strlcpy(link->stream_name, val,
|
|
SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
tplg_dbg("\t%s: %s\n", id, val);
|
|
continue;
|
|
@@ -1319,7 +1319,7 @@ int tplg_parse_hw_config(snd_tplg_t *tplg, snd_config_t *cfg,
|
|
static void tplg_add_stream_object(struct snd_soc_tplg_stream *strm,
|
|
struct snd_tplg_stream_template *strm_tpl)
|
|
{
|
|
- elem_copy_text(strm->name, strm_tpl->name,
|
|
+ snd_strlcpy(strm->name, strm_tpl->name,
|
|
SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
strm->format = strm_tpl->format;
|
|
strm->rate = strm_tpl->rate;
|
|
@@ -1331,7 +1331,7 @@ static void tplg_add_stream_object(struct snd_soc_tplg_stream *strm,
|
|
static void tplg_add_stream_caps(struct snd_soc_tplg_stream_caps *caps,
|
|
struct snd_tplg_stream_caps_template *caps_tpl)
|
|
{
|
|
- elem_copy_text(caps->name, caps_tpl->name,
|
|
+ snd_strlcpy(caps->name, caps_tpl->name,
|
|
SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
|
|
caps->formats = caps_tpl->formats;
|
|
@@ -1370,9 +1370,9 @@ int tplg_add_pcm_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t)
|
|
pcm = elem->pcm;
|
|
pcm->size = elem->size;
|
|
|
|
- elem_copy_text(pcm->pcm_name, pcm_tpl->pcm_name,
|
|
+ snd_strlcpy(pcm->pcm_name, pcm_tpl->pcm_name,
|
|
SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
- elem_copy_text(pcm->dai_name, pcm_tpl->dai_name,
|
|
+ snd_strlcpy(pcm->dai_name, pcm_tpl->dai_name,
|
|
SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
pcm->pcm_id = pcm_tpl->pcm_id;
|
|
pcm->dai_id = pcm_tpl->dai_id;
|
|
@@ -1478,9 +1478,9 @@ int tplg_add_link_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t)
|
|
|
|
/* ID and names */
|
|
link->id = link_tpl->id;
|
|
- elem_copy_text(link->name, link_tpl->name,
|
|
+ snd_strlcpy(link->name, link_tpl->name,
|
|
SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
- elem_copy_text(link->stream_name, link_tpl->stream_name,
|
|
+ snd_strlcpy(link->stream_name, link_tpl->stream_name,
|
|
SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
|
|
/* stream configs */
|
|
@@ -1540,7 +1540,7 @@ int tplg_add_dai_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t)
|
|
dai = elem->dai;
|
|
dai->size = elem->size;
|
|
|
|
- elem_copy_text(dai->dai_name, dai_tpl->dai_name,
|
|
+ snd_strlcpy(dai->dai_name, dai_tpl->dai_name,
|
|
SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
dai->dai_id = dai_tpl->dai_id;
|
|
|
|
diff --git a/src/topology/text.c b/src/topology/text.c
|
|
index cba68870dacc..72647fe04955 100644
|
|
--- a/src/topology/text.c
|
|
+++ b/src/topology/text.c
|
|
@@ -46,7 +46,7 @@ static int parse_text_values(snd_config_t *cfg, struct tplg_elem *elem)
|
|
if (snd_config_get_string(n, &value) < 0)
|
|
continue;
|
|
|
|
- elem_copy_text(&texts->items[j][0], value,
|
|
+ snd_strlcpy(&texts->items[j][0], value,
|
|
SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
|
|
tplg_dbg("\t%s\n", &texts->items[j][0]);
|
|
|
|
diff --git a/src/topology/tplg_local.h b/src/topology/tplg_local.h
|
|
index af599145f9a9..8d58b2ae019e 100644
|
|
--- a/src/topology/tplg_local.h
|
|
+++ b/src/topology/tplg_local.h
|
|
@@ -282,15 +282,6 @@ struct tplg_elem *tplg_elem_lookup(struct list_head *base,
|
|
struct tplg_elem* tplg_elem_new_common(snd_tplg_t *tplg,
|
|
snd_config_t *cfg, const char *name, enum snd_tplg_type type);
|
|
|
|
-static inline void elem_copy_text(char *dest, const char *src, int len)
|
|
-{
|
|
- if (!dest || !src || !len)
|
|
- return;
|
|
-
|
|
- strncpy(dest, src, len);
|
|
- dest[len - 1] = 0;
|
|
-}
|
|
-
|
|
int tplg_parse_channel(snd_tplg_t *tplg ATTRIBUTE_UNUSED,
|
|
snd_config_t *cfg, void *private);
|
|
|
|
--
|
|
2.16.4
|
|
|