Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1317044 > unrolled thread

[PATCH 1/2] ASoC: cs35l32: avoid uninitialized variable access

Started byArnd Bergmann <arnd@arndb.de>
First post2016-01-25 18:10 +0100
Last post2016-01-26 05:10 +0100
Articles 3 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 1/2] ASoC: cs35l32: avoid uninitialized variable access Arnd Bergmann <arnd@arndb.de> - 2016-01-25 18:10 +0100
    [PATCH 2/2] ASoC: s3c24xx: use const snd_soc_component_driver pointer Arnd Bergmann <arnd@arndb.de> - 2016-01-25 18:20 +0100
      Re: [PATCH 2/2] ASoC: s3c24xx: use const snd_soc_component_driver  pointer Krzysztof Kozlowski <k.kozlowski@samsung.com> - 2016-01-26 05:10 +0100

#1317044 — [PATCH 1/2] ASoC: cs35l32: avoid uninitialized variable access

FromArnd Bergmann <arnd@arndb.de>
Date2016-01-25 18:10 +0100
Subject[PATCH 1/2] ASoC: cs35l32: avoid uninitialized variable access
Message-ID<qUSOn-7cE-31@gated-at.bofh.it>
gcc warns about the possibilty of accessing a property read from
devicetree in cs35l32_i2c_probe() when it has not been initialized
because CONFIG_OF is disabled:

sound/soc/codecs/cs35l32.c: In function 'cs35l32_i2c_probe':
sound/soc/codecs/cs35l32.c:278:2: warning: 'val' may be used uninitialized in this function [-Wmaybe-uninitialized]

The code is actually correct because it checks the dev->of_node
variable first and we know this is NULL here, but by adding a
check for IS_ENABLED(CONFIG_OF), we can let the compiler know
as well, and also generate smaller object code.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 sound/soc/codecs/cs35l32.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/codecs/cs35l32.c b/sound/soc/codecs/cs35l32.c
index 44c30fe3e315..52ffaa8eb02b 100644
--- a/sound/soc/codecs/cs35l32.c
+++ b/sound/soc/codecs/cs35l32.c
@@ -372,7 +372,7 @@ static int cs35l32_i2c_probe(struct i2c_client *i2c_client,
 			dev_err(&i2c_client->dev, "could not allocate pdata\n");
 			return -ENOMEM;
 		}
-		if (i2c_client->dev.of_node) {
+		if (IS_ENABLED(CONFIG_OF) && i2c_client->dev.of_node) {
 			ret = cs35l32_handle_of_data(i2c_client,
 						     &cs35l32->pdata);
 			if (ret != 0)
-- 
2.7.0

[toc] | [next] | [standalone]


#1317069 — [PATCH 2/2] ASoC: s3c24xx: use const snd_soc_component_driver pointer

FromArnd Bergmann <arnd@arndb.de>
Date2016-01-25 18:20 +0100
Subject[PATCH 2/2] ASoC: s3c24xx: use const snd_soc_component_driver pointer
Message-ID<qUSY2-7hD-9@gated-at.bofh.it>
In reply to#1317044
An older patch to convert the API in the s3c i2s driver
ended up passing a const pointer into a function that takes
a non-const pointer, so we now get a warning:

sound/soc/samsung/s3c2412-i2s.c: In function 's3c2412_iis_dev_probe':
sound/soc/samsung/s3c2412-i2s.c:172:9: error: passing argument 3 of 's3c_i2sv2_register_component' discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]

However, the s3c_i2sv2_register_component() function again
passes the pointer into another function taking a const, so
we just need to change its prototype.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: eca3b01d0885 ("ASoC: switch over to use snd_soc_register_component() on s3c i2s")
---
 sound/soc/samsung/s3c-i2s-v2.c | 2 +-
 sound/soc/samsung/s3c-i2s-v2.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/soc/samsung/s3c-i2s-v2.c b/sound/soc/samsung/s3c-i2s-v2.c
index df65c5b494b1..b6ab3fc5789e 100644
--- a/sound/soc/samsung/s3c-i2s-v2.c
+++ b/sound/soc/samsung/s3c-i2s-v2.c
@@ -709,7 +709,7 @@ static int s3c2412_i2s_resume(struct snd_soc_dai *dai)
 #endif
 
 int s3c_i2sv2_register_component(struct device *dev, int id,
-			   struct snd_soc_component_driver *cmp_drv,
+			   const struct snd_soc_component_driver *cmp_drv,
 			   struct snd_soc_dai_driver *dai_drv)
 {
 	struct snd_soc_dai_ops *ops = (struct snd_soc_dai_ops *)dai_drv->ops;
diff --git a/sound/soc/samsung/s3c-i2s-v2.h b/sound/soc/samsung/s3c-i2s-v2.h
index 90abab364b49..d0684145ed1f 100644
--- a/sound/soc/samsung/s3c-i2s-v2.h
+++ b/sound/soc/samsung/s3c-i2s-v2.h
@@ -101,7 +101,7 @@ extern int s3c_i2sv2_probe(struct snd_soc_dai *dai,
  * soc core.
  */
 extern int s3c_i2sv2_register_component(struct device *dev, int id,
-					struct snd_soc_component_driver *cmp_drv,
+					const struct snd_soc_component_driver *cmp_drv,
 					struct snd_soc_dai_driver *dai_drv);
 
 #endif /* __SND_SOC_S3C24XX_S3C_I2SV2_I2S_H */
-- 
2.7.0

[toc] | [prev] | [next] | [standalone]


#1317516 — Re: [PATCH 2/2] ASoC: s3c24xx: use const snd_soc_component_driver pointer

FromKrzysztof Kozlowski <k.kozlowski@samsung.com>
Date2016-01-26 05:10 +0100
SubjectRe: [PATCH 2/2] ASoC: s3c24xx: use const snd_soc_component_driver pointer
Message-ID<qV373-64e-5@gated-at.bofh.it>
In reply to#1317069
On 26.01.2016 02:07, Arnd Bergmann wrote:
> An older patch to convert the API in the s3c i2s driver
> ended up passing a const pointer into a function that takes
> a non-const pointer, so we now get a warning:
> 
> sound/soc/samsung/s3c2412-i2s.c: In function 's3c2412_iis_dev_probe':
> sound/soc/samsung/s3c2412-i2s.c:172:9: error: passing argument 3 of 's3c_i2sv2_register_component' discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]
> 
> However, the s3c_i2sv2_register_component() function again
> passes the pointer into another function taking a const, so
> we just need to change its prototype.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Fixes: eca3b01d0885 ("ASoC: switch over to use snd_soc_register_component() on s3c i2s")
> ---
>  sound/soc/samsung/s3c-i2s-v2.c | 2 +-
>  sound/soc/samsung/s3c-i2s-v2.h | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 

Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>

Best regards,
Krzysztof

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web