various code fixes

From <https://scan.coverity.com/projects/emulationstation?tab=overview>.
This commit is contained in:
Nico Schlömer 2017-07-28 09:57:37 +02:00
parent c874c506d9
commit 419e6c43e0
6 changed files with 19 additions and 9 deletions

View file

@ -21,7 +21,7 @@ VolumeControl::VolumeControl()
#if defined (__APPLE__) #if defined (__APPLE__)
#error TODO: Not implemented for MacOS yet!!! #error TODO: Not implemented for MacOS yet!!!
#elif defined(__linux__) #elif defined(__linux__)
, mixerIndex(0), mixerHandle(nullptr), mixerElem(nullptr), mixerSelemId(nullptr) , mixerIndex(0), mixerHandle(nullptr), mixerElem(nullptr), mixerSelemId(nullptr)
#elif defined(WIN32) || defined(_WIN32) #elif defined(WIN32) || defined(_WIN32)
, mixerHandle(nullptr), endpointVolume(nullptr) , mixerHandle(nullptr), endpointVolume(nullptr)
#endif #endif
@ -32,7 +32,15 @@ VolumeControl::VolumeControl()
originalVolume = getVolume(); originalVolume = getVolume();
} }
VolumeControl::VolumeControl(const VolumeControl & right) VolumeControl::VolumeControl(const VolumeControl & right):
originalVolume(0), internalVolume(0)
#if defined (__APPLE__)
#error TODO: Not implemented for MacOS yet!!!
#elif defined(__linux__)
, mixerIndex(0), mixerHandle(nullptr), mixerElem(nullptr), mixerSelemId(nullptr)
#elif defined(WIN32) || defined(_WIN32)
, mixerHandle(nullptr), endpointVolume(nullptr)
#endif
{ {
sInstance = right.sInstance; sInstance = right.sInstance;
} }

View file

@ -335,8 +335,8 @@ void Window::setHelpPrompts(const std::vector<HelpPrompt>& prompts, const HelpSt
// yes, it has! // yes, it has!
// can we combine? (dpad only) // can we combine? (dpad only)
if((it->first == "up/down" && addPrompts.at(mappedTo->second).first == "left/right") || if((strcmp(it->first, "up/down") == 0 && strcmp(addPrompts.at(mappedTo->second).first, "left/right")) ||
(it->first == "left/right" && addPrompts.at(mappedTo->second).first == "up/down")) (strcmp(it->first, "left/right") == 0 && strcmp(addPrompts.at(mappedTo->second).first, "up/down")))
{ {
// yes! // yes!
addPrompts.at(mappedTo->second).first = "up/down/left/right"; addPrompts.at(mappedTo->second).first = "up/down/left/right";

View file

@ -8,6 +8,8 @@ class LambdaAnimation : public Animation
public: public:
LambdaAnimation(const std::function<void(float t)>& func, int duration) : mFunction(func), mDuration(duration) {} LambdaAnimation(const std::function<void(float t)>& func, int duration) : mFunction(func), mDuration(duration) {}
virtual ~LambdaAnimation() = default;
int getDuration() const override { return mDuration; } int getDuration() const override { return mDuration; }
void apply(float t) override void apply(float t) override

View file

@ -430,15 +430,15 @@ std::vector<HelpPrompt> ComponentGrid::getHelpPrompts()
bool canScrollHoriz = mGridSize.x() > 1; bool canScrollHoriz = mGridSize.x() > 1;
for(auto it = prompts.begin(); it != prompts.end(); it++) for(auto it = prompts.begin(); it != prompts.end(); it++)
{ {
if(it->first == "up/down/left/right") if(strcmp(it->first, "up/down/left/right") == 0)
{ {
canScrollHoriz = false; canScrollHoriz = false;
canScrollVert = false; canScrollVert = false;
break; break;
}else if(it->first == "up/down") }else if(strcmp(it->first, "up/down") == 0)
{ {
canScrollVert = false; canScrollVert = false;
}else if(it->first == "left/right") }else if(strcmp(it->first, "left/right") == 0)
{ {
canScrollHoriz = false; canScrollHoriz = false;
} }

View file

@ -319,7 +319,7 @@ std::vector<HelpPrompt> ComponentList::getHelpPrompts()
bool addMovePrompt = true; bool addMovePrompt = true;
for(auto it = prompts.begin(); it != prompts.end(); it++) for(auto it = prompts.begin(); it != prompts.end(); it++)
{ {
if(it->first == "up/down" || it->first == "up/down/left/right") if(strcmp(it->first, "up/down") == 0 || strcmp(it->first, "up/down/left/right") == 0)
{ {
addMovePrompt = false; addMovePrompt = false;
break; break;

View file

@ -396,7 +396,7 @@ bool GuiInputConfig::assign(Input input, int inputId)
// if this input is mapped to something other than "nothing" or the current row, error // if this input is mapped to something other than "nothing" or the current row, error
// (if it's the same as what it was before, allow it) // (if it's the same as what it was before, allow it)
if(mTargetConfig->getMappedTo(input).size() > 0 && !mTargetConfig->isMappedTo(inputName[inputId], input) && inputName[inputId] != "HotKeyEnable") if(mTargetConfig->getMappedTo(input).size() > 0 && !mTargetConfig->isMappedTo(inputName[inputId], input) && strcmp(inputName[inputId], "HotKeyEnable") != 0)
{ {
error(mMappings.at(inputId), "Already mapped!"); error(mMappings.at(inputId), "Already mapped!");
return false; return false;