[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <Pine.LNX.4.64.0802102114330.23906@ask.diku.dk>
Date: Sun, 10 Feb 2008 21:15:09 +0100 (CET)
From: Julia Lawall <julia@...u.dk>
To: gregkh@...e.de, linux-usb-devel@...ts.sourceforge.net
Cc: linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org
Subject: [PATCH 7/8] drivers/usb: Use FIELD_SIZEOF
From: Julia Lawall <julia@...u.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@...u.dk>
---
diff -u -p a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
--- a/drivers/usb/atm/usbatm.c 2007-09-20 18:59:00.000000000 +0200
+++ b/drivers/usb/atm/usbatm.c 2008-02-10 18:13:48.000000000 +0100
@@ -1349,7 +1349,7 @@ static int __init usbatm_usb_init(void)
{
dbg("%s: driver version %s", __func__, DRIVER_VERSION);
- if (sizeof(struct usbatm_control) > sizeof(((struct sk_buff *) 0)->cb)) {
+ if (sizeof(struct usbatm_control) > FIELD_SIZEOF(struct sk_buff, cb)) {
printk(KERN_ERR "%s unusable with this kernel!\n", usbatm_driver_name);
return -EIO;
}
diff -u -p a/drivers/usb/serial/io_usbvend.h b/drivers/usb/serial/io_usbvend.h
--- a/drivers/usb/serial/io_usbvend.h 2007-07-20 15:28:33.000000000 +0200
+++ b/drivers/usb/serial/io_usbvend.h 2008-02-10 18:15:37.000000000 +0100
@@ -514,10 +514,10 @@ struct edge_manuf_descriptor {
#define MANUF_BOARD_REV_A 1 // First rev of 251+Netchip design
-#define MANUF_SERNUM_LENGTH sizeof(((struct edge_manuf_descriptor *)0)->SerialNumber)
-#define MANUF_ASSYNUM_LENGTH sizeof(((struct edge_manuf_descriptor *)0)->AssemblyNumber)
-#define MANUF_OEMASSYNUM_LENGTH sizeof(((struct edge_manuf_descriptor *)0)->OemAssyNumber)
-#define MANUF_MANUFDATE_LENGTH sizeof(((struct edge_manuf_descriptor *)0)->ManufDate)
+#define MANUF_SERNUM_LENGTH FIELD_SIZEOF(struct edge_manuf_descriptor, SerialNumber)
+#define MANUF_ASSYNUM_LENGTH FIELD_SIZEOF(struct edge_manuf_descriptor, AssemblyNumber)
+#define MANUF_OEMASSYNUM_LENGTH FIELD_SIZEOF(struct edge_manuf_descriptor, OemAssyNumber)
+#define MANUF_MANUFDATE_LENGTH FIELD_SIZEOF(struct edge_manuf_descriptor, ManufDate)
#define MANUF_ION_CONFIG_DIAG_NO_LOOP 0x20 // As below but no ext loopback test
#define MANUF_ION_CONFIG_DIAG 0x40 // 930 based device: 1=Run h/w diags, 0=norm
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists