Kaydet (Commit) d0c9cb0c authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Clean up C-style casts from pointers to void

Change-Id: I7e6315bf2a2e3d6e089ef8f5eacc69d2b413374a
üst 3a32d02b
......@@ -101,7 +101,7 @@ inline ds_status initDSProfile(ds_profile** p, const char* version)
if (p == NULL) return DS_INVALID_PROFILE;
profile = (ds_profile*)malloc(sizeof(ds_profile));
profile = static_cast<ds_profile*>(malloc(sizeof(ds_profile)));
if (profile == NULL) return DS_MEMORY_ERROR;
memset(profile, 0, sizeof(ds_profile));
......@@ -109,7 +109,7 @@ inline ds_status initDSProfile(ds_profile** p, const char* version)
clGetPlatformIDs(0, NULL, &numPlatforms);
if (numPlatforms != 0)
{
platforms = (cl_platform_id*)malloc(numPlatforms * sizeof(cl_platform_id));
platforms = static_cast<cl_platform_id*>(malloc(numPlatforms * sizeof(cl_platform_id)));
if (platforms == NULL)
{
status = DS_MEMORY_ERROR;
......@@ -136,7 +136,7 @@ inline ds_status initDSProfile(ds_profile** p, const char* version)
}
if (numDevices != 0)
{
devices = (cl_device_id*)malloc(numDevices * sizeof(cl_device_id));
devices = static_cast<cl_device_id*>(malloc(numDevices * sizeof(cl_device_id)));
if (devices == NULL)
{
status = DS_MEMORY_ERROR;
......@@ -145,7 +145,7 @@ inline ds_status initDSProfile(ds_profile** p, const char* version)
}
profile->numDevices = numDevices + 1; // +1 to numDevices to include the native CPU
profile->devices = (ds_device*)malloc(profile->numDevices * sizeof(ds_device));
profile->devices = static_cast<ds_device*>(malloc(profile->numDevices * sizeof(ds_device)));
if (profile->devices == NULL)
{
profile->numDevices = 0;
......@@ -185,13 +185,13 @@ inline ds_status initDSProfile(ds_profile** p, const char* version)
clGetDeviceInfo(profile->devices[next].oclDeviceID, CL_DEVICE_NAME
, DS_DEVICE_NAME_LENGTH, &buffer, NULL);
length = strlen(buffer);
profile->devices[next].oclDeviceName = (char*)malloc(length + 1);
profile->devices[next].oclDeviceName = static_cast<char*>(malloc(length + 1));
memcpy(profile->devices[next].oclDeviceName, buffer, length + 1);
clGetDeviceInfo(profile->devices[next].oclDeviceID, CL_DRIVER_VERSION
, DS_DEVICE_NAME_LENGTH, &buffer, NULL);
length = strlen(buffer);
profile->devices[next].oclDriverVersion = (char*)malloc(length + 1);
profile->devices[next].oclDriverVersion = static_cast<char*>(malloc(length + 1));
memcpy(profile->devices[next].oclDriverVersion, buffer, length + 1);
}
}
......@@ -390,7 +390,7 @@ inline ds_status readProFile(const char* fileName, char** content, size_t* conte
size = pos;
rewind(input);
binary = (char*)malloc(size);
binary = static_cast<char*>(malloc(size));
if (binary == NULL)
{
fclose(input);
......
......@@ -219,7 +219,7 @@ ds_status releaseScore(void* score)
{
if (NULL != score)
{
delete (LibreOfficeDeviceScore*)score;
delete static_cast<LibreOfficeDeviceScore*>(score);
}
return DS_SUCCESS;
}
......@@ -270,8 +270,8 @@ ds_status evaluateScoreForDevice(ds_device* device, void* evalData)
{
/* No 64-bit float support */
device->score = (void*)new LibreOfficeDeviceScore;
((LibreOfficeDeviceScore*)device->score)->fTime = DBL_MAX;
((LibreOfficeDeviceScore*)device->score)->bNoCLErrors = true;
static_cast<LibreOfficeDeviceScore*>(device->score)->fTime = DBL_MAX;
static_cast<LibreOfficeDeviceScore*>(device->score)->bNoCLErrors = true;
SAL_INFO("opencl.device", "... no fp64 support");
}
else
......@@ -295,14 +295,14 @@ ds_status evaluateScoreForDevice(ds_device* device, void* evalData)
size_t length;
char* buildLog;
clStatus = clGetProgramBuildInfo(clProgram, device->oclDeviceID, CL_PROGRAM_BUILD_LOG, 0, NULL, &length);
buildLog = (char*)malloc(length);
buildLog = static_cast<char*>(malloc(length));
clGetProgramBuildInfo(clProgram, device->oclDeviceID, CL_PROGRAM_BUILD_LOG, length, buildLog, &length);
SAL_INFO("opencl.device", "Build Errors:\n" << buildLog);
free(buildLog);
device->score = (void*)new LibreOfficeDeviceScore;
((LibreOfficeDeviceScore*)device->score)->fTime = DBL_MAX;
((LibreOfficeDeviceScore*)device->score)->bNoCLErrors = false;
static_cast<LibreOfficeDeviceScore*>(device->score)->fTime = DBL_MAX;
static_cast<LibreOfficeDeviceScore*>(device->score)->bNoCLErrors = false;
}
else
{
......@@ -311,7 +311,7 @@ ds_status evaluateScoreForDevice(ds_device* device, void* evalData)
timerStart(&kernelTime);
/* Run kernel */
LibreOfficeDeviceEvaluationIO* testData = (LibreOfficeDeviceEvaluationIO*)evalData;
LibreOfficeDeviceEvaluationIO* testData = static_cast<LibreOfficeDeviceEvaluationIO*>(evalData);
cl_kernel clKernel = clCreateKernel(clProgram, "DynamicKernel", &clStatus);
DS_CHECK_STATUS(clStatus, "evaluateScoreForDevice::clCreateKernel");
cl_mem clResult = clCreateBuffer(clContext, CL_MEM_WRITE_ONLY | CL_MEM_USE_HOST_PTR, sizeof(cl_double) * testData->outputSize, &testData->output[0], &clStatus);
......@@ -347,8 +347,8 @@ ds_status evaluateScoreForDevice(ds_device* device, void* evalData)
clReleaseKernel(clKernel);
device->score = (void*)new LibreOfficeDeviceScore;
((LibreOfficeDeviceScore*)device->score)->fTime = timerCurrent(&kernelTime);
((LibreOfficeDeviceScore*)device->score)->bNoCLErrors = true;
static_cast<LibreOfficeDeviceScore*>(device->score)->fTime = timerCurrent(&kernelTime);
static_cast<LibreOfficeDeviceScore*>(device->score)->bNoCLErrors = true;
}
clReleaseProgram(clProgram);
......@@ -363,7 +363,7 @@ ds_status evaluateScoreForDevice(ds_device* device, void* evalData)
timer kernelTime;
timerStart(&kernelTime);
LibreOfficeDeviceEvaluationIO* testData = (LibreOfficeDeviceEvaluationIO*)evalData;
LibreOfficeDeviceEvaluationIO* testData = static_cast<LibreOfficeDeviceEvaluationIO*>(evalData);
for (unsigned long j = 0; j < testData->outputSize; j++)
{
double fAverage = 0.0f;
......@@ -386,10 +386,10 @@ ds_status evaluateScoreForDevice(ds_device* device, void* evalData)
float fInterpretTailFactor = 10.0;
device->score = (void*)new LibreOfficeDeviceScore;
((LibreOfficeDeviceScore*)device->score)->fTime = timerCurrent(&kernelTime);
((LibreOfficeDeviceScore*)device->score)->bNoCLErrors = true;
static_cast<LibreOfficeDeviceScore*>(device->score)->fTime = timerCurrent(&kernelTime);
static_cast<LibreOfficeDeviceScore*>(device->score)->bNoCLErrors = true;
((LibreOfficeDeviceScore*)device->score)->fTime *= fInterpretTailFactor;
static_cast<LibreOfficeDeviceScore*>(device->score)->fTime *= fInterpretTailFactor;
}
return DS_SUCCESS;
}
......@@ -403,7 +403,7 @@ ds_status pickBestDevice(ds_profile* profile, int* bestDeviceIdx)
for (unsigned int d = 0; d < profile->numDevices; d++)
{
ds_device device = profile->devices[d];
LibreOfficeDeviceScore *pScore = (LibreOfficeDeviceScore*)device.score;
LibreOfficeDeviceScore *pScore = static_cast<LibreOfficeDeviceScore*>(device.score);
// Check blacklist and whitelist for actual devices
if (device.type == DS_DEVICE_OPENCL_DEVICE)
......
......@@ -830,7 +830,7 @@ bool switchOpenCLDevice(const OUString* pDevice, bool bAutoSelect, bool bForceEv
// initialisation below.) Because otherwise the code crashes in
// initOpenCLRunEnv(). Confused? You should be.
gpuEnv.mpArryDevsID = (cl_device_id*) malloc( sizeof(cl_device_id) );
gpuEnv.mpArryDevsID = static_cast<cl_device_id*>(malloc( sizeof(cl_device_id) ));
gpuEnv.mpArryDevsID[0] = pDeviceId;
return !initOpenCLRunEnv(0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment