Subject: Re: [PATCH] WAN: bit and/or confusion

From: Andrew Morton <[email-masked]>
Date: Fri, 14 Aug 2009 16:36:44 -0700

On Fri, 14 Aug 2009 14:51:46 +0200
Roel Kluin <[email-masked]> wrote:

> Fix the tests that check whether Frame* bits are not set
> 
> Signed-off-by: Roel Kluin <[email-masked]>
> ---
> // vi drivers/net/wan/dscc4.c +307
> #define FrameVfr	0x80
> #define FrameRdo        0x40
> #define FrameCrc	0x20
> #define FrameRab	0x10
> 
> diff --git a/drivers/net/wan/dscc4.c b/drivers/net/wan/dscc4.c
> index 8face5d..dd3c64a 100644
> --- a/drivers/net/wan/dscc4.c
> +++ b/drivers/net/wan/dscc4.c
> @@ -663,9 +663,9 @@ static inline void dscc4_rx_skb(struct dscc4_dev_priv *dpriv,
>  	} else {
>  		if (skb->data[pkt_len] & FrameRdo)
>  			dev->stats.rx_fifo_errors++;
> -		else if (!(skb->data[pkt_len] | ~FrameCrc))
> +		else if (!(skb->data[pkt_len] & ~FrameCrc))
>  			dev->stats.rx_crc_errors++;

that's

	if (!(x & 0xffffffdf))

which seems peculiar.  Should it have been

	else if (skb->data[pkt_len] & FrameCrc)

or

	else if (!(skb->data[pkt_len] & FrameCrc))

> -		else if (!(skb->data[pkt_len] | ~(FrameVfr | FrameRab)))
> +		else if (!(skb->data[pkt_len] & ~(FrameVfr | FrameRab)))
>  			dev->stats.rx_length_errors++;
>  		else
>  			dev->stats.rx_errors++;