Skip to contentSkip to conversation

net: clean up skb headers code

PATCH Superseded Cong Wang 6 participants 19 messages May 29, 2013 – May 30, 2013

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Cong Wang

author
#0 lore raw

PATCH 1/1 net: clean up skb headers code

commit 1a37e412a0225fcba5587 (net: Use 16bits for *_headers fields of struct skbuff) converts skb->*_header to u16, therefore 1) we could just use 0xFFFFF instead of (__u16) ~0U
2) some #if NET_SKBUFF_DATA_USES_OFFSET is useless now.

Cc David S. Miller <[email protected]>
Cc Simon Horman <[email protected]>

---

include/linux/skbuff.h +2 -2
index 8f2b830..3c896b7 100644
@@ -1584,7 +1584,7 @@ static inline void skb_set_inner_mac_header(struct sk_buff *skb,
 }
 static inline bool skb_transport_header_was_set(const struct sk_buff *skb)
 {
-	return skb->transport_header != ~0U;
+	return skb->transport_header != 0xFFFF;
 }
 
 static inline unsigned char *skb_transport_header(const struct sk_buff *skb)
@@ -1627,7 +1627,7 @@ static inline unsigned char *skb_mac_header(const struct sk_buff *skb)
 
 static inline int skb_mac_header_was_set(const struct sk_buff *skb)
 {
-	return skb->mac_header != ~0U;
+	return skb->mac_header != 0xFFFF;
 }
 
 static inline void skb_reset_mac_header(struct sk_buff *skb)
net/core/skbuff.c +5 -11
index f45de07..0c3742f 100644
@@ -199,9 +199,7 @@ struct sk_buff *__alloc_skb_head(gfp_t gfp_mask, int node)
 	skb->truesize = sizeof(struct sk_buff);
 	atomic_set(&skb->users, 1);
 
-#ifdef NET_SKBUFF_DATA_USES_OFFSET
-	skb->mac_header = (__u16) ~0U;
-#endif
+	skb->mac_header = 0xFFFF;
 out:
 	return skb;
 }
@@ -275,10 +273,8 @@ struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask,
 	skb->data = data;
 	skb_reset_tail_pointer(skb);
 	skb->end = skb->tail + size;
-#ifdef NET_SKBUFF_DATA_USES_OFFSET
-	skb->mac_header = (__u16) ~0U;
-	skb->transport_header = (__u16) ~0U;
-#endif
+	skb->mac_header = 0xFFFF;
+	skb->transport_header = 0xFFFF;
 
 	/* make sure we initialize shinfo sequentially */
 	shinfo = skb_shinfo(skb);
@@ -344,10 +340,8 @@ struct sk_buff *build_skb(void *data, unsigned int frag_size)
 	skb->data = data;
 	skb_reset_tail_pointer(skb);
 	skb->end = skb->tail + size;
-#ifdef NET_SKBUFF_DATA_USES_OFFSET
-	skb->mac_header = (__u16) ~0U;
-	skb->transport_header = (__u16) ~0U;
-#endif
+	skb->mac_header = 0xFFFF;
+	skb->transport_header = 0xFFFF;
 
 	/* make sure we initialize shinfo sequentially */
 	shinfo = skb_shinfo(skb);
maintainer
#1 lore raw

From: Cong Wang <[email protected]>
Date: Wed, 29 May 2013 14:09:00 +0800

Quoted 9 lines

commit 1a37e412a0225fcba5587 (net: Use 16bits for *_headers fields of struct skbuff) converts skb->*_header to u16, therefore 1) we could just use 0xFFFFF instead of (__u16) ~0U
2) some #if NET_SKBUFF_DATA_USES_OFFSET is useless now.

Cc David S. Miller <[email protected]>
Cc Simon Horman <[email protected]>

I want to use something that will either break the build or automatically work if the type changes again.

So something like "X = (typeof(X)) ~0U;".

author
#2 lore raw
Quoted 9 lines · David Miller

From: Cong Wang <[email protected]>
Date: Wed, 29 May 2013 14:09:00 +0800

Quoted 6 lines

commit 1a37e412a0225fcba5587 (net: Use 16bits for *_headers fields of struct skbuff) converts skb->*_header to u16, therefore 1) we could just use 0xFFFFF instead of (__u16) ~0U
2) some #if NET_SKBUFF_DATA_USES_OFFSET is useless now.

