diff options
author | Michel Dänzer <michel.daenzer@amd.com> | 2015-10-14 12:48:52 +0900 |
---|---|---|
committer | Michel Dänzer <michel@daenzer.net> | 2015-10-14 12:48:52 +0900 |
commit | 3045523de214fb7df92ee3c8482e883637504bbe (patch) | |
tree | beb8bf512e03400ec598579f90c32281c3f04aed | |
parent | 8c4a1cbd98bd8d185d489395f33302a17db643a9 (diff) | |
download | libdrm-3045523de214fb7df92ee3c8482e883637504bbe.tar.gz libdrm-3045523de214fb7df92ee3c8482e883637504bbe.tar.bz2 libdrm-3045523de214fb7df92ee3c8482e883637504bbe.zip |
Fix void pointer arithmetic in drmProcessPciDevice
Arithmetic on void pointers is a GCC extension.
CC libdrm_la-xf86drm.lo
../xf86drm.c: In function 'drmProcessPciDevice':
../xf86drm.c:3017:10: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
addr += sizeof(drmDevice);
^
../xf86drm.c:3020:10: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
addr += DRM_NODE_MAX * sizeof(void *);
^
../xf86drm.c:3023:14: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
addr += max_node_str;
^
../xf86drm.c:3035:14: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
addr += sizeof(drmPciBusInfo);
^
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r-- | xf86drm.c | 19 |
1 files changed, 10 insertions, 9 deletions
@@ -3001,21 +3001,22 @@ static int drmProcessPciDevice(drmDevicePtr *device, const char *d_name, { const int max_node_str = drmGetMaxNodeName(); int ret, i; - void *addr; + char *addr; - addr = *device = calloc(1, sizeof(drmDevice) + - (DRM_NODE_MAX * - (sizeof(void *) + max_node_str)) + - sizeof(drmPciBusInfo) + - sizeof(drmPciDeviceInfo)); + *device = calloc(1, sizeof(drmDevice) + + (DRM_NODE_MAX * (sizeof(void *) + max_node_str)) + + sizeof(drmPciBusInfo) + + sizeof(drmPciDeviceInfo)); if (!*device) return -ENOMEM; + addr = (char*)*device; + (*device)->bustype = DRM_BUS_PCI; (*device)->available_nodes = 1 << node_type; addr += sizeof(drmDevice); - (*device)->nodes = addr; + (*device)->nodes = (char**)addr; addr += DRM_NODE_MAX * sizeof(void *); for (i = 0; i < DRM_NODE_MAX; i++) { @@ -3024,7 +3025,7 @@ static int drmProcessPciDevice(drmDevicePtr *device, const char *d_name, } memcpy((*device)->nodes[node_type], node, max_node_str); - (*device)->businfo.pci = addr; + (*device)->businfo.pci = (drmPciBusInfoPtr)addr; ret = drmParsePciBusInfo(maj, min, (*device)->businfo.pci); if (ret) @@ -3033,7 +3034,7 @@ static int drmProcessPciDevice(drmDevicePtr *device, const char *d_name, // Fetch the device info if the user has requested it if (fetch_deviceinfo) { addr += sizeof(drmPciBusInfo); - (*device)->deviceinfo.pci = addr; + (*device)->deviceinfo.pci = (drmPciDeviceInfoPtr)addr; ret = drmParsePciDeviceInfo(d_name, (*device)->deviceinfo.pci); if (ret) |