mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
relationals: fix -Wformat warnings (#2218)
Avoid a ``` ‘%zu’ directive writing between 1 and 20 bytes into a region of size 16 ``` warning by using `std::string` for `generate_shuffle_mask`. As this fixes the last remaining Wformat warning in the relationals suite, drop the local `-Wno-format` compiler option. Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
This commit is contained in:
committed by
GitHub
parent
bc5b0215ee
commit
a2d6cadec1
@@ -7,7 +7,5 @@ set(${MODULE_NAME}_SOURCES
|
|||||||
test_shuffles.cpp
|
test_shuffles.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set_gnulike_module_compile_flags("-Wno-format")
|
|
||||||
|
|
||||||
include(../CMakeCommon.txt)
|
include(../CMakeCommon.txt)
|
||||||
|
|
||||||
|
|||||||
@@ -307,27 +307,24 @@ void print_hex_mem_dump(const unsigned char *inDataPtr,
|
|||||||
log_info("%s\n", error.str().c_str());
|
log_info("%s\n", error.str().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void generate_shuffle_mask( char *outMaskString, size_t maskSize, const ShuffleOrder *order )
|
std::string generate_shuffle_mask(size_t maskSize, const ShuffleOrder *order)
|
||||||
{
|
{
|
||||||
outMaskString[ 0 ] = 0;
|
std::ostringstream outMaskString;
|
||||||
if( order != NULL )
|
if( order != NULL )
|
||||||
{
|
{
|
||||||
for( size_t jj = 0; jj < maskSize; jj++ )
|
for( size_t jj = 0; jj < maskSize; jj++ )
|
||||||
{
|
{
|
||||||
char thisMask[ 16 ];
|
outMaskString << (jj == 0 ? "" : ", ") << +((*order)[jj]);
|
||||||
sprintf( thisMask, "%s%d", ( jj == 0 ) ? "" : ", ", (*order)[ jj ] );
|
|
||||||
strcat( outMaskString, thisMask );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for( size_t jj = 0; jj < maskSize; jj++ )
|
for( size_t jj = 0; jj < maskSize; jj++ )
|
||||||
{
|
{
|
||||||
char thisMask[ 16 ];
|
outMaskString << (jj == 0 ? "" : ", ") << jj;
|
||||||
sprintf(thisMask, "%s%zu", (jj == 0) ? "" : ", ", jj);
|
|
||||||
strcat( outMaskString, thisMask );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return outMaskString.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
static int create_shuffle_kernel( cl_context context, cl_program *outProgram, cl_kernel *outKernel,
|
static int create_shuffle_kernel( cl_context context, cl_program *outProgram, cl_kernel *outKernel,
|
||||||
@@ -520,9 +517,9 @@ static int create_shuffle_kernel( cl_context context, cl_program *outProgram, cl
|
|||||||
maskType = kULong;
|
maskType = kULong;
|
||||||
}
|
}
|
||||||
|
|
||||||
char maskString[ 1024 ] = "";
|
|
||||||
size_t maskSize = outVecSize;// ( shuffleMode == kBuiltInDualInputFnMode ) ? ( outVecSize << 1 ) : outVecSize;
|
size_t maskSize = outVecSize;// ( shuffleMode == kBuiltInDualInputFnMode ) ? ( outVecSize << 1 ) : outVecSize;
|
||||||
generate_shuffle_mask( maskString, maskSize, ( outOrders != NULL ) ? &outOrders[ i ] : NULL );
|
std::string maskString = generate_shuffle_mask(
|
||||||
|
maskSize, (outOrders != NULL) ? &outOrders[i] : NULL);
|
||||||
|
|
||||||
// Set up a quick prefix, so mask gets unsigned type regardless of the input/output type
|
// Set up a quick prefix, so mask gets unsigned type regardless of the input/output type
|
||||||
char maskPrefix[ 2 ] = "u";
|
char maskPrefix[ 2 ] = "u";
|
||||||
@@ -532,13 +529,21 @@ static int create_shuffle_kernel( cl_context context, cl_program *outProgram, cl
|
|||||||
char progLine2[ 10240 ];
|
char progLine2[ 10240 ];
|
||||||
if( shuffleMode == kBuiltInDualInputFnMode )
|
if( shuffleMode == kBuiltInDualInputFnMode )
|
||||||
{
|
{
|
||||||
sprintf( progLine2, shuffleBuiltInDualPattern, get_explicit_type_name( vecType ), inSizeName,
|
sprintf(
|
||||||
( inVecSize == 3 ) ? "vload3( %ld, (__global %s *)source )" : "source[ %ld ]",
|
progLine2, shuffleBuiltInDualPattern,
|
||||||
get_explicit_type_name( vecType ), inSizeName,
|
get_explicit_type_name(vecType), inSizeName,
|
||||||
( inVecSize == 3 ) ? "vload3( %ld, (__global %s *)secondSource )" : "secondSource[ %ld ]",
|
(inVecSize == 3) ? "vload3( %ld, (__global %s *)source )"
|
||||||
maskPrefix, get_explicit_type_name( maskType ), outSizeName, maskPrefix, get_explicit_type_name( maskType ), outSizeName,
|
: "source[ %ld ]",
|
||||||
maskString,
|
get_explicit_type_name(vecType), inSizeName,
|
||||||
( outVecSize == 3 ) ? "vstore3( tmp, %ld, (__global %s *)dest )" : "dest[ %ld ] = tmp" );
|
(inVecSize == 3)
|
||||||
|
? "vload3( %ld, (__global %s *)secondSource )"
|
||||||
|
: "secondSource[ %ld ]",
|
||||||
|
maskPrefix, get_explicit_type_name(maskType), outSizeName,
|
||||||
|
maskPrefix, get_explicit_type_name(maskType), outSizeName,
|
||||||
|
maskString.c_str(),
|
||||||
|
(outVecSize == 3)
|
||||||
|
? "vstore3( tmp, %ld, (__global %s *)dest )"
|
||||||
|
: "dest[ %ld ] = tmp");
|
||||||
|
|
||||||
if( outVecSize == 3 )
|
if( outVecSize == 3 )
|
||||||
{
|
{
|
||||||
@@ -557,11 +562,17 @@ static int create_shuffle_kernel( cl_context context, cl_program *outProgram, cl
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprintf( progLine2, shuffleBuiltInPattern, get_explicit_type_name( vecType ), inSizeName,
|
sprintf(
|
||||||
( inVecSize == 3 ) ? "vload3( %ld, (__global %s *)source )" : "source[ %ld ]",
|
progLine2, shuffleBuiltInPattern,
|
||||||
maskPrefix, get_explicit_type_name( maskType ), outSizeName, maskPrefix, get_explicit_type_name( maskType ), outSizeName,
|
get_explicit_type_name(vecType), inSizeName,
|
||||||
maskString,
|
(inVecSize == 3) ? "vload3( %ld, (__global %s *)source )"
|
||||||
( outVecSize == 3 ) ? "vstore3( tmp, %ld, (__global %s *)dest )" : "dest[ %ld ] = tmp" );
|
: "source[ %ld ]",
|
||||||
|
maskPrefix, get_explicit_type_name(maskType), outSizeName,
|
||||||
|
maskPrefix, get_explicit_type_name(maskType), outSizeName,
|
||||||
|
maskString.c_str(),
|
||||||
|
(outVecSize == 3)
|
||||||
|
? "vstore3( tmp, %ld, (__global %s *)dest )"
|
||||||
|
: "dest[ %ld ] = tmp");
|
||||||
|
|
||||||
if( outVecSize == 3 )
|
if( outVecSize == 3 )
|
||||||
{
|
{
|
||||||
@@ -705,9 +716,9 @@ int test_shuffle_dual_kernel(cl_context context, cl_command_queue queue,
|
|||||||
if( ( shuffleMode == kBuiltInFnMode ) || ( shuffleMode == kBuiltInDualInputFnMode ) )
|
if( ( shuffleMode == kBuiltInFnMode ) || ( shuffleMode == kBuiltInDualInputFnMode ) )
|
||||||
{
|
{
|
||||||
// Mask would've been different for every shuffle done, so we have to regen it to print it
|
// Mask would've been different for every shuffle done, so we have to regen it to print it
|
||||||
char maskString[ 1024 ];
|
std::string maskString = generate_shuffle_mask(
|
||||||
generate_shuffle_mask( maskString, outVecSize, ( outOrderIdx != NULL ) ? &outOrderIdx[ i ] : NULL );
|
outVecSize, (outOrderIdx != NULL) ? &outOrderIdx[i] : NULL);
|
||||||
log_error( " Mask: %s\n", maskString );
|
log_error(" Mask: %s\n", maskString.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
ret++;
|
ret++;
|
||||||
|
|||||||
Reference in New Issue
Block a user