Skip to content

Commit

Permalink
select: fix -Wformat warnings (#1817)
Browse files Browse the repository at this point in the history
* Printing of a `size_t` requires the `%z` specifier.

 * Printing of `cl_long`/`cl_ulong` 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>
  • Loading branch information
svenvh authored Sep 22, 2023
1 parent 7759c26 commit b143a99
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 26 deletions.
4 changes: 3 additions & 1 deletion test_conformance/select/test_select.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include <stdio.h>
#include <time.h>
#include <string.h>

#include <cinttypes>
#include <vector>

#if ! defined( _WIN32)
Expand Down Expand Up @@ -441,7 +443,7 @@ static int doTest(cl_command_queue queue, cl_context context, Type stype, Type c
block_elements, element_count[vecsize])
!= 0)
{
log_error("vec_size:%d indx: 0x%16.16llx\n",
log_error("vec_size:%d indx: 0x%16.16" PRIx64 "\n",
(int)element_count[vecsize], i);
return TEST_FAIL;
}
Expand Down
51 changes: 26 additions & 25 deletions test_conformance/select/util_select.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "harness/errorHelpers.h"

#include <stdio.h>
#include <cinttypes>
#include "test_select.h"


Expand Down Expand Up @@ -648,8 +649,8 @@ size_t check_uchar(const void *const test, const void *const correct,
for (i = 0; i < count; i++)
if (t[i] != c[i])
{
log_error("\n(check_uchar) Error for vector size %ld found at "
"0x%8.8lx (of 0x%8.8lx): "
log_error("\n(check_uchar) Error for vector size %zu found at "
"0x%8.8zx (of 0x%8.8zx): "
"*0x%2.2x vs 0x%2.2x\n",
vector_size, i, count, c[i], t[i]);
return i + 1;
Expand All @@ -670,8 +671,8 @@ size_t check_char(const void *const test, const void *const correct,
for (i = 0; i < count; i++)
if (t[i] != c[i])
{
log_error("\n(check_char) Error for vector size %ld found at "
"0x%8.8lx (of 0x%8.8lx): "
log_error("\n(check_char) Error for vector size %zu found at "
"0x%8.8zx (of 0x%8.8zx): "
"*0x%2.2x vs 0x%2.2x\n",
vector_size, i, count, c[i], t[i]);
return i + 1;
Expand All @@ -693,8 +694,8 @@ size_t check_ushort(const void *const test, const void *const correct,
for (i = 0; i < count; i++)
if (t[i] != c[i])
{
log_error("\n(check_ushort) Error for vector size %ld found at "
"0x%8.8lx (of 0x%8.8lx): "
log_error("\n(check_ushort) Error for vector size %zu found at "
"0x%8.8zx (of 0x%8.8zx): "
"*0x%4.4x vs 0x%4.4x\n",
vector_size, i, count, c[i], t[i]);
return i + 1;
Expand All @@ -716,8 +717,8 @@ size_t check_short(const void *const test, const void *const correct,
for (i = 0; i < count; i++)
if (t[i] != c[i])
{
log_error("\n(check_short) Error for vector size %ld found at "
"0x%8.8lx (of 0x%8.8lx): "
log_error("\n(check_short) Error for vector size %zu found at "
"0x%8.8zx (of 0x%8.8zx): "
"*0x%8.8x vs 0x%8.8x\n",
vector_size, i, count, c[i], t[i]);
return i + 1;
Expand All @@ -739,8 +740,8 @@ size_t check_uint(const void *const test, const void *const correct,
for (i = 0; i < count; i++)
if (t[i] != c[i])
{
log_error("\n(check_uint) Error for vector size %ld found at "
"0x%8.8lx (of 0x%8.8lx): "
log_error("\n(check_uint) Error for vector size %zu found at "
"0x%8.8zx (of 0x%8.8zx): "
"*0x%8.8x vs 0x%8.8x\n",
vector_size, i, count, c[i], t[i]);
return i + 1;
Expand All @@ -763,8 +764,8 @@ size_t check_int(const void *const test, const void *const correct,
if (t[i] != c[i])
{

log_error("\n(check_int) Error for vector size %ld found at "
"0x%8.8lx (of 0x%8.8lx): "
log_error("\n(check_int) Error for vector size %zu found at "
"0x%8.8zx (of 0x%8.8zx): "
"*0x%8.8x vs 0x%8.8x\n",
vector_size, i, count, c[i], t[i]);
return i + 1;
Expand All @@ -786,9 +787,9 @@ size_t check_ulong(const void *const test, const void *const correct,
for (i = 0; i < count; i++)
if (t[i] != c[i])
{
log_error("\n(check_ulong) Error for vector size %ld found at "
"0x%8.8lx (of 0x%8.8lx): "
"*0x%16.16llx vs 0x%16.16llx\n",
log_error("\n(check_ulong) Error for vector size %zu found at "
"0x%8.8zx (of 0x%8.8zx): "
"*0x%16.16" PRIx64 " vs 0x%16.16" PRIx64 "\n",
vector_size, i, count, c[i], t[i]);
return i + 1;
}
Expand All @@ -809,9 +810,9 @@ size_t check_long(const void *const test, const void *const correct,
for (i = 0; i < count; i++)
if (t[i] != c[i])
{
log_error("\n(check_long) Error for vector size %ld found at "
"0x%8.8lx (of 0x%8.8lx): "
"*0x%16.16llx vs 0x%16.16llx\n",
log_error("\n(check_long) Error for vector size %zu found at "
"0x%8.8zx (of 0x%8.8zx): "
"*0x%16.16" PRIx64 " vs 0x%16.16" PRIx64 "\n",
vector_size, i, count, c[i], t[i]);
return i + 1;
}
Expand All @@ -834,8 +835,8 @@ size_t check_half(const void *const test, const void *const correct,
&& !(isnan(((cl_half *)correct)[i])
&& isnan(((cl_half *)test)[i])))
{
log_error("\n(check_half) Error for vector size %ld found at "
"0x%8.8lx (of 0x%8.8lx): "
log_error("\n(check_half) Error for vector size %zu found at "
"0x%8.8zx (of 0x%8.8zx): "
"*0x%4.4x vs 0x%4.4x\n",
vector_size, i, count, c[i], t[i]);
return i + 1;
Expand All @@ -858,8 +859,8 @@ size_t check_float(const void *const test, const void *const correct,
if ((t[i] != c[i])
&& !(isnan(((float *)correct)[i]) && isnan(((float *)test)[i])))
{
log_error("\n(check_float) Error for vector size %ld found at "
"0x%8.8lx (of 0x%8.8lx): "
log_error("\n(check_float) Error for vector size %zu found at "
"0x%8.8zx (of 0x%8.8zx): "
"*0x%8.8x vs 0x%8.8x\n",
vector_size, i, count, c[i], t[i]);
return i + 1;
Expand All @@ -883,9 +884,9 @@ size_t check_double(const void *const test, const void *const correct,
&& !(isnan(((double *)correct)[i])
&& isnan(((double *)test)[i])))
{
log_error("\n(check_double) Error for vector size %ld found at "
"0x%8.8lx (of 0x%8.8lx): "
"*0x%16.16llx vs 0x%16.16llx\n",
log_error("\n(check_double) Error for vector size %zu found at "
"0x%8.8zx (of 0x%8.8zx): "
"*0x%16.16" PRIx64 " vs 0x%16.16" PRIx64 "\n",
vector_size, i, count, c[i], t[i]);
return i + 1;
}
Expand Down

0 comments on commit b143a99

Please sign in to comment.