Skip to contentSkip to conversation

Fix logical-not-parentheses warning

PATCH In review Tomer Barletz 3 participants 5 messages Aug 2, 2015 – Aug 3, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix logical-not-parentheses warning

---
 sound/pci/oxygen/oxygen_mixer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/pci/oxygen/oxygen_mixer.c +1 -1
index 6492bca..4ca1266 100644
@@ -88,7 +88,7 @@ static int dac_mute_put(struct snd_kcontrol *ctl,
 	int changed;
 
 	mutex_lock(&chip->mutex);
-	changed = !value->value.integer.value[0] != chip->dac_mute;
+	changed = (!value->value.integer.value[0]) != chip->dac_mute;
 	if (changed) {
 		chip->dac_mute = !value->value.integer.value[0];
 		chip->model.update_dac_mute(chip);
Signature · 1 line
2.4.3
#1 lore raw
Quoted 2 lines · Tomer Barletz

This is rather a gcc5 problem that doesn't recognize the expression correctly. Though, this change make things worse, so I'm willing to take it. But please give the warning message itself in changelog to show exactly what is the issue. The subject doesn't enough to understand why this change is needed.

thanks,

Takashi

Quoted 21 lines
---
 sound/pci/oxygen/oxygen_mixer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/pci/oxygen/oxygen_mixer.c +1 -1
index 6492bca..4ca1266 100644
@@ -88,7 +88,7 @@ static int dac_mute_put(struct snd_kcontrol *ctl,
 	int changed;
 
 	mutex_lock(&chip->mutex);
-	changed = !value->value.integer.value[0] != chip->dac_mute;
+	changed = (!value->value.integer.value[0]) != chip->dac_mute;
 	if (changed) {
 		chip->dac_mute = !value->value.integer.value[0];
 		chip->model.update_dac_mute(chip);
Signature · 1 line
2.4.3
#2 lore raw

PATCH 1/1 Fix logical-not-parentheses warning

This fixes the following warning, that is seen with gcc 5.1:
warning: logical not is only applied to the left hand side of comparison [-Wlogical-not-parentheses].

---
 sound/pci/oxygen/oxygen_mixer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/pci/oxygen/oxygen_mixer.c +1 -1
index 6492bca..4ca1266 100644
@@ -88,7 +88,7 @@ static int dac_mute_put(struct snd_kcontrol *ctl,
 	int changed;
 
 	mutex_lock(&chip->mutex);
-	changed = !value->value.integer.value[0] != chip->dac_mute;
+	changed = (!value->value.integer.value[0]) != chip->dac_mute;
 	if (changed) {
 		chip->dac_mute = !value->value.integer.value[0];
 		chip->model.update_dac_mute(chip);
Signature · 1 line
2.4.3
#3 lore raw
Quoted 3 lines · Tomer Barletz

This fixes the following warning, that is seen with gcc 5.1:
warning: logical not is only applied to the left hand side of comparison [-Wlogical-not-parentheses].

[]

Review

Quoted 1 line
(quoted diff) +0 -0

[]

Quoted 1 line

@@ -88,7 +88,7 @@ static int dac_mute_put(struct snd_kcontrol *ctl,

sound/pci/oxygen/oxygen_mixer.c static int dac_mute_put(struct snd_kcontrol *ctl, · line 91

Quoted 5 lines
      int changed;
 
      mutex_lock(&chip->mutex);
sound/pci/oxygen/oxygen_mixer.c +1 -1
-     changed = !value->value.integer.value[0] != chip->dac_mute;
+     changed = (!value->value.integer.value[0]) != chip->dac_mute;

It seems this is because dac_mute's value is inverted 0 means true, 1 is false.

I think it'd be simpler if dac_mute was converted to a standard bool (or perhaps renamed to not_muted) and this test was rewritten.

Using !!value->value.integer.value[0] would also be more readable and intelligible.

Applied
#4 lore raw
In reply to Tomer Barletz
Quoted 5 lines · Tomer Barletz

This fixes the following warning, that is seen with gcc 5.1:
warning: logical not is only applied to the left hand side of comparison [-Wlogical-not-parentheses].

Applied, thanks.

Takashi

Quoted 21 lines
---
 sound/pci/oxygen/oxygen_mixer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/pci/oxygen/oxygen_mixer.c +1 -1
index 6492bca..4ca1266 100644
@@ -88,7 +88,7 @@ static int dac_mute_put(struct snd_kcontrol *ctl,
 	int changed;
 
 	mutex_lock(&chip->mutex);
-	changed = !value->value.integer.value[0] != chip->dac_mute;
+	changed = (!value->value.integer.value[0]) != chip->dac_mute;
 	if (changed) {
 		chip->dac_mute = !value->value.integer.value[0];
 		chip->model.update_dac_mute(chip);
Signature · 1 line
2.4.3