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__)
#error TODO: Not implemented for MacOS yet!!!
#elif defined(__linux__)
, mixerIndex(0), mixerHandle(nullptr), mixerElem(nullptr), mixerSelemId(nullptr)
, mixerIndex(0), mixerHandle(nullptr), mixerElem(nullptr), mixerSelemId(nullptr)
#elif defined(WIN32) || defined(_WIN32)
, mixerHandle(nullptr), endpointVolume(nullptr)
#endif
@ -32,7 +32,15 @@ VolumeControl::VolumeControl()
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;
}

View file

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

View file

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

View file

@ -430,15 +430,15 @@ std::vector<HelpPrompt> ComponentGrid::getHelpPrompts()
bool canScrollHoriz = mGridSize.x() > 1;
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;
canScrollVert = false;
break;
}else if(it->first == "up/down")
}else if(strcmp(it->first, "up/down") == 0)
{
canScrollVert = false;
}else if(it->first == "left/right")
}else if(strcmp(it->first, "left/right") == 0)
{
canScrollHoriz = false;
}

View file

@ -319,7 +319,7 @@ std::vector<HelpPrompt> ComponentList::getHelpPrompts()
bool addMovePrompt = true;
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;
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 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!");
return false;