diff mbox

[1/5] ALSA: soc-da7219: fix inappropriate condition statement

Message ID 1469540517-32466-2-git-send-email-o-takashi@sakamocchi.jp (mailing list archive)
State Accepted
Commit a56a569818ea831ed2325dc5d1122dc0b8a229d0
Headers show

Commit Message

Takashi Sakamoto July 26, 2016, 1:41 p.m. UTC
Sparse reports a below warning.

sound/soc/codecs/da7219.c:804:57: warning: dubious: x & !y

The line includes a condition statement; '(a < b) & !c'. Practically, the
evaluated value of this statement equals to the value of '(a < b) && !c'.
Although, it's not an usual way to use bitwise operations as logical
operations to several conditions.

This commit fixes the bug.

Fixes: 6d817c0e9fd7 ("ASoC: codecs: Add da7219 codec driver")
CC: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
---
 sound/soc/codecs/da7219.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Adam Thomson July 26, 2016, 2:14 p.m. UTC | #1
On 26 July 2016 14:42, Takashi Sakamoto wrote: 

> Sparse reports a below warning.
> 
> sound/soc/codecs/da7219.c:804:57: warning: dubious: x & !y
> 
> The line includes a condition statement; '(a < b) & !c'. Practically, the
> evaluated value of this statement equals to the value of '(a < b) && !c'.
> Although, it's not an usual way to use bitwise operations as logical
> operations to several conditions.
> 
> This commit fixes the bug.
> 
> Fixes: 6d817c0e9fd7 ("ASoC: codecs: Add da7219 codec driver")
> CC: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
> Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
> ---
>  sound/soc/codecs/da7219.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/sound/soc/codecs/da7219.c b/sound/soc/codecs/da7219.c
> index 50ea943..b9fa8fe 100644
> --- a/sound/soc/codecs/da7219.c
> +++ b/sound/soc/codecs/da7219.c
> @@ -801,7 +801,7 @@ static int da7219_dai_event(struct snd_soc_dapm_widget
> *w,
>  				++i;
>  				msleep(50);
>  			}
> -		} while ((i < DA7219_SRM_CHECK_RETRIES) & (!srm_lock));
> +		} while ((i < DA7219_SRM_CHECK_RETRIES) && (!srm_lock));
> 
>  		if (!srm_lock)
>  			dev_warn(codec->dev, "SRM failed to lock\n");
> --
> 2.7.4

Acked-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
diff mbox

Patch

diff --git a/sound/soc/codecs/da7219.c b/sound/soc/codecs/da7219.c
index 50ea943..b9fa8fe 100644
--- a/sound/soc/codecs/da7219.c
+++ b/sound/soc/codecs/da7219.c
@@ -801,7 +801,7 @@  static int da7219_dai_event(struct snd_soc_dapm_widget *w,
 				++i;
 				msleep(50);
 			}
-		} while ((i < DA7219_SRM_CHECK_RETRIES) & (!srm_lock));
+		} while ((i < DA7219_SRM_CHECK_RETRIES) && (!srm_lock));
 
 		if (!srm_lock)
 			dev_warn(codec->dev, "SRM failed to lock\n");