From 20865daf729fcee2cccfa02b60e6d23a7007fefa Mon Sep 17 00:00:00 2001 From: Federico Montesino Pouzols Date: Thu, 28 May 2015 16:50:25 +0100 Subject: [PATCH] fix coverity uninits issues in API, 1075490...1075499, re #11829 --- .../Framework/API/inc/MantidAPI/IFunction.h | 9 ++++---- Code/Mantid/Framework/API/src/Algorithm.cpp | 15 ++++++++----- .../Framework/API/src/BoxController.cpp | 22 ++++++++++--------- .../Framework/API/src/CompositeFunction.cpp | 2 +- .../API/src/IPowderDiffPeakFunction.cpp | 5 ++++- .../Algorithms/src/RemoveLowResTOF.cpp | 2 +- 6 files changed, 32 insertions(+), 23 deletions(-) diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/IFunction.h b/Code/Mantid/Framework/API/inc/MantidAPI/IFunction.h index 93060ff2bbff..519a32431bca 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/IFunction.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/IFunction.h @@ -247,16 +247,17 @@ class MANTID_API_DLL IFunction { explicit Attribute(const std::string &str, bool quoteValue = false) : m_data(str), m_quoteValue(quoteValue) {} /// Create int attribute - explicit Attribute(const int &i) : m_data(i) {} + explicit Attribute(const int &i) : m_data(i), m_quoteValue(false) {} /// Create double attribute - explicit Attribute(const double &d) : m_data(d) {} + explicit Attribute(const double &d) : m_data(d), m_quoteValue(false) {} /// Create bool attribute - explicit Attribute(const bool &b) : m_data(b) {} + explicit Attribute(const bool &b) : m_data(b), m_quoteValue(false) {} /// Create string attribute explicit Attribute(const char *c) : m_data(std::string(c)), m_quoteValue(false) {} /// Create vector attribute - explicit Attribute(const std::vector &v) : m_data(v) {} + explicit Attribute(const std::vector &v) + : m_data(v), m_quoteValue(false) {} /// Apply an attribute visitor template T apply(AttributeVisitor &v) { diff --git a/Code/Mantid/Framework/API/src/Algorithm.cpp b/Code/Mantid/Framework/API/src/Algorithm.cpp index f66d32bd9239..1fba0af0a239 100644 --- a/Code/Mantid/Framework/API/src/Algorithm.cpp +++ b/Code/Mantid/Framework/API/src/Algorithm.cpp @@ -75,8 +75,9 @@ Algorithm::Algorithm() m_isInitialized(false), m_isExecuted(false), m_isChildAlgorithm(false), m_recordHistoryForChild(false), m_alwaysStoreInADS(false), m_runningAsync(false), m_running(false), m_rethrow(false), - m_isAlgStartupLoggingEnabled(true), m_algorithmID(this), - m_singleGroup(-1), m_groupsHaveSimilarNames(false) {} + m_isAlgStartupLoggingEnabled(true), m_startChildProgress(0.), + m_endChildProgress(0.), m_algorithmID(this), m_singleGroup(-1), + m_groupsHaveSimilarNames(false) {} /// Virtual destructor Algorithm::~Algorithm() { @@ -884,7 +885,8 @@ IAlgorithm_sptr Algorithm::fromString(const std::string &input) { } catch (boost::bad_lexical_cast &) { } } - IAlgorithm_sptr alg = AlgorithmManager::Instance().createUnmanaged(algName, version); + IAlgorithm_sptr alg = + AlgorithmManager::Instance().createUnmanaged(algName, version); alg->initialize(); if (boost::regex_search(input, what, propExp, boost::match_not_null)) { std::string _propStr = what[1]; @@ -1305,11 +1307,12 @@ bool Algorithm::processGroups() { outputBaseName += ws->name(); // Set the property using the name of that workspace - if (Property *prop = dynamic_cast(m_inputWorkspaceProps[iwp])) { + if (Property *prop = + dynamic_cast(m_inputWorkspaceProps[iwp])) { alg->setPropertyValue(prop->name(), ws->name()); } else { - throw std::logic_error( - "Found a Workspace property which doesn't inherit from Property."); + throw std::logic_error("Found a Workspace property which doesn't " + "inherit from Property."); } } // not an empty (i.e. optional) input } // for each InputWorkspace property diff --git a/Code/Mantid/Framework/API/src/BoxController.cpp b/Code/Mantid/Framework/API/src/BoxController.cpp index 766d992be19e..0a6334c5cc7b 100644 --- a/Code/Mantid/Framework/API/src/BoxController.cpp +++ b/Code/Mantid/Framework/API/src/BoxController.cpp @@ -36,8 +36,11 @@ BoxController *BoxController::clone() const { /*Private Copy constructor used in cloning */ BoxController::BoxController(const BoxController &other) : nd(other.nd), m_maxId(other.m_maxId), - m_SplitThreshold(other.m_SplitThreshold), m_maxDepth(other.m_maxDepth), - m_splitInto(other.m_splitInto), m_splitTopInto(other.m_splitTopInto), m_numSplit(other.m_numSplit), + m_SplitThreshold(other.m_SplitThreshold), + m_significantEventsNumber(other.m_significantEventsNumber), + m_maxDepth(other.m_maxDepth), m_numEventsAtMax(other.m_numEventsAtMax), + m_splitInto(other.m_splitInto), m_splitTopInto(other.m_splitTopInto), + m_numSplit(other.m_numSplit), m_numTopSplit(other.m_numTopSplit), m_addingEvents_eventsPerTask(other.m_addingEvents_eventsPerTask), m_addingEvents_numTasksPerBlock(other.m_addingEvents_numTasksPerBlock), m_numMDBoxes(other.m_numMDBoxes), @@ -166,13 +169,10 @@ std::string BoxController::toXMLString() const { pBoxElement->appendChild(element); element = pDoc->createElement("SplitTopInto"); - if (m_splitTopInto) - { + if (m_splitTopInto) { vecStr = Kernel::Strings::join(this->m_splitTopInto.get().begin(), this->m_splitTopInto.get().end(), ","); - } - else - { + } else { vecStr = ""; } text = pDoc->createTextNode(vecStr); @@ -249,9 +249,11 @@ void BoxController::fromXMLString(const std::string &xml) { s = pBoxElement->getChildElement("SplitInto")->innerText(); this->m_splitInto = splitStringIntoVector(s); - // Need to make sure that we handle box controllers which did not have the SplitTopInto - // attribute - Poco::AutoPtr nodes = pBoxElement->getElementsByTagName("SplitTopInto"); + // Need to make sure that we handle box controllers which did not have the + // SplitTopInto + // attribute + Poco::AutoPtr nodes = + pBoxElement->getElementsByTagName("SplitTopInto"); if (nodes->length() > 0) { s = pBoxElement->getChildElement("SplitTopInto")->innerText(); if (s.empty()) { diff --git a/Code/Mantid/Framework/API/src/CompositeFunction.cpp b/Code/Mantid/Framework/API/src/CompositeFunction.cpp index 792a4f8c19e4..98ef89edd11f 100644 --- a/Code/Mantid/Framework/API/src/CompositeFunction.cpp +++ b/Code/Mantid/Framework/API/src/CompositeFunction.cpp @@ -27,7 +27,7 @@ using std::size_t; DECLARE_FUNCTION(CompositeFunction) /// Default constructor -CompositeFunction::CompositeFunction() : IFunction(), m_nParams(0) { +CompositeFunction::CompositeFunction() : IFunction(), m_nParams(0), m_iConstraintFunction(false) { declareAttribute("NumDeriv", Attribute(false)); } diff --git a/Code/Mantid/Framework/API/src/IPowderDiffPeakFunction.cpp b/Code/Mantid/Framework/API/src/IPowderDiffPeakFunction.cpp index f230bf331106..f619b56a0a72 100644 --- a/Code/Mantid/Framework/API/src/IPowderDiffPeakFunction.cpp +++ b/Code/Mantid/Framework/API/src/IPowderDiffPeakFunction.cpp @@ -21,7 +21,10 @@ int IPowderDiffPeakFunction::s_peakRadius = 5; * property */ IPowderDiffPeakFunction::IPowderDiffPeakFunction() - : LATTICEINDEX(9999), HEIGHTINDEX(9999) { + : m_centre(0.), m_dcentre(0.), m_fwhm(0.), m_hasNewParameterValue(false), + m_cellParamValueChanged(false), m_sortedProfileParameterNames(), + m_unitCell(), m_unitCellSize(0.), m_parameterValid(false), mH(0), mK(0), + mL(0), mHKLSet(false), LATTICEINDEX(9999), HEIGHTINDEX(9999) { // Set peak's radius from configuration int peakRadius; if (Kernel::ConfigService::Instance().getValue("curvefitting.peakRadius", diff --git a/Code/Mantid/Framework/Algorithms/src/RemoveLowResTOF.cpp b/Code/Mantid/Framework/Algorithms/src/RemoveLowResTOF.cpp index 4c9afb0951dd..621db894fb1f 100644 --- a/Code/Mantid/Framework/Algorithms/src/RemoveLowResTOF.cpp +++ b/Code/Mantid/Framework/Algorithms/src/RemoveLowResTOF.cpp @@ -27,7 +27,7 @@ DECLARE_ALGORITHM(RemoveLowResTOF) RemoveLowResTOF::RemoveLowResTOF() : m_inputWS(), m_inputEvWS(), m_DIFCref(0.), m_K(0.), m_instrument(), m_sample(), m_L1(0.), m_Tmin(0.), m_wavelengthMin(0.), - m_numberOfSpectra(0), m_outputLowResTOF(false), m_progress(NULL) {} + m_numberOfSpectra(0), m_progress(NULL), m_outputLowResTOF(false) {} /// Destructor RemoveLowResTOF::~RemoveLowResTOF() { delete m_progress; }