Skip to content

Commit 1bbcbd8

Browse files
committed
opencl: Fix some compiler warnings
Remove several unused variables and fix some signed / unsigned mismatches. Signed-off-by: Stefan Weil <[email protected]>
1 parent 1cf098d commit 1bbcbd8

File tree

1 file changed

+9
-22
lines changed

1 file changed

+9
-22
lines changed

opencl/openclwrapper.cpp

+9-22
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,6 @@ static ds_status readProfileFromFile(ds_profile *profile,
330330
const char *currentPosition;
331331
const char *dataStart;
332332
const char *dataEnd;
333-
size_t versionStringLength;
334333

335334
contentEnd = contentStart + contentSize;
336335
currentPosition = contentStart;
@@ -349,8 +348,8 @@ static ds_status readProfileFromFile(ds_profile *profile,
349348
goto cleanup;
350349
}
351350

352-
versionStringLength = strlen(profile->version);
353-
if (versionStringLength != (dataEnd - dataStart) ||
351+
size_t versionStringLength = strlen(profile->version);
352+
if (versionStringLength + dataStart != dataEnd ||
354353
strncmp(profile->version, dataStart, versionStringLength) != 0) {
355354
// version mismatch
356355
status = DS_PROFILE_FILE_ERROR;
@@ -439,8 +438,8 @@ static ds_status readProfileFromFile(ds_profile *profile,
439438

440439
actualDeviceNameLength = strlen(profile->devices[i].oclDeviceName);
441440
driverVersionLength = strlen(profile->devices[i].oclDriverVersion);
442-
if (actualDeviceNameLength == (deviceNameEnd - deviceNameStart) &&
443-
driverVersionLength == (deviceDriverEnd - deviceDriverStart) &&
441+
if (deviceNameStart + actualDeviceNameLength == deviceNameEnd &&
442+
deviceDriverStart + driverVersionLength == deviceDriverEnd &&
444443
strncmp(profile->devices[i].oclDeviceName, deviceNameStart,
445444
actualDeviceNameLength) == 0 &&
446445
strncmp(profile->devices[i].oclDriverVersion, deviceDriverStart,
@@ -586,7 +585,7 @@ static void legalizeFileName( char *fileName) {
586585
const char *invalidChars =
587586
"/\?:*\"><| "; // space is valid but can cause headaches
588587
// for each invalid char
589-
for (int i = 0; i < strlen(invalidChars); i++) {
588+
for (unsigned i = 0; i < strlen(invalidChars); i++) {
590589
char invalidStr[4];
591590
invalidStr[0] = invalidChars[i];
592591
invalidStr[1] = '\0';
@@ -1805,7 +1804,6 @@ int OpenclDevice::HistogramRectOCL(unsigned char *imageData,
18051804
static_cast<size_t>(block_size * kHistogramSize * bytes_per_pixel)};
18061805

18071806
/* map histogramAllChannels as write only */
1808-
int numBins = kHistogramSize * bytes_per_pixel * numWorkGroups;
18091807

18101808
cl_mem histogramBuffer = clCreateBuffer(
18111809
histKern.mpkContext, CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR,
@@ -2000,7 +1998,6 @@ int OpenclDevice::ThresholdRectToPixOCL(unsigned char *imageData,
20001998
/* set kernel arguments */
20011999
clStatus = clSetKernelArg(rEnv.mpkKernel, 0, sizeof(cl_mem), &imageBuffer);
20022000
CHECK_OPENCL(clStatus, "clSetKernelArg imageBuffer");
2003-
cl_uint numPixels = width * height;
20042001
clStatus = clSetKernelArg(rEnv.mpkKernel, 1, sizeof(int), &height);
20052002
CHECK_OPENCL(clStatus, "clSetKernelArg height");
20062003
clStatus = clSetKernelArg(rEnv.mpkKernel, 2, sizeof(int), &width);
@@ -2197,9 +2194,6 @@ static double composeRGBPixelMicroBench(GPUEnv *env, TessScoreEvaluationInputDat
21972194
#endif
21982195
Pix *pix = pixCreate(input.width, input.height, 32);
21992196
l_uint32 *pixData = pixGetData(pix);
2200-
int wpl = pixGetWpl(pix);
2201-
//l_uint32* output_gpu=pixReadFromTiffKernel(tiffdata,w,h,wpl,line);
2202-
//pixSetData(pix, output_gpu);
22032197
int i, j;
22042198
int idx = 0;
22052199
for (i = 0; i < input.height ; i++) {
@@ -2245,14 +2239,11 @@ static double histogramRectMicroBench( GPUEnv *env, TessScoreEvaluationInputData
22452239
timespec time_funct_start, time_funct_end;
22462240
#endif
22472241

2248-
unsigned char pixelHi = (unsigned char)255;
2249-
22502242
int left = 0;
22512243
int top = 0;
22522244
int kHistogramSize = 256;
22532245
int bytes_per_line = input.width*input.numChannels;
22542246
int *histogramAllChannels = new int[kHistogramSize*input.numChannels];
2255-
int retVal = 0;
22562247
// function call
22572248
if (type == DS_DEVICE_OPENCL_DEVICE) {
22582249
#if ON_WINDOWS
@@ -2264,8 +2255,7 @@ static double histogramRectMicroBench( GPUEnv *env, TessScoreEvaluationInputData
22642255
#endif
22652256

22662257
OpenclDevice::gpuEnv = *env;
2267-
int wpl = pixGetWpl(input.pix);
2268-
retVal = OpenclDevice::HistogramRectOCL(
2258+
int retVal = OpenclDevice::HistogramRectOCL(
22692259
input.imageData, input.numChannels, bytes_per_line, top, left,
22702260
input.width, input.height, kHistogramSize, histogramAllChannels);
22712261

@@ -2354,7 +2344,6 @@ static void ThresholdRectToPix_Native(const unsigned char* imagedata,
23542344

23552345
static double thresholdRectToPixMicroBench(GPUEnv *env, TessScoreEvaluationInputData input, ds_device_type type) {
23562346
double time;
2357-
int retVal = 0;
23582347
#if ON_WINDOWS
23592348
LARGE_INTEGER freq, time_funct_start, time_funct_end;
23602349
QueryPerformanceFrequency(&freq);
@@ -2394,8 +2383,7 @@ static double thresholdRectToPixMicroBench(GPUEnv *env, TessScoreEvaluationInput
23942383
#endif
23952384

23962385
OpenclDevice::gpuEnv = *env;
2397-
int wpl = pixGetWpl(input.pix);
2398-
retVal = OpenclDevice::ThresholdRectToPixOCL(
2386+
int retVal = OpenclDevice::ThresholdRectToPixOCL(
23992387
input.imageData, input.numChannels, bytes_per_line, thresholds,
24002388
hi_values, &input.pix, input.height, input.width, top, left);
24012389

@@ -2480,7 +2468,6 @@ static double getLineMasksMorphMicroBench(GPUEnv *env, TessScoreEvaluationInputD
24802468
#else
24812469
clock_gettime( CLOCK_MONOTONIC, &time_funct_start );
24822470
#endif
2483-
Pix *src_pix = input.pix;
24842471
OpenclDevice::gpuEnv = *env;
24852472
OpenclDevice::initMorphCLAllocations(wpl, input.height, input.pix);
24862473
Pix *pix_vline = nullptr, *pix_hline = nullptr, *pix_closed = nullptr;
@@ -2677,12 +2664,12 @@ ds_device OpenclDevice::getDeviceSelection( ) {
26772664
// select fastest using custom Tesseract selection algorithm
26782665
float bestTime = FLT_MAX; // begin search with worst possible time
26792666
int bestDeviceIdx = -1;
2680-
for (int d = 0; d < profile->numDevices; d++) {
2667+
for (unsigned d = 0; d < profile->numDevices; d++) {
26812668
ds_device device = profile->devices[d];
26822669
TessDeviceScore score = *(TessDeviceScore *)device.score;
26832670

26842671
float time = score.time;
2685-
printf("[DS] Device[%i] %i:%s score is %f\n", d + 1, device.type,
2672+
printf("[DS] Device[%u] %i:%s score is %f\n", d + 1, device.type,
26862673
device.oclDeviceName, time);
26872674
if (time < bestTime) {
26882675
bestTime = time;

0 commit comments

Comments
 (0)