All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] Remove support for SNDRV_CTL_ELEM_ACCESS_USER & minor fix
@ 2016-07-20  1:52 mengdong.lin
  2016-07-20  1:52 ` [PATCH v2 1/3] topology: Remove support for control flag SNDRV_CTL_ELEM_ACCESS_USER mengdong.lin
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: mengdong.lin @ 2016-07-20  1:52 UTC (permalink / raw)
  To: alsa-devel, broonie
  Cc: tiwai, mengdong.lin, Mengdong Lin, liam.r.girdwood, o-takashi

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

There is no ABI change in this series.

Remove support for control flag SNDRV_CTL_ELEM_ACCESS_USER as Takashi
Sakamoto suggested. Also fix 2 compiler warnings and add check before
string cpy.

History:
v2: Revise commit messages.

Mengdong Lin (3):
  topology: Remove support for control flag SNDRV_CTL_ELEM_ACCESS_USER
  topology: Add ATTRIBUTE_UNUSED for unused parameters to fix compiler
    warning
  topology: Check address and length before string copy

 src/topology/ctl.c        | 1 -
 src/topology/pcm.c        | 8 ++++----
 src/topology/tplg_local.h | 3 +++
 3 files changed, 7 insertions(+), 5 deletions(-)

-- 
2.5.0

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

* [PATCH v2 1/3] topology: Remove support for control flag SNDRV_CTL_ELEM_ACCESS_USER
  2016-07-20  1:52 [PATCH v2 0/3] Remove support for SNDRV_CTL_ELEM_ACCESS_USER & minor fix mengdong.lin
@ 2016-07-20  1:52 ` mengdong.lin
  2016-07-20  1:53 ` [PATCH v2 2/3] topology: Add ATTRIBUTE_UNUSED for unused parameters to fix compiler warning mengdong.lin
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: mengdong.lin @ 2016-07-20  1:52 UTC (permalink / raw)
  To: alsa-devel, broonie
  Cc: tiwai, mengdong.lin, Mengdong Lin, liam.r.girdwood, o-takashi

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

This access flag is used to add controls from user space by ioctl.
But topology only configures controls in user space and these controls
will eventually be created by ASoC in kernel, so topology should not
support this flag.

Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>

diff --git a/src/topology/ctl.c b/src/topology/ctl.c
index 592dded..54f8e44 100644
--- a/src/topology/ctl.c
+++ b/src/topology/ctl.c
@@ -41,7 +41,6 @@ static const struct ctl_access_elem ctl_access[] = {
 	{"lock", SNDRV_CTL_ELEM_ACCESS_LOCK},
 	{"owner", SNDRV_CTL_ELEM_ACCESS_OWNER},
 	{"tlv_callback", SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK},
-	{"user", SNDRV_CTL_ELEM_ACCESS_USER},
 };
 
 /* find CTL access strings and conver to values */
-- 
2.5.0

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

* [PATCH v2 2/3] topology: Add ATTRIBUTE_UNUSED for unused parameters to fix compiler warning
  2016-07-20  1:52 [PATCH v2 0/3] Remove support for SNDRV_CTL_ELEM_ACCESS_USER & minor fix mengdong.lin
  2016-07-20  1:52 ` [PATCH v2 1/3] topology: Remove support for control flag SNDRV_CTL_ELEM_ACCESS_USER mengdong.lin
@ 2016-07-20  1:53 ` mengdong.lin
  2016-07-20  1:53 ` [PATCH v2 3/3] topology: Check address and length before string copy mengdong.lin
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: mengdong.lin @ 2016-07-20  1:53 UTC (permalink / raw)
  To: alsa-devel, broonie
  Cc: tiwai, mengdong.lin, Mengdong Lin, liam.r.girdwood, o-takashi

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

This commit adds ATTRIBUTE_UNUSED to the unused parameter 'tplg' for
function tplg_parse_streams() and tplg_parse_fe_dai(). These two functions
need to keep 'tplg' as ops for tplg_parse_compound().

The compiler warnings below are fixed:

pcm.c: In function 'tplg_parse_streams':
pcm.c:262:43: warning: unused parameter 'tplg' [-Wunused-parameter]
 static int tplg_parse_streams(snd_tplg_t *tplg, snd_config_t *cfg,
                                           ^
pcm.c: In function 'tplg_parse_fe_dai':
pcm.c:324:42: warning: unused parameter 'tplg' [-Wunused-parameter]
 static int tplg_parse_fe_dai(snd_tplg_t *tplg, snd_config_t *cfg,

Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>

diff --git a/src/topology/pcm.c b/src/topology/pcm.c
index 281e6ef..0a90cb9 100644
--- a/src/topology/pcm.c
+++ b/src/topology/pcm.c
@@ -259,8 +259,8 @@ int tplg_parse_stream_caps(snd_tplg_t *tplg,
 }
 
 /* Parse the caps and config of a pcm stream */
-static int tplg_parse_streams(snd_tplg_t *tplg, snd_config_t *cfg,
-	void *private)
+static int tplg_parse_streams(snd_tplg_t *tplg ATTRIBUTE_UNUSED,
+			      snd_config_t *cfg, void *private)
 {
 	snd_config_iterator_t i, next;
 	snd_config_t *n;
@@ -321,8 +321,8 @@ static int tplg_parse_streams(snd_tplg_t *tplg, snd_config_t *cfg,
 }
 
 /* Parse name and id of a front-end DAI (ie. cpu dai of a FE DAI link) */
-static int tplg_parse_fe_dai(snd_tplg_t *tplg, snd_config_t *cfg,
-	void *private)
+static int tplg_parse_fe_dai(snd_tplg_t *tplg ATTRIBUTE_UNUSED,
+			     snd_config_t *cfg, void *private)
 {
 	struct tplg_elem *elem = private;
 	struct snd_soc_tplg_pcm *pcm = elem->pcm;
-- 
2.5.0

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

* [PATCH v2 3/3] topology: Check address and length before string copy
  2016-07-20  1:52 [PATCH v2 0/3] Remove support for SNDRV_CTL_ELEM_ACCESS_USER & minor fix mengdong.lin
  2016-07-20  1:52 ` [PATCH v2 1/3] topology: Remove support for control flag SNDRV_CTL_ELEM_ACCESS_USER mengdong.lin
  2016-07-20  1:53 ` [PATCH v2 2/3] topology: Add ATTRIBUTE_UNUSED for unused parameters to fix compiler warning mengdong.lin
@ 2016-07-20  1:53 ` mengdong.lin
  2016-07-20  4:29 ` [PATCH v2 0/3] Remove support for SNDRV_CTL_ELEM_ACCESS_USER & minor fix Takashi Sakamoto
  2016-07-20  5:49 ` Takashi Iwai
  4 siblings, 0 replies; 7+ messages in thread
From: mengdong.lin @ 2016-07-20  1:53 UTC (permalink / raw)
  To: alsa-devel, broonie
  Cc: tiwai, mengdong.lin, Mengdong Lin, liam.r.girdwood, o-takashi

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

elem_copy_text() is widely used for string copy in topology. Because some
name fields are not mandatory for users, sometimes the source can be
invalid and we should not do the copy. So we add check here.

Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>

diff --git a/src/topology/tplg_local.h b/src/topology/tplg_local.h
index 4d79aa7..cfde4cc 100644
--- a/src/topology/tplg_local.h
+++ b/src/topology/tplg_local.h
@@ -253,6 +253,9 @@ struct tplg_elem* tplg_elem_new_common(snd_tplg_t *tplg,
 
 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;
 }
-- 
2.5.0

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

* Re: [PATCH v2 0/3] Remove support for SNDRV_CTL_ELEM_ACCESS_USER & minor fix
  2016-07-20  1:52 [PATCH v2 0/3] Remove support for SNDRV_CTL_ELEM_ACCESS_USER & minor fix mengdong.lin
                   ` (2 preceding siblings ...)
  2016-07-20  1:53 ` [PATCH v2 3/3] topology: Check address and length before string copy mengdong.lin
@ 2016-07-20  4:29 ` Takashi Sakamoto
  2016-07-20  4:51   ` Mengdong Lin
  2016-07-20  5:49 ` Takashi Iwai
  4 siblings, 1 reply; 7+ messages in thread
From: Takashi Sakamoto @ 2016-07-20  4:29 UTC (permalink / raw)
  To: mengdong.lin, alsa-devel, broonie; +Cc: tiwai, mengdong.lin, liam.r.girdwood

Hi,

On Jul 20 2016 10:52, mengdong.lin@linux.intel.com wrote:
> From: Mengdong Lin <mengdong.lin@linux.intel.com>
>
> There is no ABI change in this series.
>
> Remove support for control flag SNDRV_CTL_ELEM_ACCESS_USER as Takashi
> Sakamoto suggested. Also fix 2 compiler warnings and add check before
> string cpy.
>
> History:
> v2: Revise commit messages.
>
> Mengdong Lin (3):
>    topology: Remove support for control flag SNDRV_CTL_ELEM_ACCESS_USER
>    topology: Add ATTRIBUTE_UNUSED for unused parameters to fix compiler
>      warning
>    topology: Check address and length before string copy
>
>   src/topology/ctl.c        | 1 -
>   src/topology/pcm.c        | 8 ++++----
>   src/topology/tplg_local.h | 3 +++
>   3 files changed, 7 insertions(+), 5 deletions(-)

Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>

But I believe that we can seek better ways for the purpose of third 
patch. For example, changing prototype of the function to return error 
code might help callers to handle errors appropriately.

Anyway, thanks for the first patch.


Regards

Takashi Sakamoto

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

* Re: [PATCH v2 0/3] Remove support for SNDRV_CTL_ELEM_ACCESS_USER & minor fix
  2016-07-20  4:29 ` [PATCH v2 0/3] Remove support for SNDRV_CTL_ELEM_ACCESS_USER & minor fix Takashi Sakamoto
@ 2016-07-20  4:51   ` Mengdong Lin
  0 siblings, 0 replies; 7+ messages in thread
From: Mengdong Lin @ 2016-07-20  4:51 UTC (permalink / raw)
  To: Takashi Sakamoto, alsa-devel, broonie
  Cc: tiwai, mengdong.lin, liam.r.girdwood



On 07/20/2016 12:29 PM, Takashi Sakamoto wrote:
> Hi,
>
> On Jul 20 2016 10:52, mengdong.lin@linux.intel.com wrote:
>> From: Mengdong Lin <mengdong.lin@linux.intel.com>
>>
>> There is no ABI change in this series.
>>
>> Remove support for control flag SNDRV_CTL_ELEM_ACCESS_USER as Takashi
>> Sakamoto suggested. Also fix 2 compiler warnings and add check before
>> string cpy.
>>
>> History:
>> v2: Revise commit messages.
>>
>> Mengdong Lin (3):
>>    topology: Remove support for control flag SNDRV_CTL_ELEM_ACCESS_USER
>>    topology: Add ATTRIBUTE_UNUSED for unused parameters to fix compiler
>>      warning
>>    topology: Check address and length before string copy
>>
>>   src/topology/ctl.c        | 1 -
>>   src/topology/pcm.c        | 8 ++++----
>>   src/topology/tplg_local.h | 3 +++
>>   3 files changed, 7 insertions(+), 5 deletions(-)
>
> Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
>
> But I believe that we can seek better ways for the purpose of third
> patch. For example, changing prototype of the function to return error
> code might help callers to handle errors appropriately.
>
> Anyway, thanks for the first patch.
>

The 3rd patch is to reduce checking on some optional fields elsewhere. 
We could drop this patch if we add check before calling elem_copy_text() 
and it will bring more code.

Thanks
Mengdong

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

* Re: [PATCH v2 0/3] Remove support for SNDRV_CTL_ELEM_ACCESS_USER & minor fix
  2016-07-20  1:52 [PATCH v2 0/3] Remove support for SNDRV_CTL_ELEM_ACCESS_USER & minor fix mengdong.lin
                   ` (3 preceding siblings ...)
  2016-07-20  4:29 ` [PATCH v2 0/3] Remove support for SNDRV_CTL_ELEM_ACCESS_USER & minor fix Takashi Sakamoto
@ 2016-07-20  5:49 ` Takashi Iwai
  4 siblings, 0 replies; 7+ messages in thread
From: Takashi Iwai @ 2016-07-20  5:49 UTC (permalink / raw)
  To: mengdong.lin
  Cc: mengdong.lin, alsa-devel, broonie, liam.r.girdwood, o-takashi

On Wed, 20 Jul 2016 03:52:23 +0200,
mengdong.lin@linux.intel.com wrote:
> 
> From: Mengdong Lin <mengdong.lin@linux.intel.com>
> 
> There is no ABI change in this series.
> 
> Remove support for control flag SNDRV_CTL_ELEM_ACCESS_USER as Takashi
> Sakamoto suggested. Also fix 2 compiler warnings and add check before
> string cpy.
> 
> History:
> v2: Revise commit messages.
> 
> Mengdong Lin (3):
>   topology: Remove support for control flag SNDRV_CTL_ELEM_ACCESS_USER
>   topology: Add ATTRIBUTE_UNUSED for unused parameters to fix compiler
>     warning
>   topology: Check address and length before string copy

Applied all three patches now.  Thanks.


Takashi

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

end of thread, other threads:[~2016-07-20  5:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-20  1:52 [PATCH v2 0/3] Remove support for SNDRV_CTL_ELEM_ACCESS_USER & minor fix mengdong.lin
2016-07-20  1:52 ` [PATCH v2 1/3] topology: Remove support for control flag SNDRV_CTL_ELEM_ACCESS_USER mengdong.lin
2016-07-20  1:53 ` [PATCH v2 2/3] topology: Add ATTRIBUTE_UNUSED for unused parameters to fix compiler warning mengdong.lin
2016-07-20  1:53 ` [PATCH v2 3/3] topology: Check address and length before string copy mengdong.lin
2016-07-20  4:29 ` [PATCH v2 0/3] Remove support for SNDRV_CTL_ELEM_ACCESS_USER & minor fix Takashi Sakamoto
2016-07-20  4:51   ` Mengdong Lin
2016-07-20  5:49 ` Takashi Iwai

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.