[<prev] [next>] [day] [month] [year] [list]
Message-ID: <Pine.LNX.4.58.0712261714270.1185@pc-041.diku.dk>
Date: Wed, 26 Dec 2007 17:15:08 +0100 (MET)
From: Julia Lawall <julia@...u.dk>
To: linux-scsi@...r.kernel.org, viro@...iv.linux.org.uk,
linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org
Subject: [PATCH 3/3] drivers/scsi: Use offsetof
From: Julia Lawall <julia@...u.dk>
In the patch cc154ac64aa8d3396b187f64cef01ce67f433324, Al Viro observed
that the proper way to compute the distance between two structure fields is
to use offsetof() or a cast to a pointer to character. The same change can
be applied to a few more files.
The change was made using the following semantic patch
(http://www.emn.fr/x-info/coccinelle/)
// <smpl>
@r3 disable ptr_to_array@
type T;
T *s;
type T1, T2;
identifier fld1;
@@
(
(char *)&s->fld1 - (char *)s
|
(uint8_t *)&s->fld1 - (uint8_t *)s
|
(u8 *)&s->fld1 - (u8 *)s
|
- (T1)&s->fld1 - (T2)s
+ offsetof(T,fld1)
)
// </smpl>
Signed-off-by: Julia Lawall <julia@...u.dk>
---
diff -u -p a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c
--- a/drivers/scsi/BusLogic.c 2007-10-22 11:25:20.000000000 +0200
+++ b/drivers/scsi/BusLogic.c 2007-12-26 16:33:42.000000000 +0100
@@ -2856,7 +2856,10 @@ static int BusLogic_QueueCommand(struct
CCB->Opcode = BusLogic_InitiatorCCB_ScatterGather;
CCB->DataLength = Count * sizeof(struct BusLogic_ScatterGatherSegment);
if (BusLogic_MultiMasterHostAdapterP(HostAdapter))
- CCB->DataPointer = (unsigned int) CCB->DMA_Handle + ((unsigned long) &CCB->ScatterGatherList - (unsigned long) CCB);
+ CCB->DataPointer =
+ (unsigned int) CCB->DMA_Handle +
+ offsetof(struct BusLogic_CCB,
+ ScatterGatherList);
else
CCB->DataPointer = Virtual_to_32Bit_Virtual(CCB->ScatterGatherList);
--
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