From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ben Hutchings Subject: Re: [Patch net-next v3] net: clean up skb headers code Date: Thu, 30 May 2013 22:05:18 +0100 Message-ID: <1369947918.2414.28.camel@bwh-desktop.uk.level5networks.com> References: <1369879575-18701-1-git-send-email-amwang@redhat.com> <20130530.131603.1155012584617016387.davem@davemloft.net> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Cc: , , , To: David Miller Return-path: Received: from webmail.solarflare.com ([12.187.104.25]:50994 "EHLO webmail.solarflare.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757690Ab3E3VFX (ORCPT ); Thu, 30 May 2013 17:05:23 -0400 In-Reply-To: <20130530.131603.1155012584617016387.davem@davemloft.net> Sender: netdev-owner@vger.kernel.org List-ID: On Thu, 2013-05-30 at 13:16 -0700, David Miller wrote: > From: "David Laight" > Date: Thu, 30 May 2013 12:18:13 +0100 > > >> commit 1a37e412a0225fcba5587 (net: Use 16bits for *_headers > >> fields of struct skbuff) converts skb->*_header to u16, > >> some #if NET_SKBUFF_DATA_USES_OFFSET are now useless, > >> and to be safe, we could just use "X = ~(typeof(X))0;" > >> as suggested by David and Ben. > > > > IIRC ~(unsigned short)0 is the same as ~0 and will be -1. > > define an actual constant with value 0xffff > > The problem with doing that is that if this type is changed again, > we'lll go through this same circus changing the constant everywhere > and missing some cases. > > I absolutely want to see a version of this fix that makes sure that if > the type changes, either the constantly automatically change (that's > the "typeof(X)" approach) or the build breaks spectacularly until the > value is fixed up. Let's just give the 'invalid' value a name and define it right next to those fields. It might be worth reintroducing sk_buff_data_t too, since there was at least one place which wanted to save and restore offsets in local variables. Ben. -- Ben Hutchings, Staff Engineer, Solarflare Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.