topology: Fix the missing referenced elem ptr when merging private data
PATCH 1/1 topology: Fix the missing referenced elem ptr when merging private data
From: Mengdong Lin <[email protected]>
tplg_copy_data() should set the valid referenced data element pointer. The caller will double check this pointer for all kinds of references, including TLV, controls, text and data.
Also fix an inaccurate dmesg.
src/topology/dapm.c +1 -1
@@ -201,7 +201,7 @@ static int tplg_build_widget(snd_tplg_t *tplg, }if (!ref->elem) { -SNDERR ("error: cannot find control '%s'" +SNDERR ("error: cannot find '%s'" " referenced by widget '%s'\n" , ref->id, elem->id);return -EINVAL ;
src/topology/data.c +1 -0
@@ -1050,6 +1050,7 @@ int tplg_copy_data(snd_tplg_t *tplg, struct tplg_elem *elem, " element '%s'\n", ref->id, elem->id);return -EINVAL ; } + ref->elem = ref_elem;tplg_dbg ("Data '%s' used by '%s'\n" , ref->id, elem->id);/* overlook empty private data */
Signature · 1 line
2.5.0
Hi,
Quoted 15 lines · On Jul 21 2016 16:00, [email protected] wrote:
From: Mengdong Lin <[email protected]>
tplg_copy_data()should set the valid referenced data element pointer. The caller will double check this pointer for all kinds of references, including TLV, controls, text and data.Also fix an inaccurate dmesg.
Signed-off-by Mengdong Lin <[email protected]>src/topology/dapm.c +0
-0
src/topology/dapm.c static int tplg_build_widget(snd_tplg_t *tplg, · line 207
Quoted 8 lines
src/topology/dapm.c +1
-1@@ -201,7 +201,7 @@ static int tplg_build_widget(snd_tplg_t *tplg, }if (!ref->elem) { -SNDERR ("error: cannot find control '%s'" +SNDERR ("error: cannot find '%s'" " referenced by widget '%s'\n" , ref->id, elem->id);return -EINVAL ;
It's better to split to two patches for the different aims. Accumulating patches to log history is preferable, as long as you have concrete wills to improve codes, I believe.
src/topology/data.c int tplg_copy_data(snd_tplg_t *tplg, struct tplg_elem *elem, · line 1056
Quoted 12 lines
src/topology/data.c +1
-0@@ -1050,6 +1050,7 @@ int tplg_copy_data(snd_tplg_t *tplg, struct tplg_elem *elem, " element '%s'\n", ref->id, elem->id);return -EINVAL ; } + ref->elem = ref_elem;tplg_dbg ("Data '%s' used by '%s'\n" , ref->id, elem->id);/* overlook empty private data */
I wonder why the assignment is done in this line. This function still includes some codes to return errors. In this case, it's better to code the assignment in last part of the function.
This is a public API. It's better not to touch application's objects in invalid cases.
Regards
Takashi Sakamoto
Quoted 48 lines · Takashi Sakamoto
Hi,
Quoted 15 lines · On Jul 21 2016 16:00, [email protected] wrote:
From: Mengdong Lin <[email protected]>
tplg_copy_data()should set the valid referenced data element pointer. The caller will double check this pointer for all kinds of references, including TLV, controls, text and data.Also fix an inaccurate dmesg.
Signed-off-by Mengdong Lin <[email protected]>src/topology/dapm.c +0
-0src/topology/dapm.c static int tplg_build_widget(snd_tplg_t *tplg, · line 207
Quoted 8 lines
src/topology/dapm.c +1
-1@@ -201,7 +201,7 @@ static int tplg_build_widget(snd_tplg_t *tplg, }if (!ref->elem) { -SNDERR ("error: cannot find control '%s'" +SNDERR ("error: cannot find '%s'" " referenced by widget '%s'\n" , ref->id, elem->id);return -EINVAL ;It's better to split to two patches for the different aims. Accumulating patches to log history is preferable, as long as you have concrete wills to improve codes, I believe.
src/topology/data.c int tplg_copy_data(snd_tplg_t *tplg, struct tplg_elem *elem, · line 1056
Quoted 12 lines
src/topology/data.c +1
-0@@ -1050,6 +1050,7 @@ int tplg_copy_data(snd_tplg_t *tplg, struct tplg_elem *elem, " element '%s'\n", ref->id, elem->id);return -EINVAL ; } + ref->elem = ref_elem;tplg_dbg ("Data '%s' used by '%s'\n" , ref->id, elem->id);/* overlook empty private data */ I wonder why the assignment is done in this line. This function still includes some codes to return errors. In this case, it's better to code the assignment in last part of the function.
Quoted 2 lines
This is a public API. It's better not to touch application's objects in invalid cases.
Oops. I overlooked. It's in src/topology/tplg_local.h and not a public API... Anyway, it's better to consider about the error cases for consistency of object state.
Regards
Takashi Sakamoto
Quoted 7 lines
-----Original Message-----
From: Takashi Sakamoto [mailto:[email protected]]
Sent: Friday, July 22, 2016 5:16 AMQuoted 3 lines
It's better to split to two patches for the different aims. Accumulating patches to log history is preferable, as long as you have concrete wills to improve codes, I believe.
Okay. I split them in v2.
Quoted 19 lines
Quoted 6 lines
src/topology/data.c int tplg_copy_data(snd_tplg_t *tplg, struct
Quoted 6 lines
src/topology/data.c index renamed from src/topology/data.c +0
-0768fc27..397f6a5 100644
src/topology/data.c +0
-0@@ -1050,6 +1050,7 @@ int tplg_copy_data(snd_tplg_t *tplg, struct
tplg_elem*elem,Quoted 12 lines
src/topology/data.c int tplg_copy_data(snd_tplg_t *tplg, struct tplg_elem *elem, · line 1056
Quoted 7 lines
src/topology/data.c +1
-0" element '%s'\n", ref->id, elem->id);return -EINVAL ; } + ref->elem = ref_elem;tplg_dbg ("Data '%s' used by '%s'\n" , ref->id, elem->id);/* overlook empty private data */ I wonder why the assignment is done in this line. This function still includes some codes to return errors. In this case, it's better to code the assignment in last part of the function.
Quoted 6 lines
Quoted 2 lines
This is a public API. It's better not to touch application's objects in invalid cases.
Oops. I overlooked. It's in
src/topology/tplg_local.hand not a public API... Anyway, it's better to consider about the error cases for consistency of object state.
Yes. It's better to move to the end of this function, only on success. Also fixed this in v2 series "topology: Fix for handling widgets' references"
Thanks for your review!
Mengdong