All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] topology: Fix the missing referenced elem ptr when merging private data
@ 2016-07-21  7:00 mengdong.lin
  2016-07-21 20:37 ` Takashi Sakamoto
  0 siblings, 1 reply; 4+ messages in thread
From: mengdong.lin @ 2016-07-21  7:00 UTC (permalink / raw)
  To: alsa-devel, broonie
  Cc: tiwai, mengdong.lin, Mengdong Lin, liam.r.girdwood, shreyas.nc

From: Mengdong Lin <mengdong.lin@linux.intel.com>

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 <mengdong.lin@linux.intel.com>

diff --git a/src/topology/dapm.c b/src/topology/dapm.c
index 4d343b2..e3c90d8 100644
--- a/src/topology/dapm.c
+++ b/src/topology/dapm.c
@@ -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;
diff --git a/src/topology/data.c b/src/topology/data.c
index 768fc27..397f6a5 100644
--- a/src/topology/data.c
+++ b/src/topology/data.c
@@ -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 */
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] topology: Fix the missing referenced elem ptr when merging private data
  2016-07-21  7:00 [PATCH] topology: Fix the missing referenced elem ptr when merging private data mengdong.lin
@ 2016-07-21 20:37 ` Takashi Sakamoto
  2016-07-21 21:16   ` Takashi Sakamoto
  0 siblings, 1 reply; 4+ messages in thread
From: Takashi Sakamoto @ 2016-07-21 20:37 UTC (permalink / raw)
  To: mengdong.lin, alsa-devel, broonie
  Cc: tiwai, mengdong.lin, liam.r.girdwood, shreyas.nc

Hi,

On Jul 21 2016 16:00, mengdong.lin@linux.intel.com wrote:
> From: Mengdong Lin <mengdong.lin@linux.intel.com>
> 
> 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 <mengdong.lin@linux.intel.com>
> 
> diff --git a/src/topology/dapm.c b/src/topology/dapm.c
> index 4d343b2..e3c90d8 100644
> --- a/src/topology/dapm.c
> +++ b/src/topology/dapm.c
> @@ -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.

> diff --git a/src/topology/data.c b/src/topology/data.c
> index 768fc27..397f6a5 100644
> --- a/src/topology/data.c
> +++ b/src/topology/data.c
> @@ -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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] topology: Fix the missing referenced elem ptr when merging private data
  2016-07-21 20:37 ` Takashi Sakamoto
@ 2016-07-21 21:16   ` Takashi Sakamoto
  2016-07-22  1:48     ` Lin, Mengdong
  0 siblings, 1 reply; 4+ messages in thread
From: Takashi Sakamoto @ 2016-07-21 21:16 UTC (permalink / raw)
  To: mengdong.lin, alsa-devel, broonie
  Cc: tiwai, mengdong.lin, liam.r.girdwood, shreyas.nc

On Jul 22 2016 05:37, Takashi Sakamoto wrote:
> Hi,
> 
> On Jul 21 2016 16:00, mengdong.lin@linux.intel.com wrote:
>> From: Mengdong Lin <mengdong.lin@linux.intel.com>
>>
>> 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 <mengdong.lin@linux.intel.com>
>>
>> diff --git a/src/topology/dapm.c b/src/topology/dapm.c
>> index 4d343b2..e3c90d8 100644
>> --- a/src/topology/dapm.c
>> +++ b/src/topology/dapm.c
>> @@ -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.
> 
>> diff --git a/src/topology/data.c b/src/topology/data.c
>> index 768fc27..397f6a5 100644
>> --- a/src/topology/data.c
>> +++ b/src/topology/data.c
>> @@ -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.

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] topology: Fix the missing referenced elem ptr when merging private data
  2016-07-21 21:16   ` Takashi Sakamoto
@ 2016-07-22  1:48     ` Lin, Mengdong
  0 siblings, 0 replies; 4+ messages in thread
From: Lin, Mengdong @ 2016-07-22  1:48 UTC (permalink / raw)
  To: Takashi Sakamoto, mengdong.lin
  Cc: tiwai, alsa-devel, broonie, Girdwood, Liam R, Nc, Shreyas

> -----Original Message-----
> From: Takashi Sakamoto [mailto:o-takashi@sakamocchi.jp]
> Sent: Friday, July 22, 2016 5:16 AM

> > 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.

> >
> >> diff --git a/src/topology/data.c b/src/topology/data.c index
> >> 768fc27..397f6a5 100644
> >> --- a/src/topology/data.c
> >> +++ b/src/topology/data.c
> >> @@ -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.
> 
> 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.

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-07-22  1:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-21  7:00 [PATCH] topology: Fix the missing referenced elem ptr when merging private data mengdong.lin
2016-07-21 20:37 ` Takashi Sakamoto
2016-07-21 21:16   ` Takashi Sakamoto
2016-07-22  1:48     ` Lin, Mengdong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.