Fix various clang compilation errors

Also fixed a writable strings warning/error.
warning: ISO C++11 does not allow conversion from
      string literal to 'char *' [-Wwritable-strings]

Several were of this form and fixed as the compiler suggested:
openclwrapper.cpp:2411:33: error: non-constant-expression cannot be narrowed
      from type 'int' to 'size_t' (aka 'unsigned long') in initializer list
      [-Wc++11-narrowing]
    size_t local_work_size[] = {block_size};
                                ^~~~~~~~~~
openclwrapper.cpp:2411:33: note: insert an explicit cast to silence this issue
    size_t local_work_size[] = {block_size};
                                ^~~~~~~~~~
                                static_cast<size_t>( )

Should have low impact on other platforms/compilers. The change makes
the code more correct.
This commit is contained in:
James R. Barlow 2015-08-26 01:00:05 -07:00 committed by Zdenko Podobný
parent 8f6ebc95c0
commit 8d5abff34a

View File

@ -60,7 +60,7 @@ KernelEnv rEnv;
// substitute invalid characters in device name with _
void legalizeFileName( char *fileName) {
//printf("fileName: %s\n", fileName);
char *invalidChars = "/\?:*\"><| "; // space is valid but can cause headaches
const char* invalidChars = "/\?:*\"><| "; // space is valid but can cause headaches
// for each invalid char
for (int i = 0; i < strlen(invalidChars); i++) {
char invalidStr[4];
@ -2408,9 +2408,9 @@ PERF_COUNT_START("HistogramRectOCL")
int requestedOccupancy = 10;
int numWorkGroups = numCUs * requestedOccupancy;
int numThreads = block_size*numWorkGroups;
size_t local_work_size[] = {block_size};
size_t global_work_size[] = {numThreads};
size_t red_global_work_size[] = {block_size*kHistogramSize*bytes_per_pixel};
size_t local_work_size[] = {static_cast<size_t>(block_size)};
size_t global_work_size[] = {static_cast<size_t>(numThreads)};
size_t red_global_work_size[] = {static_cast<size_t>(block_size*kHistogramSize*bytes_per_pixel)};
/* map histogramAllChannels as write only */
int numBins = kHistogramSize*bytes_per_pixel*numWorkGroups;
@ -3398,8 +3398,8 @@ PERF_COUNT_SUB("pix setup")
int block_size = 256;
int numWorkGroups = ((h*w+block_size-1) / block_size );
int numThreads = block_size*numWorkGroups;
size_t local_work_size[] = {block_size};
size_t global_work_size[] = {numThreads};
size_t local_work_size[] = {static_cast<size_t>(block_size)};
size_t global_work_size[] = {static_cast<size_t>(numThreads)};
//printf("Enqueueing %i threads for %i output pixels\n", numThreads, w*h);
/* compile kernel */