Re: [PATCH] Fix logical-not-parentheses warning
From: Joe Perches
Date: Sun Aug 02 2015 - 10:16:51 EST
On Sun, 2015-08-02 at 02:08 -0700, Tomer Barletz wrote:
> 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].
[]
> diff --git a/sound/pci/oxygen/oxygen_mixer.c
[]
>
@@ -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;
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.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/