From 36ba43d6ea38062b17f7e63ef659962bfc51c64d Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 6 Jun 2017 23:34:34 +0300 Subject: Fix clang-tidy check readability-implicit-bool-cast. --- src/resources/dye/dye.cpp | 26 ++++++++++++----------- src/resources/dye/dyepalette.cpp | 6 +++--- src/resources/dye/dyepalette_replaceacolor.cpp | 12 +++++------ src/resources/dye/dyepalette_replaceaoglcolor.cpp | 12 +++++------ src/resources/dye/dyepalette_replacescolor.cpp | 12 +++++------ src/resources/dye/dyepalette_replacesoglcolor.cpp | 12 +++++------ 6 files changed, 41 insertions(+), 39 deletions(-) (limited to 'src/resources/dye') diff --git a/src/resources/dye/dye.cpp b/src/resources/dye/dye.cpp index b9c9e4cd8..70d2a21b1 100644 --- a/src/resources/dye/dye.cpp +++ b/src/resources/dye/dye.cpp @@ -143,9 +143,9 @@ void Dye::instantiate(std::string &restrict target, int Dye::getType() const restrict2 noexcept2 { - if (mDyePalettes[sPaleteIndex]) + if (mDyePalettes[sPaleteIndex] != nullptr) return 1; - if (mDyePalettes[aPaleteIndex]) + if (mDyePalettes[aPaleteIndex] != nullptr) return 2; return 0; } @@ -153,7 +153,7 @@ int Dye::getType() const restrict2 noexcept2 void Dye::normalDye(uint32_t *restrict pixels, const int bufSize) const restrict2 { - if (!pixels) + if (pixels == nullptr) return; #ifdef ENABLE_CILKPLUS @@ -230,7 +230,7 @@ endlabel:{} const int alpha = p & 0xff; #endif // SDL_BYTEORDER == SDL_BIG_ENDIAN - if (!alpha) + if (alpha == 0) continue; unsigned int color[3]; #if SDL_BYTEORDER == SDL_BIG_ENDIAN @@ -260,10 +260,11 @@ endlabel:{} continue; } - const unsigned int i = (color[0] != 0) | ((color[1] != 0) << 1) - | ((color[2] != 0) << 2); + const unsigned int i = static_cast(color[0] != 0) | + (static_cast(color[1] != 0) << 1) | + (static_cast(color[2] != 0) << 2); - if (mDyePalettes[i - 1]) + if (mDyePalettes[i - 1] != nullptr) mDyePalettes[i - 1]->getColor(cmax, color); #if SDL_BYTEORDER == SDL_BIG_ENDIAN @@ -281,7 +282,7 @@ endlabel:{} void Dye::normalOGLDye(uint32_t *restrict pixels, const int bufSize) const restrict2 { - if (!pixels) + if (pixels == nullptr) return; #ifdef ENABLE_CILKPLUS @@ -357,7 +358,7 @@ endlabel:{} const int alpha = p & 0xff000000; #endif // SDL_BYTEORDER == SDL_BIG_ENDIAN - if (!alpha) + if (alpha == 0) continue; unsigned int color[3]; #if SDL_BYTEORDER == SDL_BIG_ENDIAN @@ -387,10 +388,11 @@ endlabel:{} continue; } - const unsigned int i = (color[0] != 0) | ((color[1] != 0) << 1) - | ((color[2] != 0) << 2); + const unsigned int i = static_cast(color[0] != 0) | + (static_cast(color[1] != 0) << 1) | + (static_cast(color[2] != 0) << 2); - if (mDyePalettes[i - 1]) + if (mDyePalettes[i - 1] != nullptr) mDyePalettes[i - 1]->getColor(cmax, color); #if SDL_BYTEORDER == SDL_BIG_ENDIAN diff --git a/src/resources/dye/dyepalette.cpp b/src/resources/dye/dyepalette.cpp index 65063959b..cf1d7c205 100644 --- a/src/resources/dye/dyepalette.cpp +++ b/src/resources/dye/dyepalette.cpp @@ -97,7 +97,7 @@ DyePalette::DyePalette(const std::string &restrict description, continue; } const DyeColor *const color = PaletteDB::getColor(str); - if (color) + if (color != nullptr) { DyeColor color2 = *color; color2.value[3] = alpha; @@ -249,7 +249,7 @@ void DyePalette::initFunctions() { #ifdef SIMD_SUPPORTED const uint32_t flags = Cpu::getFlags(); - if (flags & Cpu::FEATURE_AVX2) + if ((flags & Cpu::FEATURE_AVX2) != 0u) { funcReplaceSColor = &DyePalette::replaceSColorAvx2; funcReplaceSColorAvx2 = &DyePalette::replaceSColorAvx2; @@ -267,7 +267,7 @@ void DyePalette::initFunctions() funcReplaceAOGLColorSse2 = &DyePalette::replaceAOGLColorSse2; #endif // USE_OPENGL } - else if (flags & Cpu::FEATURE_SSE2) + else if ((flags & Cpu::FEATURE_SSE2) != 0u) { funcReplaceSColor = &DyePalette::replaceSColorSse2; funcReplaceSColorAvx2 = &DyePalette::replaceSColorSse2; diff --git a/src/resources/dye/dyepalette_replaceacolor.cpp b/src/resources/dye/dyepalette_replaceacolor.cpp index 718a85853..21cd0b0c5 100644 --- a/src/resources/dye/dyepalette_replaceacolor.cpp +++ b/src/resources/dye/dyepalette_replaceacolor.cpp @@ -38,9 +38,9 @@ void DyePalette::replaceAColorDefault(uint32_t *restrict pixels, { std::vector::const_iterator it_end = mColors.end(); const size_t sz = mColors.size(); - if (!sz || !pixels) + if ((sz == 0u) || (pixels == nullptr)) return; - if (sz % 2) + if ((sz % 2) != 0u) -- it_end; #ifdef ENABLE_CILKPLUS @@ -140,9 +140,9 @@ void DyePalette::replaceAColorSse2(uint32_t *restrict pixels, { std::vector::const_iterator it_end = mColors.end(); const size_t sz = mColors.size(); - if (!sz || !pixels) + if ((sz == 0u) || (pixels == nullptr)) return; - if (sz % 2) + if ((sz % 2) != 0u) -- it_end; const int mod = bufSize % 4; const int bufEnd = bufSize - mod; @@ -211,9 +211,9 @@ void DyePalette::replaceAColorAvx2(uint32_t *restrict pixels, { std::vector::const_iterator it_end = mColors.end(); const size_t sz = mColors.size(); - if (!sz || !pixels) + if ((sz == 0u) || (pixels == nullptr)) return; - if (sz % 2) + if ((sz % 2) != 0u) -- it_end; const int mod = bufSize % 8; const int bufEnd = bufSize - mod; diff --git a/src/resources/dye/dyepalette_replaceaoglcolor.cpp b/src/resources/dye/dyepalette_replaceaoglcolor.cpp index 19f74d4c7..c0225df65 100644 --- a/src/resources/dye/dyepalette_replaceaoglcolor.cpp +++ b/src/resources/dye/dyepalette_replaceaoglcolor.cpp @@ -40,9 +40,9 @@ void DyePalette::replaceAOGLColorDefault(uint32_t *restrict pixels, { std::vector::const_iterator it_end = mColors.end(); const size_t sz = mColors.size(); - if (!sz || !pixels) + if (sz == 0u || pixels == nullptr) return; - if (sz % 2) + if ((sz % 2) != 0u) -- it_end; #ifdef ENABLE_CILKPLUS @@ -143,9 +143,9 @@ void DyePalette::replaceAOGLColorSse2(uint32_t *restrict pixels, { std::vector::const_iterator it_end = mColors.end(); const size_t sz = mColors.size(); - if (!sz || !pixels) + if (sz == 0u || pixels == nullptr) return; - if (sz % 2) + if ((sz % 2) != 0u) -- it_end; if (bufSize >= 8) @@ -269,9 +269,9 @@ void DyePalette::replaceAOGLColorAvx2(uint32_t *restrict pixels, { std::vector::const_iterator it_end = mColors.end(); const size_t sz = mColors.size(); - if (!sz || !pixels) + if (sz == 0u || pixels == nullptr) return; - if (sz % 2) + if ((sz % 2) != 0u) -- it_end; if (bufSize >= 8) diff --git a/src/resources/dye/dyepalette_replacescolor.cpp b/src/resources/dye/dyepalette_replacescolor.cpp index 3f14adb74..0a4206e83 100644 --- a/src/resources/dye/dyepalette_replacescolor.cpp +++ b/src/resources/dye/dyepalette_replacescolor.cpp @@ -38,9 +38,9 @@ void DyePalette::replaceSColorDefault(uint32_t *restrict pixels, { std::vector::const_iterator it_end = mColors.end(); const size_t sz = mColors.size(); - if (!sz || !pixels) + if (sz == 0u || pixels == nullptr) return; - if (sz % 2) + if ((sz % 2) != 0u) -- it_end; #ifdef ENABLE_CILKPLUS @@ -138,9 +138,9 @@ void DyePalette::replaceSColorSse2(uint32_t *restrict pixels, { std::vector::const_iterator it_end = mColors.end(); const size_t sz = mColors.size(); - if (!sz || !pixels) + if (sz == 0u || pixels == nullptr) return; - if (sz % 2) + if ((sz % 2) != 0u) -- it_end; const int mod = bufSize % 8; const int bufEnd = bufSize - mod; @@ -219,9 +219,9 @@ void DyePalette::replaceSColorAvx2(uint32_t *restrict pixels, { std::vector::const_iterator it_end = mColors.end(); const size_t sz = mColors.size(); - if (!sz || !pixels) + if (sz == 0u || pixels == nullptr) return; - if (sz % 2) + if ((sz % 2) != 0u) -- it_end; const int mod = bufSize % 8; const int bufEnd = bufSize - mod; diff --git a/src/resources/dye/dyepalette_replacesoglcolor.cpp b/src/resources/dye/dyepalette_replacesoglcolor.cpp index da7cd0519..cde7fac8e 100644 --- a/src/resources/dye/dyepalette_replacesoglcolor.cpp +++ b/src/resources/dye/dyepalette_replacesoglcolor.cpp @@ -40,9 +40,9 @@ void DyePalette::replaceSOGLColorDefault(uint32_t *restrict pixels, { std::vector::const_iterator it_end = mColors.end(); const size_t sz = mColors.size(); - if (!sz || !pixels) + if ((sz == 0u) || (pixels == nullptr)) return; - if (sz % 2) + if ((sz % 2) != 0u) -- it_end; #ifdef ENABLE_CILKPLUS @@ -143,9 +143,9 @@ void DyePalette::replaceSOGLColorSse2(uint32_t *restrict pixels, { std::vector::const_iterator it_end = mColors.end(); const size_t sz = mColors.size(); - if (!sz || !pixels) + if ((sz == 0u) || (pixels == nullptr)) return; - if (sz % 2) + if ((sz % 2) != 0u) -- it_end; if (bufSize >= 8) @@ -271,9 +271,9 @@ void DyePalette::replaceSOGLColorAvx2(uint32_t *restrict pixels, { std::vector::const_iterator it_end = mColors.end(); const size_t sz = mColors.size(); - if (!sz || !pixels) + if ((sz == 0u) || (pixels == nullptr)) return; - if (sz % 2) + if ((sz % 2) != 0u) -- it_end; if (bufSize >= 8) -- cgit v1.2.3-70-g09d2