You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gu...@apache.org on 2021/10/11 19:39:55 UTC
[incubator-nuttx] 01/03: audio/comp: Call va_start again instead of
va_copy
This is an automated email from the ASF dual-hosted git repository.
gustavonihei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 805f40f2f9e6af911b90b3c01aeacb160026cb2d
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Sat Oct 9 14:19:16 2021 +0800
audio/comp: Call va_start again instead of va_copy
since va_copy mayn't exist on all arch
Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
audio/audio_comp.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/audio/audio_comp.c b/audio/audio_comp.c
index 30d9bfd..648b400 100644
--- a/audio/audio_comp.c
+++ b/audio/audio_comp.c
@@ -930,26 +930,24 @@ int audio_comp_initialize(FAR const char *name, ...)
{
FAR struct audio_comp_priv_s *priv;
va_list ap;
- va_list cp;
int ret = -ENOMEM;
int i;
- va_start(ap, name);
- va_copy(cp, ap);
-
priv = kmm_zalloc(sizeof(struct audio_comp_priv_s));
if (priv == NULL)
{
- goto end_va;
+ return ret;
}
priv->export.ops = &g_audio_comp_ops;
+ va_start(ap, name);
while (va_arg(ap, FAR struct audio_lowerhalf_s *))
{
priv->count++;
}
+ va_end(ap);
priv->lower = kmm_calloc(priv->count,
sizeof(FAR struct audio_lowerhalf_s *));
if (priv->lower == NULL)
@@ -957,31 +955,30 @@ int audio_comp_initialize(FAR const char *name, ...)
goto free_priv;
}
+ va_start(ap, name);
for (i = 0; i < priv->count; i++)
{
FAR struct audio_lowerhalf_s *tmp;
- tmp = va_arg(cp, FAR struct audio_lowerhalf_s *);
+ tmp = va_arg(ap, FAR struct audio_lowerhalf_s *);
tmp->upper = audio_comp_callback;
tmp->priv = priv;
priv->lower[i] = tmp;
}
+ va_end(ap);
ret = audio_register(name, &priv->export);
if (ret < 0)
{
goto free_lower;
}
- va_end(ap);
return OK;
free_lower:
kmm_free(priv->lower);
free_priv:
kmm_free(priv);
-end_va:
- va_end(ap);
return ret;
}