From: Julia Lawall <[EMAIL PROTECTED]>

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 <[EMAIL PROTECTED]>
---

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-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to