basic: fix Wformat warnings (#2343)

Fix all `-Wformat` warnings in the basic test suite, and re-enable the
warning.

---------

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
This commit is contained in:
Sven van Haastregt
2025-03-25 17:45:18 +01:00
committed by GitHub
parent 1cbb548e27
commit b6924adfb2
8 changed files with 112 additions and 43 deletions

View File

@@ -21,6 +21,8 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <cinttypes>
#include "testBase.h"
cl_int get_type_size( cl_context context, cl_command_queue queue, const char *type, cl_ulong *size, cl_device_id device )
@@ -161,12 +163,16 @@ REGISTER_TEST(sizeof)
return err;
if( test != scalar_table[i].size )
{
log_error( "\nFAILED: Type %s has size %lld, but expected size %lld!\n", scalar_table[i].name, test, scalar_table[i].size );
log_error("\nFAILED: Type %s has size %" PRId64
", but expected size %" PRId64 "!\n",
scalar_table[i].name, test, scalar_table[i].size);
return -1;
}
if( test != scalar_table[i].cl_size )
{
log_error( "\nFAILED: Type %s has size %lld, but cl_ size is %lld!\n", scalar_table[i].name, test, scalar_table[i].cl_size );
log_error("\nFAILED: Type %s has size %" PRId64
", but cl_ size is %" PRId64 "!\n",
scalar_table[i].name, test, scalar_table[i].cl_size);
return -2;
}
log_info( "%16s", scalar_table[i].name );
@@ -196,16 +202,16 @@ REGISTER_TEST(sizeof)
return err;
if( test != j * vector_table[i].size )
{
log_error(
"\nFAILED: Type %s has size %lld, but expected size %zu!\n",
name, test, j * vector_table[i].size);
log_error("\nFAILED: Type %s has size %" PRId64
", but expected size %" PRIu64 "!\n",
name, test, j * vector_table[i].size);
return -1;
}
if( test != j * vector_table[i].cl_size )
{
log_error(
"\nFAILED: Type %s has size %lld, but cl_ size is %zu!\n",
name, test, j * vector_table[i].cl_size);
log_error("\nFAILED: Type %s has size %" PRId64
", but cl_ size is %" PRIu64 "!\n",
name, test, j * vector_table[i].cl_size);
return -2;
}
log_info( "%16s", name );
@@ -222,7 +228,9 @@ REGISTER_TEST(sizeof)
return err;
if( test != ptr_size )
{
log_error( "\nFAILED: Type %s has size %lld, but expected size %u!\n", ptr_table[i], test, ptr_size );
log_error("\nFAILED: Type %s has size %" PRId64
", but expected size %u!\n",
ptr_table[i], test, ptr_size);
return -1;
}
log_info( "%16s", ptr_table[i] );
@@ -235,12 +243,16 @@ REGISTER_TEST(sizeof)
return err;
if( test < ptr_size )
{
log_error( "\nFAILED: intptr_t has size %lld, but must be at least %u!\n", test, ptr_size );
log_error("\nFAILED: intptr_t has size %" PRId64
", but must be at least %u!\n",
test, ptr_size);
return -1;
}
if( ! IsPowerOfTwo( test ) )
{
log_error( "\nFAILED: sizeof(intptr_t) is %lld, but must be a power of two!\n", test );
log_error("\nFAILED: sizeof(intptr_t) is %" PRId64
", but must be a power of two!\n",
test);
return -2;
}
log_info( "%16s", "intptr_t" );
@@ -252,12 +264,16 @@ REGISTER_TEST(sizeof)
return err;
if( test < ptr_size )
{
log_error( "\nFAILED: uintptr_t has size %lld, but must be at least %u!\n", test, ptr_size );
log_error("\nFAILED: uintptr_t has size %" PRId64
", but must be at least %u!\n",
test, ptr_size);
return -1;
}
if( ! IsPowerOfTwo( test ) )
{
log_error( "\nFAILED: sizeof(uintptr_t) is %lld, but must be a power of two!\n", test );
log_error("\nFAILED: sizeof(uintptr_t) is %" PRId64
", but must be a power of two!\n",
test);
return -2;
}
log_info( "%16s\n", "uintptr_t" );
@@ -293,7 +309,9 @@ REGISTER_TEST(sizeof)
return err;
if( ! IsPowerOfTwo( test ) )
{
log_error( "\nFAILED: Type %s has size %lld, which is not a power of two (section 6.1.5)!\n", other_types[i], test );
log_error("\nFAILED: Type %s has size %" PRId64
", which is not a power of two (section 6.1.5)!\n",
other_types[i], test);
return -1;
}
log_info( "%16s", other_types[i] );
@@ -311,7 +329,8 @@ REGISTER_TEST(sizeof)
return err;
if( test != 8 )
{
log_error( "\nFAILED: double has size %lld, but must be 8!\n", test );
log_error("\nFAILED: double has size %" PRId64 ", but must be 8!\n",
test);
return -1;
}
log_info( "%16s", "double" );
@@ -328,7 +347,8 @@ REGISTER_TEST(sizeof)
return err;
if( test != 8*j )
{
log_error("\nFAILED: %s has size %lld, but must be %zu!\n",
log_error("\nFAILED: %s has size %" PRId64
", but must be %zu!\n",
name, test, 8 * j);
return -1;
}
@@ -347,7 +367,8 @@ REGISTER_TEST(sizeof)
return err;
if( test != 2 )
{
log_error( "\nFAILED: half has size %lld, but must be 2!\n", test );
log_error("\nFAILED: half has size %" PRId64 ", but must be 2!\n",
test);
return -1;
}
log_info( "%16s", "half" );
@@ -364,7 +385,8 @@ REGISTER_TEST(sizeof)
return err;
if( test != 2*j )
{
log_error("\nFAILED: %s has size %lld, but must be %zu!\n",
log_error("\nFAILED: %s has size %" PRId64
", but must be %zu!\n",
name, test, 2 * j);
return -1;
}