: Use FIELD_SIZEOF
Subsystems (3)
PATCH 8/8 : Use FIELD_SIZEOF
From: Julia Lawall <[email protected]>
Robert P.J. Day proposed to use the macro FIELD_SIZEOF in replace of code that matches its definition.
The modification was made using the following semantic patch
(http://www.emn.fr/x-info/coccinelle/)
// <smpl>
@haskernel@
@@
#include <linux/kernel.h>
@depends on haskernel@
type t;
identifier f;
@@
- (sizeof(((t*)0)->f))
+ FIELD_SIZEOF(t, f)
@depends on haskernel@
type t;
identifier f;
@@
- sizeof(((t*)0)->f)
+ FIELD_SIZEOF(t, f)
// </smpl>
---
include/net/sctp/sctp.h 2008-02-10 18:27:30.000000000 +0100 renamed from include/net/sctp/sctp.h 2008-02-10 17:13:55.000000000 +0100 +1 -0
@@ -618,7 +618,7 @@ static inline int param_type2af(__be16 t static inline int sctp_sanity_check(void) { SCTP_ASSERT(sizeof(struct sctp_ulpevent) <- sizeof(((struct sk_buff *)0)->cb), + FIELD_SIZEOF(struct sk_buff, cb), "SCTP: ulpevent does not fit in skb!\n", return 0); return 1;
include/net/sctp/sctp.h static inline int param_type2af(__be16 t · line 624
Quoted 10 lines · Julia Lawall
include/net/sctp/sctp.h +1
-0@@ -618,7 +618,7 @@ static inline int param_type2af(__be16 tstatic inline int sctp_sanity_check (void ) { SCTP_ASSERT(sizeof(struct sctp_ulpevent) <> - sizeof(((struct sk_buff *)0)->cb), + FIELD_SIZEOF(struct sk_buff, cb), "SCTP: ulpevent does not fit in skb!\n", return 0);return 1 ;
Same here. Use BUILD_BUG_ON instead.
Quoted 10 lines · Alexey Dobriyan
Quoted 9 lines · Julia Lawall
include/net/sctp/sctp.h +1
-0@@ -618,7 +618,7 @@ static inline int param_type2af(__be16 tstatic inline int sctp_sanity_check (void ) { SCTP_ASSERT(sizeof(struct sctp_ulpevent) <>> - sizeof(((struct sk_buff *)0)->cb), + FIELD_SIZEOF(struct sk_buff, cb), "SCTP: ulpevent does not fit in skb!\n", return 0);
Quoted 3 lines
include/net/sctp/sctp.h static inline int param_type2af(__be16 t · line 624
Quoted 1 line
include/net/sctp/sctp.h +0
-0return 1 ;Same here. Use
BUILD_BUG_ONinstead.
Ack. BUILD_BUG_ON is definitely appropriate here, especially considering that SCTP_ASSERT compiles to nothing with debugging turned off.
-vlad
Quoted 10 lines
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Lksctp-developers mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/lksctp-developers