atl1c: add missing parentheses
Subsystems (2)
PATCH 1/1 atl1c: add missing parentheses
Parentheses are required or the comparison occurs before the bitand.
---
#include <stdio.h>
int main()
{
printf("0 & 1 == 0: %u\n", 0 & 1 == 0);
printf("1 & 1 == 0: %u\n", 1 & 1 == 0);
printf("(0 & 1) == 0: %u\n", (0 & 1) == 0);
printf("(1 & 1) == 0: %u\n", (1 & 1) == 0);
return 0;
}output:
0 & 1 == 0: 0
1 & 1 == 0: 0
(0 & 1) == 0: 1
(1 & 1) == 0: 0
drivers/net/atl1c/atl1c.h +4 -4
@@ -188,14 +188,14 @@ struct atl1c_tpd_ext_desc {#define RRS_HDS_TYPE_DATA 2#define RRS_IS_NO_HDS_TYPE (flag) \ - (((flag) >> (RRS_HDS_TYPE_SHIFT)) & RRS_HDS_TYPE_MASK == 0) + ((((flag) >> (RRS_HDS_TYPE_SHIFT)) & RRS_HDS_TYPE_MASK) == 0)#define RRS_IS_HDS_HEAD (flag) \ - (((flag) >> (RRS_HDS_TYPE_SHIFT)) & RRS_HDS_TYPE_MASK == \ + ((((flag) >> (RRS_HDS_TYPE_SHIFT)) & RRS_HDS_TYPE_MASK) == \ RRS_HDS_TYPE_HEAD)#define RRS_IS_HDS_DATA (flag) \ - (((flag) >> (RRS_HDS_TYPE_SHIFT)) & RRS_HDS_TYPE_MASK == \ + ((((flag) >> (RRS_HDS_TYPE_SHIFT)) & RRS_HDS_TYPE_MASK) == \ RRS_HDS_TYPE_DATA)/* rrs word 3 bit 0:31 */
@@ -245,7 +245,7 @@ struct atl1c_tpd_ext_desc {#define RRS_PACKET_TYPE_802_3 1#define RRS_PACKET_TYPE_ETH 0#define RRS_PACKET_IS_ETH (word) \ - (((word) >> RRS_PACKET_TYPE_SHIFT) & RRS_PACKET_TYPE_MASK == \ + ((((word) >> RRS_PACKET_TYPE_SHIFT) & RRS_PACKET_TYPE_MASK) == \ RRS_PACKET_TYPE_ETH)#define RRS_RXD_IS_VALID (word) \ ((((word) >> RRS_RXD_UPDATED_SHIFT) & RRS_RXD_UPDATED_MASK) == 1)
David Miller
maintainerFrom: Roel Kluin <[email protected]>
Date: Sun, 12 Jul 2009 23:40:34 +0200
Quoted 3 lines
Parentheses are required or the comparison occurs before the bitand.
Signed-off-by Roel Kluin <[email protected]>
Scary... can someone test this before I apply it please?
Thanks.
Adding Jie (Atheros maintainer) to cc list.
Quoted 52 lines · Roel Kluin
Parentheses are required or the comparison occurs before the bitand.
Signed-off-by Roel Kluin <[email protected]>---
#include <stdio.h>
intmain()
{
printf("0 & 1 == 0: %u\n", 0 & 1 == 0);printf("1 & 1 == 0: %u\n", 1 & 1 == 0);printf("(0 & 1) == 0: %u\n", (0 & 1) == 0);printf("(1 & 1) == 0: %u\n", (1 & 1) == 0); return 0;
}output:
0 & 1 == 0: 0
1 & 1 == 0: 0
(0 & 1) == 0: 1
(1 & 1) == 0: 0drivers/net/atl1c/atl1c.h +4
-4@@ -188,14 +188,14 @@ struct atl1c_tpd_ext_desc { #define RRS_HDS_TYPE_DATA 2 #define RRS_IS_NO_HDS_TYPE(flag) \ - (((flag) >> (RRS_HDS_TYPE_SHIFT)) & RRS_HDS_TYPE_MASK == 0) + ((((flag) >> (RRS_HDS_TYPE_SHIFT)) & RRS_HDS_TYPE_MASK) == 0) #define RRS_IS_HDS_HEAD(flag) \ - (((flag) >> (RRS_HDS_TYPE_SHIFT)) & RRS_HDS_TYPE_MASK == \ + ((((flag) >> (RRS_HDS_TYPE_SHIFT)) & RRS_HDS_TYPE_MASK) == \ RRS_HDS_TYPE_HEAD) #define RRS_IS_HDS_DATA(flag) \ - (((flag) >> (RRS_HDS_TYPE_SHIFT)) & RRS_HDS_TYPE_MASK == \ + ((((flag) >> (RRS_HDS_TYPE_SHIFT)) & RRS_HDS_TYPE_MASK) == \ RRS_HDS_TYPE_DATA) /* rrs word 3 bit 0:31 */@@ -245,7 +245,7 @@ struct atl1c_tpd_ext_desc { #define RRS_PACKET_TYPE_802_3 1 #define RRS_PACKET_TYPE_ETH 0 #define RRS_PACKET_IS_ETH(word) \ - (((word) >> RRS_PACKET_TYPE_SHIFT) & RRS_PACKET_TYPE_MASK == \ + ((((word) >> RRS_PACKET_TYPE_SHIFT) & RRS_PACKET_TYPE_MASK) == \ RRS_PACKET_TYPE_ETH) #define RRS_RXD_IS_VALID(word) \ ((((word) >> RRS_RXD_UPDATED_SHIFT) & RRS_RXD_UPDATED_MASK) == 1)
David Miller
maintainerFrom: Roel Kluin <[email protected]>
Date: Sun, 12 Jul 2009 23:40:34 +0200
Quoted 3 lines
Parentheses are required or the comparison occurs before the bitand.
Signed-off-by Roel Kluin <[email protected]>
I'm sick and tired of waiting for someone to test this and it's so damn obvious, so, applied. Thanks!