tty: ipwireless: Fix probable mask then right shift defects
authorJoe Perches <joe@perches.com>
Mon, 27 Oct 2014 05:25:05 +0000 (22:25 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 6 Nov 2014 04:06:33 +0000 (20:06 -0800)
Precedence of & and >> is not the same and is not left to right.
shift has higher precedence and should be done after the mask.

Add parentheses around the masks.

Signed-off-by: Joe Perches <joe@perches.com>
Acked-by: David Sterba <dsterba@suse.cz>
Reviewed-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/ipwireless/hardware.c

index 2c14842..5c77e1e 100644 (file)
@@ -378,9 +378,9 @@ static void swap_packet_bitfield_to_le(unsigned char *data)
        /*
         * transform bits from aa.bbb.ccc to ccc.bbb.aa
         */
-       ret |= tmp & 0xc0 >> 6;
-       ret |= tmp & 0x38 >> 1;
-       ret |= tmp & 0x07 << 5;
+       ret |= (tmp & 0xc0) >> 6;
+       ret |= (tmp & 0x38) >> 1;
+       ret |= (tmp & 0x07) << 5;
        *data = ret & 0xff;
 #endif
 }
@@ -393,9 +393,9 @@ static void swap_packet_bitfield_from_le(unsigned char *data)
        /*
         * transform bits from ccc.bbb.aa to aa.bbb.ccc
         */
-       ret |= tmp & 0xe0 >> 5;
-       ret |= tmp & 0x1c << 1;
-       ret |= tmp & 0x03 << 6;
+       ret |= (tmp & 0xe0) >> 5;
+       ret |= (tmp & 0x1c) << 1;
+       ret |= (tmp & 0x03) << 6;
        *data = ret & 0xff;
 #endif
 }