[linux-dvb] [v4l-dvb-maintainer] [PATCH] [rivers/media/video/tvaudio.c] add parentheses

Patrick Boettcher patrick.boettcher at desy.de
Sun Feb 3 18:05:06 CET 2008


Hi,

On Sun, 3 Feb 2008, Bodo Eggert wrote:

> Roel Kluin <12o3l at tiscali.nl> wrote:
> 
> > '!' has a higher priority than '&': bitanding has no effect.
> 
> > +++ b/drivers/media/video/tvaudio.c
> > @@ -1571,14 +1571,14 @@ static int tvaudio_get_ctrl(struct CHIPSTATE *chip,
> >  ctrl->value=chip->muted;
> >  return 0;
> >  case V4L2_CID_AUDIO_VOLUME:
> > -             if (!desc->flags & CHIP_HAS_VOLUME)
> > +             if (!(desc->flags & CHIP_HAS_VOLUME))
> 
> This is a cosmetic change, because:
> 
> !1100101 & 0000100 == 0011010 & 0000100 == 0 /* false */
> !(1100101 & 0000100) == !0000100 == 0 /* false */
> 
> !1100001 & 0000100 == 0011110 & 0000100 == 0000100 /* non-false */
> !(1100001 & 0000100) == !0000000 == 1 /* non-false */
> 
> 
> OTOH, your change may result in better code by using a negated jump instead of
> explicitely negating the value.

If I'm not totally wrong, ! is negating integers: !123 == 0. At least I 
hope that, otherwise I have to go through a lot of code ;)

Your interpretation of ! is actually achieved by using ~ .

Patrick.



More information about the linux-dvb mailing list