Commit f29e512d authored by Victor Poughon's avatar Victor Poughon

Merge branch 'coverity-fixes' into release-6.2

parents 3332bf1c 2aea6018
...@@ -195,9 +195,16 @@ std::string MapProjectionAdapter::GetParameter(const std::string& key) const ...@@ -195,9 +195,16 @@ std::string MapProjectionAdapter::GetParameter(const std::string& key) const
if (projectionName.compare("ossimTransMercatorProjection") == 0) if (projectionName.compare("ossimTransMercatorProjection") == 0)
{ {
const ossimTransMercatorProjection* tmProjection = dynamic_cast<const ossimTransMercatorProjection*>(this->GetMapProjection()); const ossimTransMercatorProjection* tmProjection = dynamic_cast<const ossimTransMercatorProjection*>(this->GetMapProjection());
if (key.compare("ScaleFactor") == 0) if (!tmProjection)
{ {
return Utils::ConvertToString(tmProjection->getScaleFactor()); itkExceptionMacro("Error casting object to ossimTransMercatorProjection.");
}
else
{
if (key.compare("ScaleFactor") == 0)
{
return Utils::ConvertToString(tmProjection->getScaleFactor());
}
} }
} }
......
...@@ -249,7 +249,7 @@ int otbGenericRSTransformGenericTest(int argc, char * argv[]) ...@@ -249,7 +249,7 @@ int otbGenericRSTransformGenericTest(int argc, char * argv[])
if(inRes>inThreshold) if(inRes>inThreshold)
{ {
failed = true; failed = true;
std::cerr<<"Input residual ("<<outRes<<") outpasses the threshold ("<<inThreshold<<")"<<std::endl; std::cerr<<"Input residual ("<<inRes<<") outpasses the threshold ("<<inThreshold<<")"<<std::endl;
std::cerr<<std::endl; std::cerr<<std::endl;
} }
......
...@@ -49,7 +49,7 @@ public: ...@@ -49,7 +49,7 @@ public:
typedef struct Parameter typedef struct Parameter
{ {
/** Maximum size of the internal patterns */ /** Maximum size of the internal patterns */
unsigned long MaxPatternSize; unsigned long MaxPatternSize = 0;
/** First sampling pattern */ /** First sampling pattern */
std::vector<bool> Pattern1; std::vector<bool> Pattern1;
...@@ -59,7 +59,7 @@ public: ...@@ -59,7 +59,7 @@ public:
std::vector<bool> Pattern2; std::vector<bool> Pattern2;
/** Seed used to randomly generate patterns (used only if greater than 0) */ /** Seed used to randomly generate patterns (used only if greater than 0) */
unsigned int Seed; unsigned int Seed = 0;
bool operator!=(const struct Parameter & param) const; bool operator!=(const struct Parameter & param) const;
} ParameterType; } ParameterType;
......
...@@ -114,7 +114,7 @@ int parseCommandLine(int ac, char * av[], std::vector<char *>& remainingArgs) ...@@ -114,7 +114,7 @@ int parseCommandLine(int ac, char * av[], std::vector<char *>& remainingArgs)
if (oldenv2) if (oldenv2)
{ {
libpath64 += KWSYS_SHARED_FORWARD_PATH_SEP; libpath64 += KWSYS_SHARED_FORWARD_PATH_SEP;
libpath64 += oldenv; libpath64 += oldenv2;
} }
itksys::SystemTools::PutEnv(libpath64.c_str()); itksys::SystemTools::PutEnv(libpath64.c_str());
} }
......
...@@ -94,7 +94,7 @@ int otbImageToImageRCC8Calculator(int itkNotUsed(argc), char* argv[]) ...@@ -94,7 +94,7 @@ int otbImageToImageRCC8Calculator(int itkNotUsed(argc), char* argv[])
{ {
std::cout << "Test failed: Result with level3AprioriKnowledge "; std::cout << "Test failed: Result with level3AprioriKnowledge ";
std::cout << "different from result without a priori knowledge" << std::endl; std::cout << "different from result without a priori knowledge" << std::endl;
std::cout << calc->GetValue() << "!=" << calc1->GetValue() << std::endl; std::cout << calc->GetValue() << "!=" << calc2->GetValue() << std::endl;
return EXIT_FAILURE; return EXIT_FAILURE;
} }
} }
......
...@@ -34,7 +34,7 @@ namespace otb ...@@ -34,7 +34,7 @@ namespace otb
/** Constructor */ /** Constructor */
SailModel SailModel
::SailModel() : m_LAI(2), m_Angl(50), m_PSoil(1), m_Skyl(70), m_HSpot(0.2), ::SailModel() : m_LAI(2), m_Angl(50), m_PSoil(1), m_Skyl(70), m_HSpot(0.2),
m_TTS(30), m_TTO(0), m_PSI(0), m_FCoverView(0.0), m_UseSoilFile(false) m_TTS(30), m_TTO(0), m_PSI(0), m_FCoverView(0.0), m_UseSoilFile(false), m_SoilIndex(0)
{ {
this->ProcessObject::SetNumberOfRequiredInputs(2); this->ProcessObject::SetNumberOfRequiredInputs(2);
this->ProcessObject::SetNumberOfRequiredOutputs(4); this->ProcessObject::SetNumberOfRequiredOutputs(4);
......
...@@ -622,9 +622,9 @@ public: ...@@ -622,9 +622,9 @@ public:
{ \ { \
Image##Type::Pointer ret; \ Image##Type::Pointer ret; \
Parameter* param = GetParameterByKey(parameter); \ Parameter* param = GetParameterByKey(parameter); \
if (dynamic_cast<ComplexInputImageParameter*>(param)) \ ComplexInputImageParameter* paramDown = dynamic_cast<ComplexInputImageParameter*>(param); \
if (paramDown) \
{ \ { \
ComplexInputImageParameter* paramDown = dynamic_cast<ComplexInputImageParameter*>(param); \
ret = paramDown->Get##Image(); \ ret = paramDown->Get##Image(); \
} \ } \
return ret; \ return ret; \
......
...@@ -817,18 +817,22 @@ std::string CommandLineLauncher::DisplayParameterHelp(const Parameter::Pointer & ...@@ -817,18 +817,22 @@ std::string CommandLineLauncher::DisplayParameterHelp(const Parameter::Pointer &
if (type == ParameterType_Choice) if (type == ParameterType_Choice)
{ {
std::vector<std::string> keys = dynamic_cast<ChoiceParameter*>(param.GetPointer())->GetChoiceKeys(); ChoiceParameter* paramDown = dynamic_cast<ChoiceParameter*>(param.GetPointer());
std::vector<std::string> names = dynamic_cast<ChoiceParameter*>(param.GetPointer())->GetChoiceNames(); if (paramDown)
{
std::vector<std::string> keys = paramDown->GetChoiceKeys();
std::vector<std::string> names = paramDown->GetChoiceNames();
oss << "["; oss << "[";
for(unsigned int i=0; i<keys.size(); i++) for(unsigned int i=0; i<keys.size(); i++)
{ {
oss<<keys[i]; oss<<keys[i];
if( i != keys.size()-1 ) if( i != keys.size()-1 )
oss << "/"; oss << "/";
} }
oss << "]"; oss << "]";
}
} }
if(m_Application->IsMandatory(paramKey)) if(m_Application->IsMandatory(paramKey))
......
...@@ -62,10 +62,12 @@ QtProgressBar::ProcessEvent( itk::Object * caller, ...@@ -62,10 +62,12 @@ QtProgressBar::ProcessEvent( itk::Object * caller,
::itk::ProcessObject::Pointer process = ::itk::ProcessObject::Pointer process =
dynamic_cast< itk::ProcessObject *>( caller ); dynamic_cast< itk::ProcessObject *>( caller );
const int value2 = static_cast<int>( if (process)
process->GetProgress() * this->maximum() ); {
const int value2 = static_cast<int>(
emit SetValueChanged( value2 ); process->GetProgress() * this->maximum() );
emit SetValueChanged( value2 );
}
} }
} }
...@@ -78,10 +80,13 @@ QtProgressBar::ConstProcessEvent( const itk::Object * caller, ...@@ -78,10 +80,13 @@ QtProgressBar::ConstProcessEvent( const itk::Object * caller,
itk::ProcessObject::ConstPointer process = itk::ProcessObject::ConstPointer process =
dynamic_cast< const itk::ProcessObject *>( caller ); dynamic_cast< const itk::ProcessObject *>( caller );
const int v = static_cast<int>( if (process)
process->GetProgress() * this->maximum() ); {
const int v = static_cast<int>(
process->GetProgress() * this->maximum() );
emit SetValueChanged( v ); emit SetValueChanged( v );
}
} }
} }
......
...@@ -109,7 +109,7 @@ int main(int argc, char* argv[]) ...@@ -109,7 +109,7 @@ int main(int argc, char* argv[])
int ret = qtApp.exec(); int ret = qtApp.exec();
// Clean resources // Clean resources
if (mainWindow) delete mainWindow; delete mainWindow;
app = ITK_NULLPTR; app = ITK_NULLPTR;
ApplicationRegistry::CleanRegistry(); ApplicationRegistry::CleanRegistry();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment