LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 8/8] : Use FIELD_SIZEOF
@ 2008-02-10 20:16 Julia Lawall
  2008-02-10 21:12 ` Alexey Dobriyan
  0 siblings, 1 reply; 3+ messages in thread
From: Julia Lawall @ 2008-02-10 20:16 UTC (permalink / raw)
  To: vladislav.yasevich, sri, lksctp-developers; +Cc: linux-kernel, kernel-janitors

From: Julia Lawall <julia@diku.dk>

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>

Signed-off-by: Julia Lawall <julia@diku.dk>

---

diff -u -p a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
--- a/include/net/sctp/sctp.h 2008-02-10 17:13:55.000000000 +0100
+++ b/include/net/sctp/sctp.h 2008-02-10 18:27:30.000000000 +0100
@@ -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;

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 8/8] : Use FIELD_SIZEOF
  2008-02-10 20:16 [PATCH 8/8] : Use FIELD_SIZEOF Julia Lawall
@ 2008-02-10 21:12 ` Alexey Dobriyan
  2008-02-11  2:23   ` [Lksctp-developers] " Vlad Yasevich
  0 siblings, 1 reply; 3+ messages in thread
From: Alexey Dobriyan @ 2008-02-10 21:12 UTC (permalink / raw)
  To: Julia Lawall
  Cc: vladislav.yasevich, sri, lksctp-developers, linux-kernel,
	kernel-janitors

On Sun, Feb 10, 2008 at 09:16:04PM +0100, Julia Lawall wrote:
> --- a/include/net/sctp/sctp.h
> +++ b/include/net/sctp/sctp.h
> @@ -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;

Same here. Use BUILD_BUG_ON instead.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Lksctp-developers] [PATCH 8/8] : Use FIELD_SIZEOF
  2008-02-10 21:12 ` Alexey Dobriyan
@ 2008-02-11  2:23   ` Vlad Yasevich
  0 siblings, 0 replies; 3+ messages in thread
From: Vlad Yasevich @ 2008-02-11  2:23 UTC (permalink / raw)
  To: Alexey Dobriyan
  Cc: Julia Lawall, kernel-janitors, linux-kernel, lksctp-developers, sri

Alexey Dobriyan wrote:
> On Sun, Feb 10, 2008 at 09:16:04PM +0100, Julia Lawall wrote:
>> --- a/include/net/sctp/sctp.h
>> +++ b/include/net/sctp/sctp.h
>> @@ -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;
> 
> Same here. Use BUILD_BUG_ON instead.

Ack. BUILD_BUG_ON is definitely appropriate here, especially considering
that SCTP_ASSERT compiles to nothing with debugging turned off.

-vlad

> 
> -------------------------------------------------------------------------
> 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
> Lksctp-developers@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/lksctp-developers
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-02-11  2:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-10 20:16 [PATCH 8/8] : Use FIELD_SIZEOF Julia Lawall
2008-02-10 21:12 ` Alexey Dobriyan
2008-02-11  2:23   ` [Lksctp-developers] " Vlad Yasevich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).