Quoted 8 lines
Quoted 3 lines
Cc David S. Miller <[email protected]>
Cc Simon Horman <[email protected]>

I want to use something that will either break the build or automatically work if the type changes again.

So something like "X = (typeof(X)) ~0U;".

Yeah, this is even better. I will update this patch.

Thanks.

maintainer
#3 lore raw

From: Cong Wang <[email protected]>
Date: Wed, 29 May 2013 14:48:06 +0800

Quoted 14 lines · David Miller
Quoted 13 lines

From: Cong Wang <[email protected]>
Date: Wed, 29 May 2013 14:09:00 +0800

Quoted 9 lines

commit 1a37e412a0225fcba5587 (net: Use 16bits for *_headers fields of struct skbuff) converts skb->*_header to u16, therefore 1) we could just use 0xFFFFF instead of (__u16) ~0U
2) some #if NET_SKBUFF_DATA_USES_OFFSET is useless now.

Cc David S. Miller <[email protected]>
Cc Simon Horman <[email protected]>
Quoted 6 lines
Quoted 4 lines

I want to use something that will either break the build or automatically work if the type changes again.

So something like "X = (typeof(X)) ~0U;".

Yeah, this is even better. I will update this patch.

Please sumbit it against Simon's series, which I'm about to push to net-next.

Thanks.

#4 lore raw
In reply to David Miller
Quoted 9 lines · David Miller

From: Cong Wang <[email protected]>
Date: Wed, 29 May 2013 14:09:00 +0800

Quoted 6 lines

commit 1a37e412a0225fcba5587 (net: Use 16bits for *_headers fields of struct skbuff) converts skb->*_header to u16, therefore 1) we could just use 0xFFFFF instead of (__u16) ~0U
2) some #if NET_SKBUFF_DATA_USES_OFFSET is useless now.

Quoted 8 lines
Quoted 3 lines
Cc David S. Miller <[email protected]>
Cc Simon Horman <[email protected]>

I want to use something that will either break the build or automatically work if the type changes again.

So something like "X = (typeof(X)) ~0U;".

I think you mean ~(typeof(X))0.

Ben.

Signature · 3 lines
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.
#5 lore raw
Quoted 14 lines · Ben Hutchings
Quoted 13 lines · David Miller

From: Cong Wang <[email protected]>
Date: Wed, 29 May 2013 14:09:00 +0800

Quoted 9 lines

commit 1a37e412a0225fcba5587 (net: Use 16bits for *_headers fields of struct skbuff) converts skb->*_header to u16, therefore 1) we could just use 0xFFFFF instead of (__u16) ~0U
2) some #if NET_SKBUFF_DATA_USES_OFFSET is useless now.

Cc David S. Miller <[email protected]>
Cc Simon Horman <[email protected]>
Quoted 6 lines
Quoted 4 lines

I want to use something that will either break the build or automatically work if the type changes again.

So something like "X = (typeof(X)) ~0U;".

I think you mean ~(typeof(X))0.

Am I wrong or you should cast the value once again, like this:

((typeof(X))~(typeof(X))0)

because the ~ operator will implicitly cast the argument to int (if I remember correctly).

Cheers,

Signature · 4 lines
Antonio Quartulli

..each of us alone is worth nothing..
Ernesto "Che" Guevara
#6 lore raw
Quoted 20 lines · Antonio Quartulli
Quoted 19 lines · Ben Hutchings
Quoted 17 lines · David Miller

From: Cong Wang <[email protected]>
Date: Wed, 29 May 2013 14:09:00 +0800

Quoted 9 lines

commit 1a37e412a0225fcba5587 (net: Use 16bits for *_headers fields of struct skbuff) converts skb->*_header to u16, therefore 1) we could just use 0xFFFFF instead of (__u16) ~0U
2) some #if NET_SKBUFF_DATA_USES_OFFSET is useless now.

Cc David S. Miller <[email protected]>
Cc Simon Horman <[email protected]>

I want to use something that will either break the build or automatically work if the type changes again.

So something like "X = (typeof(X)) ~0U;".

Quoted 8 lines
Quoted 1 line

I think you mean ~(typeof(X))0.

Am I wrong or you should cast the value once again, like this:

((typeof(X))~(typeof(X))0)

