From 5fe1cc01c0f6ce9ae46d4de005f686f4b5769f56 Mon Sep 17 00:00:00 2001 From: Sven van Haastregt Date: Fri, 5 Apr 2024 12:28:20 +0200 Subject: [PATCH] spirv_new: fix -Wformat warnings (#1933) `log_error` was invoked from a template function, but the format specifiers weren't adjusted for the template parameter types. Use a stringstream for printing instead. Signed-off-by: Sven van Haastregt --- test_conformance/spirv_new/test_decorate.cpp | 9 ++++++--- test_conformance/spirv_new/test_op_spec_constant.cpp | 8 ++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/test_conformance/spirv_new/test_decorate.cpp b/test_conformance/spirv_new/test_decorate.cpp index db58e6b77b..4c2f82b540 100644 --- a/test_conformance/spirv_new/test_decorate.cpp +++ b/test_conformance/spirv_new/test_decorate.cpp @@ -439,9 +439,12 @@ int test_fp_rounding(cl_device_id deviceID, { if (h_res[i] != h_out[i]) { - log_error("Values do not match at location %d. Original :%lf, " - "Expected: %ld, Found %ld\n", - i, h_in[i], h_out[i], h_res[i]); + std::stringstream sstr; + sstr << "Values do not match at location " << i << ". " + << "Original: " << h_in[i] << ", " + << "Expected: " << h_out[i] << ", " + << "Found: " << h_res[i]; + log_error("%s\n", sstr.str().c_str()); return -1; } } diff --git a/test_conformance/spirv_new/test_op_spec_constant.cpp b/test_conformance/spirv_new/test_op_spec_constant.cpp index 67ca7b5fea..3b3b4d45db 100644 --- a/test_conformance/spirv_new/test_op_spec_constant.cpp +++ b/test_conformance/spirv_new/test_op_spec_constant.cpp @@ -14,6 +14,8 @@ // limitations under the License. // +#include + #include "testBase.h" #include "types.hpp" @@ -63,8 +65,10 @@ int run_case(cl_device_id deviceID, cl_context context, cl_command_queue queue, use_spec_constant ? reference = final_value : reference = init_buffer; if (device_results != reference) { - log_error("Values do not match. Expected %d obtained %d\n", reference, - device_results); + std::stringstream sstr; + sstr << "Values do not match. Expected " << reference << " obtained " + << device_results; + log_error("%s\n", sstr.str().c_str()); err = -1; } return err;