Skip to contentSkip to conversation

add parentheses

PATCH Patrick Boettcher 1 participant 1 message Feb 3, 2008 2 messages not in the archive Media (V4L/DVB)

lore
Share & tools
lore
#2 lore raw
In reply to a message not in the archive

Hi,

Quoted 17 lines · Bodo Eggert

Review static int tvaudio_get_ctrl(struct CHIPSTATE *chip, · line 1574

Quoted 9 lines · Roel Kluin

'!' has a higher priority than '&': bitanding has no effect.

+++ b/drivers/media/video/tvaudio.c

(quoted diff) +1 -1
@@ -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 */

Quoted 6 lines

!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.

_______________________________________________
linux-dvb mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb