netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] atl1c: add missing parentheses
@ 2009-07-12 21:40 Roel Kluin
  2009-07-12 21:40 ` David Miller
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Roel Kluin @ 2009-07-12 21:40 UTC (permalink / raw)
  To: jcliburn; +Cc: atl1-devel, Andrew Morton, netdev

Parentheses are required or the comparison occurs before the bitand.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
#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

diff --git a/drivers/net/atl1c/atl1c.h b/drivers/net/atl1c/atl1c.h
index e1658ef..2a1120a 100644
--- a/drivers/net/atl1c/atl1c.h
+++ b/drivers/net/atl1c/atl1c.h
@@ -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)

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] atl1c: add missing parentheses
  2009-07-12 21:40 [PATCH] atl1c: add missing parentheses Roel Kluin
@ 2009-07-12 21:40 ` David Miller
  2009-07-13  0:08 ` J. K. Cliburn
  2009-07-17  1:08 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2009-07-12 21:40 UTC (permalink / raw)
  To: roel.kluin; +Cc: jcliburn, atl1-devel, akpm, netdev

From: Roel Kluin <roel.kluin@gmail.com>
Date: Sun, 12 Jul 2009 23:40:34 +0200

> Parentheses are required or the comparison occurs before the bitand.
> 
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>

Scary... can someone test this before I apply it please?

Thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] atl1c: add missing parentheses
  2009-07-12 21:40 [PATCH] atl1c: add missing parentheses Roel Kluin
  2009-07-12 21:40 ` David Miller
@ 2009-07-13  0:08 ` J. K. Cliburn
  2009-07-17  1:08 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: J. K. Cliburn @ 2009-07-13  0:08 UTC (permalink / raw)
  To: Roel Kluin; +Cc: atl1-devel, Andrew Morton, netdev, Jie Yang

Adding Jie (Atheros maintainer) to cc list.

On Sun, Jul 12, 2009 at 4:40 PM, Roel Kluin<roel.kluin@gmail.com> wrote:
> Parentheses are required or the comparison occurs before the bitand.
>
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> ---
> #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
>
> diff --git a/drivers/net/atl1c/atl1c.h b/drivers/net/atl1c/atl1c.h
> index e1658ef..2a1120a 100644
> --- a/drivers/net/atl1c/atl1c.h
> +++ b/drivers/net/atl1c/atl1c.h
> @@ -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)
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] atl1c: add missing parentheses
  2009-07-12 21:40 [PATCH] atl1c: add missing parentheses Roel Kluin
  2009-07-12 21:40 ` David Miller
  2009-07-13  0:08 ` J. K. Cliburn
@ 2009-07-17  1:08 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2009-07-17  1:08 UTC (permalink / raw)
  To: roel.kluin; +Cc: jcliburn, atl1-devel, akpm, netdev

From: Roel Kluin <roel.kluin@gmail.com>
Date: Sun, 12 Jul 2009 23:40:34 +0200

> Parentheses are required or the comparison occurs before the bitand.
> 
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>

I'm sick and tired of waiting for someone to test this and it's so
damn obvious, so, applied.  Thanks!

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-07-17  1:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-12 21:40 [PATCH] atl1c: add missing parentheses Roel Kluin
2009-07-12 21:40 ` David Miller
2009-07-13  0:08 ` J. K. Cliburn
2009-07-17  1:08 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).