Fix Build Warnings for AArch64 (#2242)

This commit links to issue (#2234).

When cross-compiling for AArch64, using gcc 13.3, you encounter three
warnings types that turn into errors:

- maybe-uninitialized
- stringop-truncation
- strict-aliasing

This commit fixes all the warnings found, in regards to the first two
rules. To resolve the warnigns due to strict-aliasing, I am editing the
CMake build system.

Signed-off-by: Antonios Christidis <a-christidis@ti.com>
This commit is contained in:
Antonios Christidis
2025-02-05 06:58:17 -06:00
committed by GitHub
parent bcfa1f7c26
commit 2031e21a58
30 changed files with 104 additions and 43 deletions

View File

@@ -107,6 +107,7 @@ if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?Clang"
add_cxx_flag_if_supported(-Wno-error=cpp) # Allow #warning directive add_cxx_flag_if_supported(-Wno-error=cpp) # Allow #warning directive
add_cxx_flag_if_supported(-Wno-unknown-pragmas) # Issue #785 add_cxx_flag_if_supported(-Wno-unknown-pragmas) # Issue #785
add_cxx_flag_if_supported(-Wno-error=asm-operand-widths) # Issue #784 add_cxx_flag_if_supported(-Wno-error=asm-operand-widths) # Issue #784
add_cxx_flag_if_supported(-Wno-strict-aliasing) # Issue 2234
# -msse -mfpmath=sse to force gcc to use sse for float math, # -msse -mfpmath=sse to force gcc to use sse for float math,
# avoiding excess precision problems that cause tests like int2float # avoiding excess precision problems that cause tests like int2float

View File

@@ -2415,6 +2415,12 @@ int debug_find_vector_in_image(void *imagePtr, image_descriptor *imageInfo,
(imageInfo->height >> lod) ? (imageInfo->height >> lod) : 1; (imageInfo->height >> lod) ? (imageInfo->height >> lod) : 1;
depth = (imageInfo->depth >> lod) ? (imageInfo->depth >> lod) : 1; depth = (imageInfo->depth >> lod) ? (imageInfo->depth >> lod) : 1;
break; break;
default:
log_error("ERROR: Invalid imageInfo->type = %d\n", imageInfo->type);
width = 0;
depth = 0;
height = 0;
break;
} }
row_pitch = width * get_pixel_size(imageInfo->format); row_pitch = width * get_pixel_size(imageInfo->format);
@@ -3661,6 +3667,11 @@ void copy_image_data(image_descriptor *srcImageInfo,
? (srcImageInfo->height >> src_lod) ? (srcImageInfo->height >> src_lod)
: 1; : 1;
break; break;
default:
log_error("ERROR: Invalid srcImageInfo->type = %d\n",
srcImageInfo->type);
src_lod = 0;
break;
} }
src_mip_level_offset = compute_mip_level_offset(srcImageInfo, src_lod); src_mip_level_offset = compute_mip_level_offset(srcImageInfo, src_lod);
src_row_pitch_lod = src_row_pitch_lod =
@@ -3707,6 +3718,11 @@ void copy_image_data(image_descriptor *srcImageInfo,
? (dstImageInfo->height >> dst_lod) ? (dstImageInfo->height >> dst_lod)
: 1; : 1;
break; break;
default:
log_error("ERROR: Invalid dstImageInfo->num_mip_levels = %d\n",
dstImageInfo->num_mip_levels);
dst_lod = 0;
break;
} }
dst_mip_level_offset = compute_mip_level_offset(dstImageInfo, dst_lod); dst_mip_level_offset = compute_mip_level_offset(dstImageInfo, dst_lod);
dst_row_pitch_lod = dst_row_pitch_lod =

View File

