From 5f6319ad47776d2a515feadbbedc871dc0857946 Mon Sep 17 00:00:00 2001 From: Bogumil Sapinski Date: Thu, 22 Jun 2023 12:45:09 +0200 Subject: [PATCH 1/6] fix unused-parameter warning in samples --- samples/core/enumopencl/main.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/samples/core/enumopencl/main.cpp b/samples/core/enumopencl/main.cpp index ee180538..5d050107 100644 --- a/samples/core/enumopencl/main.cpp +++ b/samples/core/enumopencl/main.cpp @@ -67,6 +67,9 @@ static cl_int PrintDeviceInfoSummary(const std::vector devices) int main(int argc, char** argv) { + (void) argc; + (void**) argv; + std::vector platforms; cl::Platform::get(&platforms); std::cout << "Enumerated " << platforms.size() << " platforms.\n\n"; From 28f1bda2eb1848f53eb0691fb79c30de8f3c45f8 Mon Sep 17 00:00:00 2001 From: Bogumil Sapinski Date: Thu, 22 Jun 2023 12:48:46 +0200 Subject: [PATCH 2/6] Revert "fix unused-parameter warning in samples" This reverts commit 5f6319ad47776d2a515feadbbedc871dc0857946. --- samples/core/enumopencl/main.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/samples/core/enumopencl/main.cpp b/samples/core/enumopencl/main.cpp index 5d050107..ee180538 100644 --- a/samples/core/enumopencl/main.cpp +++ b/samples/core/enumopencl/main.cpp @@ -67,9 +67,6 @@ static cl_int PrintDeviceInfoSummary(const std::vector devices) int main(int argc, char** argv) { - (void) argc; - (void**) argv; - std::vector platforms; cl::Platform::get(&platforms); std::cout << "Enumerated " << platforms.size() << " platforms.\n\n"; From 681a02c3cacaf4d5aefa9c7396e6a3f392a4becf Mon Sep 17 00:00:00 2001 From: Bogumil Sapinski Date: Fri, 23 Jun 2023 17:38:47 +0200 Subject: [PATCH 3/6] fixed warnings caused by comparing signed and unsigned int --- lib/include/CL/SDK/Image.hpp | 2 +- lib/src/SDK/Image.cpp | 2 +- lib/src/Utils/File.cpp | 2 +- samples/core/copybuffer/main.cpp | 2 +- samples/core/copybufferkernel/main.cpp | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/include/CL/SDK/Image.hpp b/lib/include/CL/SDK/Image.hpp index 6e241a4e..3dddbb05 100644 --- a/lib/include/CL/SDK/Image.hpp +++ b/lib/include/CL/SDK/Image.hpp @@ -10,7 +10,7 @@ namespace cl { namespace sdk { struct Image { - int width = 0, height = 0, pixel_size = 1; + size_t width = 0, height = 0, pixel_size = 1; cl::vector pixels; }; diff --git a/lib/src/SDK/Image.cpp b/lib/src/SDK/Image.cpp index c17a3d14..e3d4cfa7 100644 --- a/lib/src/SDK/Image.cpp +++ b/lib/src/SDK/Image.cpp @@ -31,7 +31,7 @@ namespace sdk { Image im; unsigned char* data = - stbi_load(file_name, &im.width, &im.height, &im.pixel_size, 0); + stbi_load(file_name, reinterpret_cast(&im.width), reinterpret_cast(&im.height), reinterpret_cast(&im.pixel_size), 0); if (data == nullptr) { diff --git a/lib/src/Utils/File.cpp b/lib/src/Utils/File.cpp index a62efb62..4ff44f23 100644 --- a/lib/src/Utils/File.cpp +++ b/lib/src/Utils/File.cpp @@ -97,7 +97,7 @@ cl_int cl::util::write_binaries(const cl::Program::Binaries& binaries, { try { - for (auto i = 0; i < binaries.size(); ++i) + for (auto i = 0U; i < binaries.size(); ++i) { string binary_name = string(program_file_name) + "-" + devices.at(i).getInfo() + ".bin"; diff --git a/samples/core/copybuffer/main.cpp b/samples/core/copybuffer/main.cpp index e9b53f45..5429afa6 100644 --- a/samples/core/copybuffer/main.cpp +++ b/samples/core/copybuffer/main.cpp @@ -95,7 +95,7 @@ int main(int argc, char** argv) } else { - for (size_t i = 1; i < argc; i++) + for (int i = 1; i < argc; i++) { if (!strcmp(argv[i], "-d")) { diff --git a/samples/core/copybufferkernel/main.cpp b/samples/core/copybufferkernel/main.cpp index 26d046d6..1b14cfc2 100644 --- a/samples/core/copybufferkernel/main.cpp +++ b/samples/core/copybufferkernel/main.cpp @@ -106,7 +106,7 @@ int main(int argc, char** argv) } else { - for (size_t i = 1; i < argc; i++) + for (int i = 1; i < argc; i++) { if (!strcmp(argv[i], "-d")) { From 06ba952ca1d036ca0e5bab99c6058e64a235c760 Mon Sep 17 00:00:00 2001 From: Bogumil Sapinski Date: Thu, 29 Jun 2023 13:20:41 +0200 Subject: [PATCH 4/6] fixed formatting --- lib/src/SDK/Image.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/src/SDK/Image.cpp b/lib/src/SDK/Image.cpp index e3d4cfa7..c1c941de 100644 --- a/lib/src/SDK/Image.cpp +++ b/lib/src/SDK/Image.cpp @@ -31,7 +31,9 @@ namespace sdk { Image im; unsigned char* data = - stbi_load(file_name, reinterpret_cast(&im.width), reinterpret_cast(&im.height), reinterpret_cast(&im.pixel_size), 0); + stbi_load(file_name, reinterpret_cast(&im.width), + reinterpret_cast(&im.height), + reinterpret_cast(&im.pixel_size), 0); if (data == nullptr) { From 8988c0f1377c7ea9b50304b949984b0b5bfe3734 Mon Sep 17 00:00:00 2001 From: Bogumil Sapinski Date: Tue, 11 Jul 2023 13:31:44 +0200 Subject: [PATCH 5/6] fixing warning sign-compare other way --- lib/include/CL/SDK/Image.hpp | 2 +- lib/src/SDK/Image.cpp | 11 +++++------ samples/core/blur/blur.cpp | 4 ++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/include/CL/SDK/Image.hpp b/lib/include/CL/SDK/Image.hpp index 3dddbb05..6e241a4e 100644 --- a/lib/include/CL/SDK/Image.hpp +++ b/lib/include/CL/SDK/Image.hpp @@ -10,7 +10,7 @@ namespace cl { namespace sdk { struct Image { - size_t width = 0, height = 0, pixel_size = 1; + int width = 0, height = 0, pixel_size = 1; cl::vector pixels; }; diff --git a/lib/src/SDK/Image.cpp b/lib/src/SDK/Image.cpp index c1c941de..2be3b576 100644 --- a/lib/src/SDK/Image.cpp +++ b/lib/src/SDK/Image.cpp @@ -31,9 +31,7 @@ namespace sdk { Image im; unsigned char* data = - stbi_load(file_name, reinterpret_cast(&im.width), - reinterpret_cast(&im.height), - reinterpret_cast(&im.pixel_size), 0); + stbi_load(file_name, &im.width, &im.height, &im.pixel_size, 0); if (data == nullptr) { @@ -46,11 +44,12 @@ namespace sdk { err_msg.c_str()); } - im.pixels.insert(im.pixels.end(), data, - data + im.width * im.height * im.pixel_size); + std::size_t data_size = im.width * im.height * im.pixel_size; + + im.pixels.insert(im.pixels.end(), data, data + data_size); if (im.width && im.height && im.pixel_size - && im.pixels.size() == im.width * im.height * im.pixel_size) + && im.pixels.size() == data_size) err = CL_SUCCESS; else cl::util::detail::errHandler(CL_INVALID_ARG_VALUE, &err, diff --git a/samples/core/blur/blur.cpp b/samples/core/blur/blur.cpp index c19eca91..2c5d9438 100644 --- a/samples/core/blur/blur.cpp +++ b/samples/core/blur/blur.cpp @@ -732,9 +732,9 @@ void BlurCppExample::finalize_blur() // restore image type if needed if (input_image.pixel_size != output_image.pixel_size) { - const auto pixels = input_image.width * input_image.height, + const std::size_t pixels = input_image.width * input_image.height, pixel_size = output_image.pixel_size; - for (size_t i = 1; i < pixels; ++i) + for (std::size_t i = 1; i < pixels; ++i) memcpy(output_image.pixels.data() + pixel_size * i, output_image.pixels.data() + 4 * i, pixel_size); } From 1347fc6f77c6b6af28f761444e1e6646b4b3d9cd Mon Sep 17 00:00:00 2001 From: Bogumil Sapinski Date: Tue, 11 Jul 2023 18:02:29 +0200 Subject: [PATCH 6/6] formatting --- samples/core/blur/blur.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/core/blur/blur.cpp b/samples/core/blur/blur.cpp index 2c5d9438..06f6dd52 100644 --- a/samples/core/blur/blur.cpp +++ b/samples/core/blur/blur.cpp @@ -733,7 +733,7 @@ void BlurCppExample::finalize_blur() if (input_image.pixel_size != output_image.pixel_size) { const std::size_t pixels = input_image.width * input_image.height, - pixel_size = output_image.pixel_size; + pixel_size = output_image.pixel_size; for (std::size_t i = 1; i < pixels; ++i) memcpy(output_image.pixels.data() + pixel_size * i, output_image.pixels.data() + 4 * i, pixel_size);