mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
api: fix -Wformat warnings (#2025)
The main sources of warnings were: * Printing of a `size_t` which requires the `%zu` specifier. * Printing of `cl_long`/`cl_ulong` which is now done using the `PRI*64` macros to ensure portability across 32 and 64-bit builds. Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
This commit is contained in:
committed by
GitHub
parent
a7162188d6
commit
90f523ea57
@@ -18,21 +18,24 @@
|
||||
#include "harness/testHarness.h"
|
||||
|
||||
|
||||
#define TEST_MEM_OBJECT_PARAM( mem, paramName, val, expected, name, type, cast ) \
|
||||
error = clGetMemObjectInfo( mem, paramName, sizeof( val ), &val, &size ); \
|
||||
test_error( error, "Unable to get mem object " name ); \
|
||||
if( val != expected ) \
|
||||
{ \
|
||||
log_error( "ERROR: Mem object " name " did not validate! (expected " type ", got " type " from %s:%d)\n", \
|
||||
expected, (cast)val, __FILE__, __LINE__ ); \
|
||||
return -1; \
|
||||
} \
|
||||
if( size != sizeof( val ) ) \
|
||||
{ \
|
||||
log_error( "ERROR: Returned size of mem object " name " does not validate! (expected %d, got %d from %s:%d)\n", \
|
||||
(int)sizeof( val ), (int)size , __FILE__, __LINE__ ); \
|
||||
return -1; \
|
||||
}
|
||||
#define TEST_MEM_OBJECT_PARAM(mem, paramName, val, expected, name, type, cast) \
|
||||
error = clGetMemObjectInfo(mem, paramName, sizeof(val), &val, &size); \
|
||||
test_error(error, "Unable to get mem object " name); \
|
||||
if (val != expected) \
|
||||
{ \
|
||||
log_error("ERROR: Mem object " name \
|
||||
" did not validate! (expected " type ", got " type \
|
||||
" from %s:%d)\n", \
|
||||
(cast)expected, (cast)val, __FILE__, __LINE__); \
|
||||
return -1; \
|
||||
} \
|
||||
if (size != sizeof(val)) \
|
||||
{ \
|
||||
log_error("ERROR: Returned size of mem object " name \
|
||||
" does not validate! (expected %d, got %d from %s:%d)\n", \
|
||||
(int)sizeof(val), (int)size, __FILE__, __LINE__); \
|
||||
return -1; \
|
||||
}
|
||||
|
||||
static void CL_CALLBACK mem_obj_destructor_callback( cl_mem, void * data )
|
||||
{
|
||||
@@ -236,7 +239,8 @@ int test_get_buffer_info( cl_device_id deviceID, cl_context context, cl_command_
|
||||
TEST_MEM_OBJECT_PARAM( bufferObject, CL_MEM_FLAGS, flags, (unsigned int)bufferFlags[ i ], "flags", "%d", unsigned int )
|
||||
|
||||
size_t sz;
|
||||
TEST_MEM_OBJECT_PARAM( bufferObject, CL_MEM_SIZE, sz, (size_t)( addressAlign * 4 ), "size", "%ld", size_t )
|
||||
TEST_MEM_OBJECT_PARAM(bufferObject, CL_MEM_SIZE, sz,
|
||||
(size_t)(addressAlign * 4), "size", "%zu", size_t)
|
||||
|
||||
cl_uint mapCount;
|
||||
error = clGetMemObjectInfo( bufferObject, CL_MEM_MAP_COUNT, sizeof( mapCount ), &mapCount, &size );
|
||||
@@ -265,7 +269,8 @@ int test_get_buffer_info( cl_device_id deviceID, cl_context context, cl_command_
|
||||
TEST_MEM_OBJECT_PARAM( bufferObject, CL_MEM_ASSOCIATED_MEMOBJECT, origObj, (void *)NULL, "associated mem object", "%p", void * )
|
||||
|
||||
size_t offset;
|
||||
TEST_MEM_OBJECT_PARAM( bufferObject, CL_MEM_OFFSET, offset, 0L, "offset", "%ld", size_t )
|
||||
TEST_MEM_OBJECT_PARAM(bufferObject, CL_MEM_OFFSET, offset, size_t(0),
|
||||
"offset", "%zu", size_t)
|
||||
|
||||
cl_buffer_region region;
|
||||
region.origin = addressAlign;
|
||||
@@ -321,7 +326,8 @@ int test_get_buffer_info( cl_device_id deviceID, cl_context context, cl_command_
|
||||
}
|
||||
TEST_MEM_OBJECT_PARAM( subBufferObject, CL_MEM_FLAGS, flags, (unsigned int)inheritedFlags, "flags", "%d", unsigned int )
|
||||
|
||||
TEST_MEM_OBJECT_PARAM( subBufferObject, CL_MEM_SIZE, sz, (size_t)( addressAlign ), "size", "%ld", size_t )
|
||||
TEST_MEM_OBJECT_PARAM(subBufferObject, CL_MEM_SIZE, sz,
|
||||
(size_t)(addressAlign), "size", "%zu", size_t)
|
||||
|
||||
if ( bufferFlags[ i ] & CL_MEM_USE_HOST_PTR )
|
||||
{
|
||||
@@ -356,7 +362,9 @@ int test_get_buffer_info( cl_device_id deviceID, cl_context context, cl_command_
|
||||
|
||||
TEST_MEM_OBJECT_PARAM( subBufferObject, CL_MEM_ASSOCIATED_MEMOBJECT, origObj, (cl_mem)bufferObject, "associated mem object", "%p", void * )
|
||||
|
||||
TEST_MEM_OBJECT_PARAM( subBufferObject, CL_MEM_OFFSET, offset, (size_t)( addressAlign ), "offset", "%ld", size_t )
|
||||
TEST_MEM_OBJECT_PARAM(subBufferObject, CL_MEM_OFFSET, offset,
|
||||
(size_t)(addressAlign), "offset", "%zu",
|
||||
size_t)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -405,7 +413,8 @@ int test_get_imageObject_info( cl_mem * image, cl_mem_flags objectFlags, cl_imag
|
||||
|
||||
TEST_MEM_OBJECT_PARAM( *image, CL_MEM_CONTEXT, otherCtx, context, "context", "%p", cl_context )
|
||||
|
||||
TEST_MEM_OBJECT_PARAM( *image, CL_MEM_OFFSET, offset, 0L, "offset", "%ld", size_t )
|
||||
TEST_MEM_OBJECT_PARAM(*image, CL_MEM_OFFSET, offset, size_t(0), "offset",
|
||||
"%zu", size_t)
|
||||
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user