because the ~ operator will implicitly cast the argument to int (if I remember correctly).

It will promote to at least int, but that still results in the right value and doesn't provoke a warning. Try this test (with -Wall -Wextra):

#include <stdio.h>

#define ALL_ONES(v) (~(typeof(v))0)
/* #define ALL_ONES(v) (typeof(v))~0U) */

int main(void)

{
    char a = ALL_ONES(a);
    unsigned char b = ALL_ONES(b);
    short c = ALL_ONES(c);
    unsigned short d = ALL_ONES(d);
    int e = ALL_ONES(e);
    unsigned int f = ALL_ONES(f);
    long g = ALL_ONES(g);
    unsigned long h = ALL_ONES(h);
    long long i = ALL_ONES(i);
    unsigned long long j = ALL_ONES(j);

    printf("%hhx %hhx %hx %hx %x %x %lx %lx %llx %llx\n",
	   a, b, c, d, e, f, g, h, i, j);
    return 0;
}
Signature · 3 lines
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.
author
#15 lore raw
In reply to Ben Hutchings
Quoted 6 lines · Ben Hutchings
Quoted 2 lines · David Miller

So something like "X = (typeof(X)) ~0U;".

I think you mean ~(typeof(X))0.

Good catch, I will change it to ~(typeof(X))0.

#7 lore raw
In reply to Ben Hutchings
Quoted 25 lines · Ben Hutchings
Quoted 24 lines · Antonio Quartulli
Quoted 14 lines · Ben Hutchings
Quoted 13 lines · David Miller

From: Cong Wang <[email protected]>
Date: Wed, 29 May 2013 14:09:00 +0800

Quoted 9 lines

commit 1a37e412a0225fcba5587 (net: Use 16bits for *_headers fields of struct skbuff) converts skb->*_header to u16, therefore 1) we could just use 0xFFFFF instead of (__u16) ~0U
2) some #if NET_SKBUFF_DATA_USES_OFFSET is useless now.

Cc David S. Miller <[email protected]>
Cc Simon Horman <[email protected]>
Quoted 6 lines
Quoted 4 lines

I want to use something that will either break the build or automatically work if the type changes again.

So something like "X = (typeof(X)) ~0U;".

I think you mean ~(typeof(X))0.

Am I wrong or you should cast the value once again, like this:

Quoted 8 lines
Quoted 4 lines

((typeof(X))~(typeof(X))0)

because the ~ operator will implicitly cast the argument to int (if I remember correctly).

It will promote to at least int, but that still results in the right value and doesn't provoke a warning. Try this test (with -Wall -Wextra):

thanks for the test code Ben.

Yeah it gives the results you expected. Then I don't know why somebody suggested us to do this double cast in batman-adv when we wanted to obtain the same.

At this point I'll remove the double cast in our code too.

Thanks.

Cheers,

Signature · 4 lines
Antonio Quartulli

..each of us alone is worth nothing..
Ernesto "Che" Guevara
maintainer
#17 lore raw
In reply to Ben Hutchings

From: Ben Hutchings <[email protected]>
Date: Wed, 29 May 2013 20:34:33 +0100

Quoted 14 lines · David Miller
Quoted 13 lines

From: Cong Wang <[email protected]>
Date: Wed, 29 May 2013 14:09:00 +0800

Quoted 9 lines

commit 1a37e412a0225fcba5587 (net: Use 16bits for *_headers fields of struct skbuff) converts skb->*_header to u16, therefore 1) we could just use 0xFFFFF instead of (__u16) ~0U
2) some #if NET_SKBUFF_DATA_USES_OFFSET is useless now.

Cc David S. Miller <[email protected]>
Cc Simon Horman <[email protected]>
Quoted 6 lines
Quoted 4 lines

I want to use something that will either break the build or automatically work if the type changes again.

So something like "X = (typeof(X)) ~0U;".

I think you mean ~(typeof(X))0.

Take a look at what that does for ~(u8)0.

We had a bug fix in this are recently in ieee802154 if I remember correctly.

#8 lore raw
In reply to Ben Hutchings
Quoted 24 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

I want to use something that will either break the build or automatically work if the type changes again.

So something like "X = (typeof(X)) ~0U;".

Quoted 8 lines
Quoted 1 line

I think you mean ~(typeof(X))0.

Am I wrong or you should cast the value once again, like this:

