On GCC 4.1 and later, our offsetof() winds up being __builtin_offsetof(),
which is constant to GCC, so as a nice benefit this commit also fixes two
GCC 4.7 warnings:
.../dirhash.h:97:95: warning: variably modified 'dh_firstfree' at file scope
.../vdevice.h:145:2: warning: variably modified '_ArrayTables' at file scope
There are more offsetof() candidates I need to get to but since those two
fix warnings, I commit them now.
UCHAR Description[64]; /* array description */
UCHAR CreateManager[16]; /* who created it */
-#define ArrayDescript_3_0_size ((unsigned)(ULONG_PTR)&((struct _ArrayDescript *)0)->bCheckSum31)
+#define ArrayDescript_3_0_size offsetof(struct _ArrayDescript, bCheckSum31)
#define ArrayDescript_3_1_size 512
UCHAR bCheckSum31; /* new check sum */
} VDevice;
-#define ARRAY_VDEV_SIZE ((UINT)(ULONG_PTR)&((PVDevice)0)->u+sizeof(RaidArray))
-#define DISK_VDEV_SIZE ((UINT)(ULONG_PTR)&((PVDevice)0)->u+sizeof(Device))
+#define ARRAY_VDEV_SIZE (offsetof(VDevice, u) + sizeof(RaidArray))
+#define DISK_VDEV_SIZE (offsetof(VDevice, u) + sizeof(Device))
-#define Map2pVDevice(pDev) ((PVDevice)((UINT_PTR)pDev - (UINT)(UINT_PTR)&((PVDevice)0)->u.disk))
+#define Map2pVDevice(pDev) ((PVDevice)((UINT_PTR)pDev - offsetof(VDevice, u.disk)))
/*
* bUserDeviceMode
*
*/
#define DIRECTSIZ(namlen) \
- (((uintptr_t)&((struct direct *)0)->d_name + \
+ ((offsetof(struct direct, d_name) + \
((namlen)+1)*sizeof(((struct direct *)0)->d_name[0]) + 3) & ~3)
#if (BYTE_ORDER == LITTLE_ENDIAN)
#define DIRSIZ(oldfmt, dp) \