Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757275Ab3FCLey (ORCPT ); Mon, 3 Jun 2013 07:34:54 -0400 Received: from mail-ob0-f180.google.com ([209.85.214.180]:38278 "EHLO mail-ob0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755727Ab3FCLem (ORCPT ); Mon, 3 Jun 2013 07:34:42 -0400 MIME-Version: 1.0 In-Reply-To: <51AC7CD4.2060801@asianux.com> References: <51A6EBC5.7040601@asianux.com> <51AC60AA.8010107@asianux.com> <51AC7546.4010002@asianux.com> <51AC7CD4.2060801@asianux.com> Date: Mon, 3 Jun 2013 14:34:42 +0300 Message-ID: Subject: Re: [PATCH v2] include/linux/skbuff.h: using '(u16) ~0U' instead of '~0U' From: Andy Shevchenko To: Chen Gang Cc: edumazet@google.com, Pravin Shelar , Mel Gorman , David Miller , Andrew Morton , "linux-kernel@vger.kernel.org" , netdev , Ben Hutchings Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1555 Lines: 46 On Mon, Jun 3, 2013 at 2:24 PM, Chen Gang wrote: > > Both 'transport_header' and 'mac_header' are u16, which are never equal > to '~0U'. > > So need use '(u16) ~0U' instead of '~0U'. > > The related warning (with EXTRA_CFLAGS=-W ARCH=m68k for allmodconfig) > include/linux/skbuff.h:1587:2: warning: comparison is always true due to limited range of data type [-Wtype-limits] > ... > > Use meaningful macro instead of hard code number, and better to > initialize 'skb->transport_header' in __alloc_skb_head(), too. Looks okay. Couple of questions below. > --- a/include/linux/skbuff.h > +++ b/include/linux/skbuff.h > @@ -40,6 +40,8 @@ > #define CHECKSUM_COMPLETE 2 > #define CHECKSUM_PARTIAL 3 > > +#define SKB_HEADER_UNSET_16 ((unsigned short) ~0U) Isn't better to use the same type as used in the structure description? > --- a/net/core/skbuff.c > +++ b/net/core/skbuff.c > @@ -200,7 +200,8 @@ struct sk_buff *__alloc_skb_head(gfp_t gfp_mask, int node) > atomic_set(&skb->users, 1); > > #ifdef NET_SKBUFF_DATA_USES_OFFSET > - skb->mac_header = (__u16) ~0U; > + skb->mac_header = SKB_HEADER_UNSET_16; > + skb->transport_header = SKB_HEADER_UNSET_16; Is it correct to assign transport_header here as well? -- With Best Regards, Andy Shevchenko -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/