((typeof(X))~(typeof(X))0)

because the ~ operator will implicitly cast the argument to int (if I remember correctly).

It will promote to at least int, but that still results in the right value and doesn't provoke a warning. Try this test (with -Wall -Wextra):

#include <stdio.h>

#define ALL_ONES(v) (~(typeof(v))0)
/* #define ALL_ONES(v) (typeof(v))~0U) */

int main(void)

Quoted 16 lines
{
    char a = ALL_ONES(a);
    unsigned char b = ALL_ONES(b);
    short c = ALL_ONES(c);
    unsigned short d = ALL_ONES(d);
    int e = ALL_ONES(e);
    unsigned int f = ALL_ONES(f);
    long g = ALL_ONES(g);
    unsigned long h = ALL_ONES(h);
    long long i = ALL_ONES(i);
    unsigned long long j = ALL_ONES(j);

    printf("%hhx %hhx %hx %hx %x %x %lx %lx %llx %llx\n",
	   a, b, c, d, e, f, g, h, i, j);
    return 0;
}

The printf format is masking the high bits for you. If you change to:

	printf("%x %x %x %x %x %x %lx %lx %llx %llx\n", ...)

you get different values.
To get the 'expected' values you need casts both sides of the ~

David

#9 lore raw
Quoted 41 lines · David Laight
Quoted 24 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

I want to use something that will either break the build or automatically work if the type changes again.

So something like "X = (typeof(X)) ~0U;".

Quoted 8 lines
Quoted 1 line

I think you mean ~(typeof(X))0.

Am I wrong or you should cast the value once again, like this:

((typeof(X))~(typeof(X))0)

because the ~ operator will implicitly cast the argument to int (if I remember correctly).

It will promote to at least int, but that still results in the right value and doesn't provoke a warning. Try this test (with -Wall -Wextra):

#include <stdio.h>

#define ALL_ONES(v) (~(typeof(v))0)
/* #define ALL_ONES(v) (typeof(v))~0U) */

int main(void)

Quoted 16 lines
{
    char a = ALL_ONES(a);
    unsigned char b = ALL_ONES(b);
    short c = ALL_ONES(c);
    unsigned short d = ALL_ONES(d);
    int e = ALL_ONES(e);
    unsigned int f = ALL_ONES(f);
    long g = ALL_ONES(g);
    unsigned long h = ALL_ONES(h);
    long long i = ALL_ONES(i);
    unsigned long long j = ALL_ONES(j);

    printf("%hhx %hhx %hx %hx %x %x %lx %lx %llx %llx\n",
	   a, b, c, d, e, f, g, h, i, j);
    return 0;
}
Quoted 5 lines

The printf format is masking the high bits for you. If you change to:

	printf("%x %x %x %x %x %x %lx %lx %llx %llx\n", ...)

you get different values.
To get the 'expected' values you need casts both sides of the ~

I tried with