@@ -348,7 +348,7 @@ cl_int clProtectedImage::Create(cl_context context,
const cl_image_format *fmt, size_t width, const cl_image_format *fmt, size_t width,
size_t height, size_t depth, size_t arraySize) size_t height, size_t depth, size_t arraySize)
{ {
cl_int error; cl_int error = 0;
#if defined(__APPLE__) #if defined(__APPLE__)
int protect_pages = 1; int protect_pages = 1;
cl_device_id devices[16]; cl_device_id devices[16];

View File

@@ -160,8 +160,8 @@ REGISTER_TEST(svm_enqueue_api)
error = clSetUserEventStatus(userEvent, CL_COMPLETE); error = clSetUserEventStatus(userEvent, CL_COMPLETE);
test_error(error, "clSetUserEventStatus failed"); test_error(error, "clSetUserEventStatus failed");
cl_uchar *src_ptr; cl_uchar *src_ptr = nullptr;
cl_uchar *dst_ptr; cl_uchar *dst_ptr = nullptr;
if (test_case.srcAlloc == host) if (test_case.srcAlloc == host)
{ {
src_ptr = srcHostData.data(); src_ptr = srcHostData.data();

View File

@@ -208,7 +208,7 @@ int do_test_work_group_suggested_local_size(
bool (*skip_cond)(size_t), size_t start, size_t end, size_t incr, bool (*skip_cond)(size_t), size_t start, size_t end, size_t incr,
cl_ulong max_local_mem_size, size_t global_work_offset[], num_dims dim) cl_ulong max_local_mem_size, size_t global_work_offset[], num_dims dim)
{ {
int err; int err = 0;
size_t test_values[] = { 1, 1, 1 }; size_t test_values[] = { 1, 1, 1 };
std::string kernel_names[6] = { std::string kernel_names[6] = {
"test_wg_scan_local_work_group_size", "test_wg_scan_local_work_group_size",

View File

@@ -314,6 +314,12 @@ test_imagereadwrite(cl_device_id device, cl_context context, cl_command_queue qu
} }
outp = (void *)rgbafp_outptr; outp = (void *)rgbafp_outptr;
break; break;
default:
log_error("ERROR Invalid j = %d\n", j);
elem_size = 0;
p = nullptr;
outp = nullptr;
break;
} }
const char* update_packed_pitch_name = ""; const char* update_packed_pitch_name = "";

View File

@@ -320,6 +320,12 @@ test_imagereadwrite3d(cl_device_id device, cl_context context, cl_command_queue
} }
outp = (void *)rgbafp_outptr; outp = (void *)rgbafp_outptr;
break; break;
default:
log_error("ERROR Invalid j = %d\n", j);
elem_size = 0;
p = nullptr;
outp = nullptr;
break;
} }
const char* update_packed_pitch_name = ""; const char* update_packed_pitch_name = "";

View File

@@ -852,8 +852,8 @@ int test_buffer_write_struct( cl_device_id deviceID, cl_context context, cl_comm
buffers[0] = buffers[0] =
clCreateBuffer(context, flag_set[src_flag_id], clCreateBuffer(context, flag_set[src_flag_id],
ptrSizes[i] * num_elements, NULL, &err); ptrSizes[i] * num_elements, NULL, &err);
if ( err ){ if (err)
align_free( outptr[i] ); {
print_error(err, " clCreateBuffer failed\n" ); print_error(err, " clCreateBuffer failed\n" );
free_mtdata(d); free_mtdata(d);
return -1; return -1;

View File

@@ -365,16 +365,18 @@ static int ParseArgs( int argc, const char **argv )
int length_of_seed = 0; int length_of_seed = 0;
{ // Extract the app name { // Extract the app name
strncpy( appName, argv[0], MAXPATHLEN ); strncpy(appName, argv[0], MAXPATHLEN - 1);
appName[MAXPATHLEN - 1] = '\0';
#if (defined( __APPLE__ ) || defined(__linux__) || defined(__MINGW32__)) #if (defined( __APPLE__ ) || defined(__linux__) || defined(__MINGW32__))
char baseName[MAXPATHLEN]; char baseName[MAXPATHLEN];
char *base = NULL; char *base = NULL;
strncpy( baseName, argv[0], MAXPATHLEN ); strncpy(baseName, argv[0], MAXPATHLEN - 1);
baseName[MAXPATHLEN - 1] = '\0';
base = basename( baseName ); base = basename( baseName );
if( NULL != base ) if( NULL != base )
{ {
strncpy( appName, base, sizeof( appName ) ); strncpy(appName, base, sizeof(appName) - 1);
appName[ sizeof( appName ) -1 ] = '\0'; appName[ sizeof( appName ) -1 ] = '\0';
} }
#elif defined (_WIN32) #elif defined (_WIN32)
@@ -385,7 +387,7 @@ static int ParseArgs( int argc, const char **argv )
fname, _MAX_FNAME, ext, _MAX_EXT ); fname, _MAX_FNAME, ext, _MAX_EXT );
if (err == 0) { // no error if (err == 0) { // no error
strcat (fname, ext); //just cat them, size of frame can keep both strcat (fname, ext); //just cat them, size of frame can keep both
strncpy (appName, fname, sizeof(appName)); strncpy(appName, fname, sizeof(appName) - 1);
appName[ sizeof( appName ) -1 ] = '\0'; appName[ sizeof( appName ) -1 ] = '\0';
} }
#endif #endif

View File

@@ -1448,7 +1448,9 @@ cl_program MakeProgram(Type outType, Type inType, SaturationMode sat,
char inName[32]; char inName[32];
char outName[32]; char outName[32];
strncpy(inName, gTypeNames[inType], sizeof(inName)); strncpy(inName, gTypeNames[inType], sizeof(inName));
inName[sizeof(inName) - 1] = '\0';
strncpy(outName, gTypeNames[outType], sizeof(outName)); strncpy(outName, gTypeNames[outType], sizeof(outName));
outName[sizeof(outName) - 1] = '\0';
sprintf(testName, "test_implicit_%s_%s", outName, inName); sprintf(testName, "test_implicit_%s_%s", outName, inName);
source << "__kernel void " << testName << "( __global " << inName source << "__kernel void " << testName << "( __global " << inName
@@ -1473,8 +1475,10 @@ cl_program MakeProgram(Type outType, Type inType, SaturationMode sat,
switch (vectorSizetmp) switch (vectorSizetmp)
{ {
case 1: case 1:
strncpy(inName, gTypeNames[inType], sizeof(inName)); strncpy(inName, gTypeNames[inType], sizeof(inName) - 1);
strncpy(outName, gTypeNames[outType], sizeof(outName)); inName[sizeof(inName) - 1] = '\0';
strncpy(outName, gTypeNames[outType], sizeof(outName) - 1);
outName[sizeof(outName) - 1] = '\0';
snprintf(convertString, sizeof(convertString), "convert_%s%s%s", snprintf(convertString, sizeof(convertString), "convert_%s%s%s",
outName, gSaturationNames[sat], outName, gSaturationNames[sat],
gRoundingModeNames[round]); gRoundingModeNames[round]);
@@ -1482,8 +1486,10 @@ cl_program MakeProgram(Type outType, Type inType, SaturationMode sat,
vlog("Building %s( %s ) test\n", convertString, inName); vlog("Building %s( %s ) test\n", convertString, inName);
break; break;
case 3: case 3:
strncpy(inName, gTypeNames[inType], sizeof(inName)); strncpy(inName, gTypeNames[inType], sizeof(inName) - 1);
strncpy(outName, gTypeNames[outType], sizeof(outName)); inName[sizeof(inName) - 1] = '\0';
strncpy(outName, gTypeNames[outType], sizeof(outName) - 1);
outName[sizeof(outName) - 1] = '\0';
snprintf(convertString, sizeof(convertString), snprintf(convertString, sizeof(convertString),
"convert_%s3%s%s", outName, gSaturationNames[sat], "convert_%s3%s%s", outName, gSaturationNames[sat],
gRoundingModeNames[round]); gRoundingModeNames[round]);

View File

@@ -182,11 +182,12 @@ static int ParseArgs(int argc, const char **argv)
#if (defined(__APPLE__) || defined(__linux__) || defined(__MINGW32__)) #if (defined(__APPLE__) || defined(__linux__) || defined(__MINGW32__))
{ // Extract the app name { // Extract the app name
char baseName[MAXPATHLEN]; char baseName[MAXPATHLEN];
strncpy(baseName, argv[0], MAXPATHLEN); strncpy(baseName, argv[0], MAXPATHLEN - 1);
baseName[sizeof(baseName) - 1] = '\0';
char *base = basename(baseName); char *base = basename(baseName);
if (NULL != base) if (NULL != base)
{ {
strncpy(appName, base, sizeof(appName)); strncpy(appName, base, sizeof(appName) - 1);
appName[sizeof(appName) - 1] = '\0'; appName[sizeof(appName) - 1] = '\0';
} }
} }
@@ -200,7 +201,7 @@ static int ParseArgs(int argc, const char **argv)
if (err == 0) if (err == 0)
{ // no error { // no error
strcat(fname, ext); // just cat them, size of frame can keep both strcat(fname, ext); // just cat them, size of frame can keep both
strncpy(appName, fname, sizeof(appName)); strncpy(appName, fname, sizeof(appName) - 1);
appName[sizeof(appName) - 1] = '\0'; appName[sizeof(appName) - 1] = '\0';
} }
} }

View File

@@ -89,7 +89,7 @@ int test_event_enqueue_wait_for_events_run_test(
// If we are to use two devices, then get them and create a context with // If we are to use two devices, then get them and create a context with
// both. // both.
cl_device_id *two_device_ids; cl_device_id *two_device_ids = nullptr;
if (two_devices) if (two_devices)
{ {
two_device_ids = (cl_device_id *)malloc(sizeof(cl_device_id) * 2); two_device_ids = (cl_device_id *)malloc(sizeof(cl_device_id) * 2);

View File

@@ -341,8 +341,8 @@ int Test_vStoreHalf_private(cl_device_id device, f2h referenceFunc,
int vectorSize, error; int vectorSize, error;
cl_program programs[kVectorSizeCount + kStrangeVectorSizeCount][3]; cl_program programs[kVectorSizeCount + kStrangeVectorSizeCount][3];
cl_kernel kernels[kVectorSizeCount + kStrangeVectorSizeCount][3]; cl_kernel kernels[kVectorSizeCount + kStrangeVectorSizeCount][3];
cl_program resetProgram; cl_program resetProgram = nullptr;
cl_kernel resetKernel; cl_kernel resetKernel = nullptr;
uint64_t time[kVectorSizeCount + kStrangeVectorSizeCount] = { 0 }; uint64_t time[kVectorSizeCount + kStrangeVectorSizeCount] = { 0 };
uint64_t min_time[kVectorSizeCount + kStrangeVectorSizeCount] = { 0 }; uint64_t min_time[kVectorSizeCount + kStrangeVectorSizeCount] = { 0 };
@@ -1225,8 +1225,8 @@ int Test_vStoreaHalf_private(cl_device_id device, f2h referenceFunc,
int vectorSize, error; int vectorSize, error;
cl_program programs[kVectorSizeCount + kStrangeVectorSizeCount][3]; cl_program programs[kVectorSizeCount + kStrangeVectorSizeCount][3];
cl_kernel kernels[kVectorSizeCount + kStrangeVectorSizeCount][3]; cl_kernel kernels[kVectorSizeCount + kStrangeVectorSizeCount][3];
cl_program resetProgram; cl_program resetProgram = nullptr;
cl_kernel resetKernel; cl_kernel resetKernel = nullptr;
uint64_t time[kVectorSizeCount + kStrangeVectorSizeCount] = { 0 }; uint64_t time[kVectorSizeCount + kStrangeVectorSizeCount] = { 0 };
uint64_t min_time[kVectorSizeCount + kStrangeVectorSizeCount] = { 0 }; uint64_t min_time[kVectorSizeCount + kStrangeVectorSizeCount] = { 0 };

View File

@@ -144,11 +144,12 @@ static int ParseArgs( int argc, const char **argv )
#if (defined( __APPLE__ ) || defined(__linux__) || defined(__MINGW32__)) #if (defined( __APPLE__ ) || defined(__linux__) || defined(__MINGW32__))
{ // Extract the app name { // Extract the app name
char baseName[ MAXPATHLEN ]; char baseName[ MAXPATHLEN ];
strncpy( baseName, argv[0], MAXPATHLEN ); strncpy(baseName, argv[0], MAXPATHLEN - 1);
baseName[MAXPATHLEN - 1] = '\0';
char *base = basename( baseName ); char *base = basename( baseName );
if( NULL != base ) if( NULL != base )
{ {
strncpy( appName, base, sizeof( appName ) ); strncpy(appName, base, sizeof(appName) - 1);
appName[ sizeof( appName ) -1 ] = '\0'; appName[ sizeof( appName ) -1 ] = '\0';
} }
} }

View File

@@ -25,7 +25,7 @@ int test_copy_image_size_1D( cl_context context, cl_command_queue queue, image_d
size_t src_lod = 0, src_width_lod = imageInfo->width, src_row_pitch_lod; size_t src_lod = 0, src_width_lod = imageInfo->width, src_row_pitch_lod;
size_t dst_lod = 0, dst_width_lod = imageInfo->width, dst_row_pitch_lod; size_t dst_lod = 0, dst_width_lod = imageInfo->width, dst_row_pitch_lod;
size_t width_lod = imageInfo->width; size_t width_lod = imageInfo->width;
size_t max_mip_level; size_t max_mip_level = 0;
if( gTestMipmaps ) if( gTestMipmaps )
{ {

View File

@@ -25,7 +25,7 @@ int test_copy_image_size_1D_array( cl_context context, cl_command_queue queue, i
size_t src_lod = 0, src_width_lod = imageInfo->width, src_row_pitch_lod; size_t src_lod = 0, src_width_lod = imageInfo->width, src_row_pitch_lod;
size_t dst_lod = 0, dst_width_lod = imageInfo->width, dst_row_pitch_lod; size_t dst_lod = 0, dst_width_lod = imageInfo->width, dst_row_pitch_lod;
size_t width_lod = imageInfo->width; size_t width_lod = imageInfo->width;
size_t max_mip_level; size_t max_mip_level = 0;
if( gTestMipmaps ) if( gTestMipmaps )
{ {

View File

@@ -27,7 +27,7 @@ int test_copy_image_size_2D( cl_context context, cl_command_queue queue, image_d
size_t dst_lod = 0, dst_width_lod = imageInfo->width, dst_row_pitch_lod; size_t dst_lod = 0, dst_width_lod = imageInfo->width, dst_row_pitch_lod;
size_t dst_height_lod = imageInfo->height; size_t dst_height_lod = imageInfo->height;
size_t width_lod = imageInfo->width, height_lod = imageInfo->height; size_t width_lod = imageInfo->width, height_lod = imageInfo->height;
size_t max_mip_level; size_t max_mip_level = 0;
if( gTestMipmaps ) if( gTestMipmaps )
{ {

View File

@@ -72,7 +72,7 @@ int test_copy_image_size_2D_2D_array( cl_context context, cl_command_queue queue
size_t threeImage_lod = 0, threeImage_width_lod = threeImage->width, threeImage_row_pitch_lod, threeImage_slice_pitch_lod; size_t threeImage_lod = 0, threeImage_width_lod = threeImage->width, threeImage_row_pitch_lod, threeImage_slice_pitch_lod;
size_t threeImage_height_lod = threeImage->height; size_t threeImage_height_lod = threeImage->height;
size_t width_lod, height_lod; size_t width_lod, height_lod;
size_t twoImage_max_mip_level,threeImage_max_mip_level; size_t twoImage_max_mip_level = 0, threeImage_max_mip_level = 0;
if( gTestMipmaps ) if( gTestMipmaps )
{ {

View File

@@ -68,7 +68,7 @@ int test_copy_image_size_2D_3D( cl_context context, cl_command_queue queue, imag
size_t threeImage_lod = 0, threeImage_width_lod = threeImage->width, threeImage_row_pitch_lod, threeImage_slice_pitch_lod; size_t threeImage_lod = 0, threeImage_width_lod = threeImage->width, threeImage_row_pitch_lod, threeImage_slice_pitch_lod;
size_t threeImage_height_lod = threeImage->height, depth_lod = threeImage->depth; size_t threeImage_height_lod = threeImage->height, depth_lod = threeImage->depth;
size_t width_lod, height_lod; size_t width_lod, height_lod;
size_t twoImage_max_mip_level,threeImage_max_mip_level; size_t twoImage_max_mip_level = 0, threeImage_max_mip_level = 0;
if( gTestMipmaps ) if( gTestMipmaps )
{ {

View File

@@ -39,8 +39,8 @@ extern int test_copy_image_set_1D_buffer_1D(cl_device_id device,
int test_image_type( cl_device_id device, cl_context context, cl_command_queue queue, MethodsToTest testMethod, cl_mem_flags flags ) int test_image_type( cl_device_id device, cl_context context, cl_command_queue queue, MethodsToTest testMethod, cl_mem_flags flags )
{ {
const char *name; const char *name = nullptr;
cl_mem_object_type imageType; cl_mem_object_type imageType = 0;
if ( gTestMipmaps ) if ( gTestMipmaps )
{ {

View File

@@ -277,6 +277,11 @@ cl_mem create_image( cl_context context, cl_command_queue queue, BufferOwningPtr
depth = imageInfo->depth; depth = imageInfo->depth;
imageSize = imageInfo->slicePitch * imageInfo->depth; imageSize = imageInfo->slicePitch * imageInfo->depth;
break; break;
default:
log_error("ERROR Invalid imageInfo->type = %d\n", imageInfo->type);
height = 0;
depth = 0;
break;
} }
size_t origin[ 3 ] = { 0, 0, 0 }; size_t origin[ 3 ] = { 0, 0, 0 };

View File

@@ -181,6 +181,10 @@ int test_get_image_info_single( cl_context context, image_descriptor *imageInfo,
case CL_MEM_OBJECT_IMAGE3D: case CL_MEM_OBJECT_IMAGE3D:
required_height = imageInfo->height; required_height = imageInfo->height;
break; break;
default:
log_error("ERROR: Invalid imageInfo->type = %d\n", imageInfo->type);
required_height = 0;
break;
} }
size_t outHeight; size_t outHeight;
@@ -204,6 +208,10 @@ int test_get_image_info_single( cl_context context, image_descriptor *imageInfo,
case CL_MEM_OBJECT_IMAGE3D: case CL_MEM_OBJECT_IMAGE3D:
required_depth = imageInfo->depth; required_depth = imageInfo->depth;
break; break;
default:
log_error("ERROR: Invalid imageInfo->type = %d\n", imageInfo->type);
required_depth = 0;
break;
} }
size_t outDepth; size_t outDepth;
@@ -227,6 +235,10 @@ int test_get_image_info_single( cl_context context, image_descriptor *imageInfo,
case CL_MEM_OBJECT_IMAGE2D_ARRAY: case CL_MEM_OBJECT_IMAGE2D_ARRAY:
required_array_size = imageInfo->arraySize; required_array_size = imageInfo->arraySize;
break; break;
default:
log_error("ERROR: Invalid imageInfo->type = %d\n", imageInfo->type);
required_array_size = 0;
break;
} }
size_t outArraySize; size_t outArraySize;

View File

@@ -69,7 +69,7 @@ static inline size_t get_format_size(cl_context context,
} }
cl_int error = 0; cl_int error = 0;
cl_mem buffer; cl_mem buffer = nullptr;
if (imageType == CL_MEM_OBJECT_IMAGE1D_BUFFER) if (imageType == CL_MEM_OBJECT_IMAGE1D_BUFFER)
{ {
buffer = clCreateBuffer(context, flags, buffer = clCreateBuffer(context, flags,

View File

@@ -769,7 +769,7 @@ int image_from_buffer_fill_positive(cl_device_id device, cl_context context,
err = clFinish(queue); err = clFinish(queue);
test_error(err, "Error clFinish"); test_error(err, "Error clFinish");
cl_mem image1d_buffer; cl_mem image1d_buffer = nullptr;
if (imageType == CL_MEM_OBJECT_IMAGE1D_BUFFER) if (imageType == CL_MEM_OBJECT_IMAGE1D_BUFFER)
{ {
image1d_buffer = clCreateBuffer(context, flag, buffer_size, image1d_buffer = clCreateBuffer(context, flag, buffer_size,

View File

@@ -1191,7 +1191,7 @@ int test_read_image_2D( cl_context context, cl_command_queue queue, cl_kernel ke
{ {
int error; int error;
static int initHalf = 0; static int initHalf = 0;
cl_mem imageBuffer; cl_mem imageBuffer = nullptr;
cl_mem_flags image_read_write_flags = CL_MEM_READ_ONLY; cl_mem_flags image_read_write_flags = CL_MEM_READ_ONLY;
size_t threads[2]; size_t threads[2];

View File

@@ -223,7 +223,7 @@ int test_write_image( cl_device_id device, cl_context context, cl_command_queue
clProtectedImage protImage; clProtectedImage protImage;
clMemWrapper unprotImage; clMemWrapper unprotImage;
cl_mem image; cl_mem image;
cl_mem imageBuffer; cl_mem imageBuffer = nullptr;
if( gMemFlagsToUse == CL_MEM_USE_HOST_PTR ) if( gMemFlagsToUse == CL_MEM_USE_HOST_PTR )
{ {
@@ -910,7 +910,7 @@ int test_write_image_formats(cl_device_id device, cl_context context,
gTestCount++; gTestCount++;
print_write_header( &imageFormat, false ); print_write_header( &imageFormat, false );
int retCode; int retCode = 0;
switch (imageType) switch (imageType)
{ {
case CL_MEM_OBJECT_IMAGE1D: case CL_MEM_OBJECT_IMAGE1D:

View File

@@ -97,7 +97,7 @@ int test_unary_op( cl_command_queue queue, cl_context context, OpKonstants which
get_explicit_type_size(vecType) * vecSize * TEST_SIZE, inData, &error); get_explicit_type_size(vecType) * vecSize * TEST_SIZE, inData, &error);
test_error( error, "Creating input data array failed" ); test_error( error, "Creating input data array failed" );
cl_uint bits; cl_uint bits = 0;
for( i = 0; i < TEST_SIZE; i++ ) for( i = 0; i < TEST_SIZE; i++ )
{ {
size_t which = i & 7; size_t which = i & 7;

View File

@@ -1151,7 +1151,8 @@ int main(int argc, const char* argv[])
char* pcTempFname = get_temp_filename(); char* pcTempFname = get_temp_filename();
if (pcTempFname != nullptr) if (pcTempFname != nullptr)
{ {
strncpy(gFileName, pcTempFname, sizeof(gFileName)); strncpy(gFileName, pcTempFname, sizeof(gFileName) - 1);
gFileName[sizeof(gFileName) - 1] = '\0';
} }
free(pcTempFname); free(pcTempFname);

View File

@@ -261,14 +261,18 @@ static cl_program makeSelectProgram(cl_kernel *kernel_ptr,
switch( vec_len ) switch( vec_len )
{ {
case 1: case 1:
strncpy(stypename, type_name[srctype], sizeof(stypename)); strncpy(stypename, type_name[srctype], sizeof(stypename) - 1);
strncpy(ctypename, type_name[cmptype], sizeof(ctypename)); stypename[sizeof(stypename) - 1] = '\0';
strncpy(ctypename, type_name[cmptype], sizeof(ctypename) - 1);
ctypename[sizeof(ctypename) - 1] = '\0';
snprintf(testname, sizeof(testname), "select_%s_%s", stypename, ctypename ); snprintf(testname, sizeof(testname), "select_%s_%s", stypename, ctypename );
log_info("Building %s(%s, %s, %s)\n", testname, stypename, stypename, ctypename); log_info("Building %s(%s, %s, %s)\n", testname, stypename, stypename, ctypename);
break; break;
case 3: case 3:
strncpy(stypename, type_name[srctype], sizeof(stypename)); strncpy(stypename, type_name[srctype], sizeof(stypename) - 1);
strncpy(ctypename, type_name[cmptype], sizeof(ctypename)); stypename[sizeof(stypename) - 1] = '\0';
strncpy(ctypename, type_name[cmptype], sizeof(ctypename) - 1);
ctypename[sizeof(ctypename) - 1] = '\0';
snprintf(testname, sizeof(testname), "select_%s3_%s3", stypename, ctypename ); snprintf(testname, sizeof(testname), "select_%s3_%s3", stypename, ctypename );
log_info("Building %s(%s3, %s3, %s3)\n", testname, stypename, stypename, ctypename); log_info("Building %s(%s3, %s3, %s3)\n", testname, stypename, stypename, ctypename);
break; break;

View File

@@ -1611,7 +1611,7 @@ template <typename Ty, typename Fns, size_t TSIZE = 0> struct subgroup_test
test_params.subgroup_size = subgroup_size; test_params.subgroup_size = subgroup_size;
Fns::gen(idata.data(), mapin.data(), sgmap.data(), test_params); Fns::gen(idata.data(), mapin.data(), sgmap.data(), test_params);
test_status status; test_status status = TEST_FAIL;
if (test_params.divergence_mask_arg != -1) if (test_params.divergence_mask_arg != -1)
{ {