Skip to content

Commit

Permalink
fix coverity uninits issues in API, 1075490...1075499, re #11829
Browse files Browse the repository at this point in the history
  • Loading branch information
FedeMPouzols committed May 28, 2015
1 parent 7d1d4d5 commit 20865da
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 23 deletions.
9 changes: 5 additions & 4 deletions Code/Mantid/Framework/API/inc/MantidAPI/IFunction.h
Expand Up @@ -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<double> &v) : m_data(v) {}
explicit Attribute(const std::vector<double> &v)
: m_data(v), m_quoteValue(false) {}

/// Apply an attribute visitor
template <typename T> T apply(AttributeVisitor<T> &v) {
Expand Down
15 changes: 9 additions & 6 deletions Code/Mantid/Framework/API/src/Algorithm.cpp
Expand Up @@ -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() {
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -1305,11 +1307,12 @@ bool Algorithm::processGroups() {
outputBaseName += ws->name();

// Set the property using the name of that workspace
if (Property *prop = dynamic_cast<Property *>(m_inputWorkspaceProps[iwp])) {
if (Property *prop =
dynamic_cast<Property *>(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
Expand Down
22 changes: 12 additions & 10 deletions Code/Mantid/Framework/API/src/BoxController.cpp
Expand Up @@ -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),
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -249,9 +249,11 @@ void BoxController::fromXMLString(const std::string &xml) {
s = pBoxElement->getChildElement("SplitInto")->innerText();
this->m_splitInto = splitStringIntoVector<size_t>(s);

// Need to make sure that we handle box controllers which did not have the SplitTopInto
// attribute
Poco::AutoPtr<NodeList> nodes = pBoxElement->getElementsByTagName("SplitTopInto");
// Need to make sure that we handle box controllers which did not have the
// SplitTopInto
// attribute
Poco::AutoPtr<NodeList> nodes =
pBoxElement->getElementsByTagName("SplitTopInto");
if (nodes->length() > 0) {
s = pBoxElement->getChildElement("SplitTopInto")->innerText();
if (s.empty()) {
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/API/src/CompositeFunction.cpp
Expand Up @@ -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));
}

Expand Down
5 changes: 4 additions & 1 deletion Code/Mantid/Framework/API/src/IPowderDiffPeakFunction.cpp
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/Algorithms/src/RemoveLowResTOF.cpp
Expand Up @@ -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; }
Expand Down

0 comments on commit 20865da

Please sign in to comment.