19 printf("%x %x %x %x %x %x %lx %lx %llx %llx\n",

but I still see all FF.

Somewhere else we have some hidden conversion?

Cheers,

Signature · 4 lines
Antonio Quartulli

..each of us alone is worth nothing..
Ernesto "Che" Guevara
#10 lore raw
Quoted 47 lines
Quoted 41 lines
Quoted 24 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

I want to use something that will either break the build or automatically work if the type changes again.

So something like "X = (typeof(X)) ~0U;".

Quoted 8 lines
Quoted 1 line

I think you mean ~(typeof(X))0.

Am I wrong or you should cast the value once again, like this:

((typeof(X))~(typeof(X))0)

because the ~ operator will implicitly cast the argument to int (if I remember correctly).

It will promote to at least int, but that still results in the right value and doesn't provoke a warning. Try this test (with -Wall -Wextra):

#include <stdio.h>

#define ALL_ONES(v) (~(typeof(v))0)
/* #define ALL_ONES(v) (typeof(v))~0U) */

int main(void)

Quoted 16 lines
{
    char a = ALL_ONES(a);
    unsigned char b = ALL_ONES(b);
    short c = ALL_ONES(c);
    unsigned short d = ALL_ONES(d);
    int e = ALL_ONES(e);
    unsigned int f = ALL_ONES(f);
    long g = ALL_ONES(g);
    unsigned long h = ALL_ONES(h);
    long long i = ALL_ONES(i);
    unsigned long long j = ALL_ONES(j);

    printf("%hhx %hhx %hx %hx %x %x %lx %lx %llx %llx\n",
	   a, b, c, d, e, f, g, h, i, j);
    return 0;
}
Quoted 5 lines

The printf format is masking the high bits for you. If you change to:

	printf("%x %x %x %x %x %x %lx %lx %llx %llx\n", ...)

you get different values.
To get the 'expected' values you need casts both sides of the ~

Quoted 7 lines

I tried with

19 printf("%x %x %x %x %x %x %lx %lx %llx %llx\n",

but I still see all FF.

Somewhere else we have some hidden conversion?

Of course - we need to look at the value that ALL_ONES() generates in an expression. So the test print needs to be:

	printf("%hhx %hhx %hx %hx %x %x %lx %lx %llx %llx\n",
		ALL_ONES(a), ALL_ONES(b), ALL_ONES(c), ALL_ONES(d),
		ALL_ONES(e), ALL_ONES(f), ALL_ONES(g), ALL_ONES(h),
		ALL_ONES(i), ALL_ONES(j));

which then gives 0xffffffff for the first 4 entries.

David

#11 lore raw
Quoted 7 lines

Of course - we need to look at the value that ALL_ONES() generates in an expression. So the test print needs to be:

	printf("%hhx %hhx %hx %hx %x %x %lx %lx %llx %llx\n",
		ALL_ONES(a), ALL_ONES(b), ALL_ONES(c), ALL_ONES(d),
		ALL_ONES(e), ALL_ONES(f), ALL_ONES(g), ALL_ONES(h),
		ALL_ONES(i), ALL_ONES(j));

which then gives 0xffffffff for the first 4 entries.

Except I copied the wrong format line :-( It should be:
printf("%x %x %x %x %x %x %lx %lx %llx %llx\n",
ALL_ONES(a), ALL_ONES(b), ALL_ONES(c), ALL_ONES(d), ALL_ONES(e), ALL_ONES(f), ALL_ONES(g), ALL_ONES(h), ALL_ONES(i), ALL_ONES(j));

David

#14 lore raw
In reply to David Laight
Quoted 55 lines · David Laight
Quoted 47 lines
Quoted 41 lines
Quoted 24 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

I want to use something that will either break the build or automatically work if the type changes again.

So something like "X = (typeof(X)) ~0U;".

Quoted 8 lines
Quoted 1 line

I think you mean ~(typeof(X))0.

Am I wrong or you should cast the value once again, like this:

((typeof(X))~(typeof(X))0)

because the ~ operator will implicitly cast the argument to int (if I remember correctly).

It will promote to at least int, but that still results in the right value and doesn't provoke a warning. Try this test (with -Wall -Wextra):

#include <stdio.h>

#define ALL_ONES(v) (~(typeof(v))0)
/* #define ALL_ONES(v) (typeof(v))~0U) */

int main(void)

Quoted 16 lines
{
    char a = ALL_ONES(a);
    unsigned char b = ALL_ONES(b);
    short c = ALL_ONES(c);
    unsigned short d = ALL_ONES(d);
    int e = ALL_ONES(e);
    unsigned int f = ALL_ONES(f);
    long g = ALL_ONES(g);
    unsigned long h = ALL_ONES(h);
    long long i = ALL_ONES(i);
    unsigned long long j = ALL_ONES(j);

    printf("%hhx %hhx %hx %hx %x %x %lx %lx %llx %llx\n",
	   a, b, c, d, e, f, g, h, i, j);
    return 0;
}
Quoted 5 lines

The printf format is masking the high bits for you. If you change to:

	printf("%x %x %x %x %x %x %lx %lx %llx %llx\n", ...)

you get different values.
To get the 'expected' values you need casts both sides of the ~

Quoted 7 lines

I tried with

19 printf("%x %x %x %x %x %x %lx %lx %llx %llx\n",

but I still see all FF.

Somewhere else we have some hidden conversion?

Quoted 7 lines

Of course - we need to look at the value that ALL_ONES() generates in an expression. So the test print needs to be:

	printf("%hhx %hhx %hx %hx %x %x %lx %lx %llx %llx\n",
		ALL_ONES(a), ALL_ONES(b), ALL_ONES(c), ALL_ONES(d),
		ALL_ONES(e), ALL_ONES(f), ALL_ONES(g), ALL_ONES(h),
		ALL_ONES(i), ALL_ONES(j));

which then gives 0xffffffff for the first 4 entries.

It gives all FF for every argument. So, I'm not understanding the problem..this is what Ben wanted to achieve, no?

Cheers,

Signature · 4 lines
Antonio Quartulli

..each of us alone is worth nothing..
Ernesto "Che" Guevara
#12 lore raw
In reply to David Laight

Review

Quoted 13 lines · David Laight
Quoted 7 lines

Of course - we need to look at the value that ALL_ONES() generates in an expression. So the test print needs to be:

	printf("%hhx %hhx %hx %hx %x %x %lx %lx %llx %llx\n",
		ALL_ONES(a), ALL_ONES(b), ALL_ONES(c), ALL_ONES(d),
		ALL_ONES(e), ALL_ONES(f), ALL_ONES(g), ALL_ONES(h),
		ALL_ONES(i), ALL_ONES(j));

which then gives 0xffffffff for the first 4 entries.

Except I copied the wrong format line :-( It should be:

(quoted diff) +0 -0
 	printf("%x %x %x %x %x %x %lx %lx %llx %llx\n",
 		ALL_ONES(a), ALL_ONES(b), ALL_ONES(c), ALL_ONES(d),
 		ALL_ONES(e), ALL_ONES(f), ALL_ONES(g), ALL_ONES(h),
 		ALL_ONES(i), ALL_ONES(j));

Oh ok, I see the issue now.

So the problem is that this value gets bigger than what the maximal value for the type passed as argument is supposed to be.

I think the issue is clear now and why a double cast is good.

Cheers,

Signature · 4 lines
Antonio Quartulli

..each of us alone is worth nothing..
Ernesto "Che" Guevara
#16 lore raw
In reply to Cong Wang

Hello.

Quoted 6 lines · Cong Wang
Quoted 3 lines
Quoted 1 line

So something like "X = (typeof(X)) ~0U;".

I think you mean ~(typeof(X))0.

Good catch,

I doubt it.

Quoted 1 line

I will change it to ~(typeof(X))0.

Then (typeof(X))0 will be promoted to *int* before doing ~.

WBR, Sergei

#13 lore raw
In reply to Antonio Quartulli
Quoted 6 lines

Review

Quoted 5 lines

Except I copied the wrong format line :-( It should be:

(quoted diff) +0 -0
 	printf("%x %x %x %x %x %x %lx %lx %llx %llx\n",
 		ALL_ONES(a), ALL_ONES(b), ALL_ONES(c), ALL_ONES(d),
 		ALL_ONES(e), ALL_ONES(f), ALL_ONES(g), ALL_ONES(h),
 		ALL_ONES(i), ALL_ONES(j));
Quoted 6 lines

Oh ok, I see the issue now.

So the problem is that this value gets bigger than what the maximal value for the type passed as argument is supposed to be.

I think the issue is clear now and why a double cast is good.

It is much clearer to just use 0xffff. Although a named #define constant is more appropriate for the code itself.

David

#18 lore raw
In reply to David Miller
Quoted 20 lines · David Miller

From: Ben Hutchings <[email protected]>
Date: Wed, 29 May 2013 20:34:33 +0100

Quoted 17 lines · David Miller
Quoted 16 lines

From: Cong Wang <[email protected]>
Date: Wed, 29 May 2013 14:09:00 +0800

Quoted 9 lines

commit 1a37e412a0225fcba5587 (net: Use 16bits for *_headers fields of struct skbuff) converts skb->*_header to u16, therefore 1) we could just use 0xFFFFF instead of (__u16) ~0U
2) some #if NET_SKBUFF_DATA_USES_OFFSET is useless now.

Cc David S. Miller <[email protected]>
Cc Simon Horman <[email protected]>

I want to use something that will either break the build or automatically work if the type changes again.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

So something like "X = (typeof(X)) ~0U;".

I think you mean ~(typeof(X))0.

Take a look at what that does for ~(u8)0.

We had a bug fix in this are recently in ieee802154 if I remember correctly.

It's fine if you assign the result to X. The second cast is needed if you need the temporary value to have the type of X, but that's not needed here. (Of course it may be promoted as soon as you do anything other than assign to X...)

Ben.

Signature · 3 lines
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.