From 4f78d92bc8e24c8245a80612327016408c695c18 Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Tue, 16 Nov 2021 17:36:51 +0900 Subject: [PATCH] clang-tidy/clang-format fixes --- src/image.cc | 9 ++++----- src/image.h | 4 ++-- src/main.cc | 4 ++-- src/opencl_handle.cc | 3 ++- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/image.cc b/src/image.cc index 1b227fb..6ee3abf 100644 --- a/src/image.cc +++ b/src/image.cc @@ -272,7 +272,6 @@ void Image::DecodePNG(const std::string &filename) { // pass the FILE pointer to libpng png_init_io(png_ptr, file); - // TODO BEGIN // have libpng process the png data png_read_png(png_ptr, png_info_ptr, PNG_TRANSFORM_IDENTITY, nullptr); @@ -404,7 +403,7 @@ void Image::DecodePGM(const std::string &filename) { << '"' << std::endl; return; } - value = (float)int_input / max_value; + value = static_cast(int_input) / max_value; data_.push_back(std::round(value * 255.0F)); } } else if (str_input.compare("P5") == 0) { @@ -453,7 +452,7 @@ void Image::DecodePGM(const std::string &filename) { std::cout << "WARNING: File data after PGM max is not whitespace " "(filename \"" << filename << "\")" - << " value is " << (int)c << std::endl; + << " value is " << c << std::endl; } if (!ifs.good()) { @@ -557,7 +556,7 @@ void Image::DecodePPM(const std::string &filename) { << '"' << std::endl; return; } - value = (float)int_input / max_value; + value = static_cast(int_input) / max_value; data_.push_back(std::round(value * 255.0F)); if (i % 3 == 2) { // PPM is RGB but Image stores as RGBA @@ -609,7 +608,7 @@ void Image::DecodePPM(const std::string &filename) { if (c != '\n' && c != ' ') { std::cout << "WARNING: File data after PPM max is not whitespace (filename \"" - << filename << "\") value is " << (int)c << std::endl; + << filename << "\") value is " << c << std::endl; } if (!ifs.good()) { diff --git a/src/image.h b/src/image.h index 66f453a..ed4701e 100644 --- a/src/image.h +++ b/src/image.h @@ -17,10 +17,10 @@ class Image { * Image supports decoding .png, .pgm, and .ppm . Decoding only checks the * filename suffix as a guide on which file-type to expect. */ - Image(const char *filename); + explicit Image(const char *filename); /// Same constructor as Image(const char *filename) - Image(const std::string &filename); + explicit Image(const std::string &filename); // allow copy Image(const Image &other) = default; diff --git a/src/main.cc b/src/main.cc index c5d069f..c424458 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1,8 +1,8 @@ #include "image.h" int main(int argc, char **argv) { - //Image image("testin.ppm"); - //image.SaveAsPNG("testout.png", true); + // Image image("testin.ppm"); + // image.SaveAsPNG("testout.png", true); return 0; } diff --git a/src/opencl_handle.cc b/src/opencl_handle.cc index d3b5b8f..1710414 100644 --- a/src/opencl_handle.cc +++ b/src/opencl_handle.cc @@ -562,7 +562,8 @@ OpenCLContext::OpenCLContext() : context_(nullptr), queue_(nullptr) { } cl_context_properties context_properties[] = { - CL_CONTEXT_PLATFORM, (cl_context_properties)first_platform_id, 0}; + CL_CONTEXT_PLATFORM, + static_cast(first_platform_id), 0}; context_ = clCreateContextFromType(context_properties, CL_DEVICE_TYPE_GPU, nullptr, nullptr, &err_num);