From 1cee40f291add2e7dd62b0f5d0ba9af23a846c98 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Fri, 9 Jul 2021 19:58:21 +0200 Subject: [PATCH] Some minor changes proposed by the static analyzer. --- es-app/src/MiximageGenerator.cpp | 2 +- es-core/src/AudioManager.cpp | 7 ++----- es-core/src/Scripting.cpp | 18 ++++++++++++------ 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/es-app/src/MiximageGenerator.cpp b/es-app/src/MiximageGenerator.cpp index d16105bef..12e2f6f4a 100644 --- a/es-app/src/MiximageGenerator.cpp +++ b/es-app/src/MiximageGenerator.cpp @@ -627,7 +627,7 @@ void MiximageGenerator::sampleFrameColor(CImg& screenshotImage, // Convert to the HSL color space to be able to modify saturation and lightness. CImg colorHSL = CImg<>(1, 1, 1, 3).fill(redC, greenC, blueC).RGBtoHSL(); - float hue = colorHSL(0, 0, 0, 0); + // float hue = colorHSL(0, 0, 0, 0); float saturation = colorHSL(0, 0, 0, 1); float lightness = colorHSL(0, 0, 0, 2); diff --git a/es-core/src/AudioManager.cpp b/es-core/src/AudioManager.cpp index 8ca75fa41..b3f9e7632 100644 --- a/es-core/src/AudioManager.cpp +++ b/es-core/src/AudioManager.cpp @@ -307,17 +307,14 @@ void AudioManager::clearStream() // SDL_AudioStreamClear(sConversionStream); mIsClearingStream = true; - - int streamSize; int length = sAudioFormat.samples * 4; - while ((streamSize = SDL_AudioStreamAvailable(sConversionStream)) > 0) { + while (SDL_AudioStreamAvailable(sConversionStream) > 0) { std::vector readBuffer(length); int processedLength = SDL_AudioStreamGet(sConversionStream, static_cast(&readBuffer.at(0)), length); - if (processedLength <= 0) { + if (processedLength <= 0) break; - } } mIsClearingStream = false; diff --git a/es-core/src/Scripting.cpp b/es-core/src/Scripting.cpp index 5e3cd926f..dadb3db36 100644 --- a/es-core/src/Scripting.cpp +++ b/es-core/src/Scripting.cpp @@ -37,11 +37,9 @@ namespace Scripting if (Utils::FileSystem::exists(scriptDir)) scriptDirList.push_back(scriptDir); - for (std::list::const_iterator dirIt = scriptDirList.cbegin(); - dirIt != scriptDirList.cend(); dirIt++) { + for (auto dirIt = scriptDirList.cbegin(); dirIt != scriptDirList.cend(); dirIt++) { std::list scripts = Utils::FileSystem::getDirContent(*dirIt); - for (std::list::const_iterator it = scripts.cbegin(); // Line break. - it != scripts.cend(); it++) { + for (auto it = scripts.cbegin(); it != scripts.cend(); it++) { std::string arg1Quotation; std::string arg2Quotation; // Add quotation marks around the arguments as long as these are not already @@ -50,8 +48,16 @@ namespace Scripting arg1Quotation = "\""; if (arg2.front() != '\"') arg2Quotation = "\""; - std::string script = *it + " " + arg1Quotation + arg1 + arg1Quotation + " " + - arg2Quotation + arg2 + arg2Quotation; + std::string script; + script.append(*it) + .append(" ") + .append(arg1Quotation) + .append(arg1) + .append(arg1Quotation) + .append(" ") + .append(arg2Quotation) + .append(arg2) + .append(arg2Quotation); LOG(LogDebug) << "Executing: " << script; runSystemCommand(script); }