From: Cong Wang <hidden> Date: 2013-05-30 02:06:29
From: Cong Wang <redacted>
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.
Cc: Ben Hutchings <redacted>
Cc: David S. Miller <davem@davemloft.net>
Cc: Simon Horman <horms@verge.net.au>
Signed-off-by: Cong Wang <redacted>
---
v2: use typeof
v3: use ~(typeof(X))0
From: David Laight <hidden> Date: 2013-05-30 11:22:26
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
David
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.
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.
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.
sk_buff_data_t was not removed, its just used for less fields.
From: Simon Horman <horms@verge.net.au> Date: 2013-05-31 00:24:33
On Thu, May 30, 2013 at 10:06:15AM +0800, Cong Wang wrote:
From: Cong Wang <redacted>
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.
Cc: Ben Hutchings <redacted>
Cc: David S. Miller <davem@davemloft.net>
Cc: Simon Horman <horms@verge.net.au>
Signed-off-by: Cong Wang <redacted>
FWIW, I would prefer to see a patch that just removes the instances
of #ifdef NET_SKBUFF_DATA_USES_OFFSET below, and then a separate
patch to clean-up the use of ~0U once some consensus is reached on
the best approach.
The reason is that I suspect that the #ifdef NET_SKBUFF_DATA_USES_OFFSET
is a bug fix for cases where it is not defined. Whereas the ~0 discussion
is more cosmetic.