From be7d5ee2e0f72e982ed82110a9ab54e9783eaad6 Mon Sep 17 00:00:00 2001
From: Federico Montesino Pouzols <federico.montesino-pouzols@stfc.ac.uk>
Date: Sun, 24 May 2015 17:39:03 +0100
Subject: [PATCH] fix uninit coverity issue in MD algs, (1075339...1075352), re
 #11829

---
 .../LiveData/src/ISISHistoDataListener.cpp    |  1 +
 .../inc/MantidMDAlgorithms/LoadMD.h           |  2 +-
 .../Framework/MDAlgorithms/src/BinMD.cpp      | 19 ++++++++++++-------
 .../MDAlgorithms/src/CompareMDWorkspaces.cpp  |  4 +++-
 .../src/ConvertToDetectorFaceMD.cpp           |  3 ++-
 .../MDAlgorithms/src/FindPeaksMD.cpp          |  4 +++-
 .../Framework/MDAlgorithms/src/LoadMD.cpp     | 11 ++++++-----
 .../MDAlgorithms/src/MergeMDFiles.cpp         |  7 +++++--
 .../src/PreprocessDetectorsToMD.cpp           |  4 +++-
 .../src/AlignAndFocusPowder.cpp               |  8 ++++----
 10 files changed, 40 insertions(+), 23 deletions(-)

diff --git a/Code/Mantid/Framework/LiveData/src/ISISHistoDataListener.cpp b/Code/Mantid/Framework/LiveData/src/ISISHistoDataListener.cpp
index 6912032a4f9..04ba83844bf 100644
--- a/Code/Mantid/Framework/LiveData/src/ISISHistoDataListener.cpp
+++ b/Code/Mantid/Framework/LiveData/src/ISISHistoDataListener.cpp
@@ -45,6 +45,7 @@ Kernel::Logger g_log("ISISHistoDataListener");
 /// Constructor
 ISISHistoDataListener::ISISHistoDataListener()
     : ILiveListener(), isInitilized(false), m_daeHandle(NULL),
+      m_numberOfPeriods(0), m_totalNumberOfSpectra(0),
       m_timeRegime(-1) {
   declareProperty(new Kernel::ArrayProperty<specid_t>("SpectraList"),
                   "An optional list of spectra to load. If blank, all "
diff --git a/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LoadMD.h b/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LoadMD.h
index 7287b626028..488f0dfce2f 100644
--- a/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LoadMD.h
+++ b/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LoadMD.h
@@ -103,7 +103,7 @@ private:
   bool m_BoxStructureAndMethadata;
 
   /// Version of SaveMD used to save the file
-  int SaveMDVersion ;
+  int m_saveMDVersion ;
 };
 
 } // namespace DataObjects
diff --git a/Code/Mantid/Framework/MDAlgorithms/src/BinMD.cpp b/Code/Mantid/Framework/MDAlgorithms/src/BinMD.cpp
index 051cfa50c9f..a43b3483d09 100644
--- a/Code/Mantid/Framework/MDAlgorithms/src/BinMD.cpp
+++ b/Code/Mantid/Framework/MDAlgorithms/src/BinMD.cpp
@@ -34,7 +34,9 @@ using namespace Mantid::DataObjects;
 //----------------------------------------------------------------------------------------------
 /** Constructor
  */
-BinMD::BinMD() {}
+BinMD::BinMD()
+    : outWS(), prog(NULL), implicitFunction(NULL), indexMultiplier(NULL),
+      signals(NULL), errors(NULL), numEvents(NULL) {}
 
 //----------------------------------------------------------------------------------------------
 /** Destructor
@@ -409,14 +411,17 @@ void BinMD::exec() {
   }
 
   /*
-  We should fail noisily here. CALL_MDEVENT_FUNCTION will silently allow IMDHistoWorkspaces to cascade through to the end
-  and result in an empty output. The only way we allow InputWorkspaces to be IMDHistoWorkspaces is if they also happen to contain original workspaces
+  We should fail noisily here. CALL_MDEVENT_FUNCTION will silently allow
+  IMDHistoWorkspaces to cascade through to the end
+  and result in an empty output. The only way we allow InputWorkspaces to be
+  IMDHistoWorkspaces is if they also happen to contain original workspaces
   that are MDEventWorkspaces.
   */
-  if(boost::dynamic_pointer_cast<IMDHistoWorkspace>(m_inWS))
-  {
-      throw std::runtime_error("Cannot rebin a workspace that is histogrammed and has no original workspace that is an MDEventWorkspace. "
-                               "Reprocess the input so that it contains full MDEvents.");
+  if (boost::dynamic_pointer_cast<IMDHistoWorkspace>(m_inWS)) {
+    throw std::runtime_error(
+        "Cannot rebin a workspace that is histogrammed and has no original "
+        "workspace that is an MDEventWorkspace. "
+        "Reprocess the input so that it contains full MDEvents.");
   }
 
   CALL_MDEVENT_FUNCTION(this->binByIterating, m_inWS);
diff --git a/Code/Mantid/Framework/MDAlgorithms/src/CompareMDWorkspaces.cpp b/Code/Mantid/Framework/MDAlgorithms/src/CompareMDWorkspaces.cpp
index 7eb692273ab..6387f94d4ad 100644
--- a/Code/Mantid/Framework/MDAlgorithms/src/CompareMDWorkspaces.cpp
+++ b/Code/Mantid/Framework/MDAlgorithms/src/CompareMDWorkspaces.cpp
@@ -32,7 +32,9 @@ DECLARE_ALGORITHM(CompareMDWorkspaces)
 //----------------------------------------------------------------------------------------------
 /** Constructor
 */
-CompareMDWorkspaces::CompareMDWorkspaces() {}
+CompareMDWorkspaces::CompareMDWorkspaces()
+    : inWS2(), m_result(), m_tolerance(0.0), m_CheckEvents(true),
+      m_CompareBoxID(true) {}
 
 //----------------------------------------------------------------------------------------------
 /** Destructor
diff --git a/Code/Mantid/Framework/MDAlgorithms/src/ConvertToDetectorFaceMD.cpp b/Code/Mantid/Framework/MDAlgorithms/src/ConvertToDetectorFaceMD.cpp
index 293bfe9ae06..2d58e4c5fba 100644
--- a/Code/Mantid/Framework/MDAlgorithms/src/ConvertToDetectorFaceMD.cpp
+++ b/Code/Mantid/Framework/MDAlgorithms/src/ConvertToDetectorFaceMD.cpp
@@ -26,7 +26,8 @@ DECLARE_ALGORITHM(ConvertToDetectorFaceMD)
 /** Constructor
  */
 ConvertToDetectorFaceMD::ConvertToDetectorFaceMD()
-    : m_numXPixels(0), m_numYPixels(0) {}
+    : in_ws(), m_numXPixels(0), m_numYPixels(0), m_detID_to_WI(),
+      m_detID_to_WI_offset(0) {}
 
 //----------------------------------------------------------------------------------------------
 /** Destructor
diff --git a/Code/Mantid/Framework/MDAlgorithms/src/FindPeaksMD.cpp b/Code/Mantid/Framework/MDAlgorithms/src/FindPeaksMD.cpp
index 68d4f01eba2..8d70251479e 100644
--- a/Code/Mantid/Framework/MDAlgorithms/src/FindPeaksMD.cpp
+++ b/Code/Mantid/Framework/MDAlgorithms/src/FindPeaksMD.cpp
@@ -106,7 +106,9 @@ DECLARE_ALGORITHM(FindPeaksMD)
 /** Constructor
  */
 FindPeaksMD::FindPeaksMD()
-    : m_addDetectors(true), m_densityScaleFactor(1e-6), prog(NULL) {}
+: peakWS(), peakRadiusSquared(), DensityThresholdFactor(0.0), MaxPeaks(0),
+  m_addDetectors(true), m_densityScaleFactor(1e-6), prog(NULL), inst(),
+  runNumber(-1), dimType(), goniometer() {}
 
 //----------------------------------------------------------------------------------------------
 /** Destructor
diff --git a/Code/Mantid/Framework/MDAlgorithms/src/LoadMD.cpp b/Code/Mantid/Framework/MDAlgorithms/src/LoadMD.cpp
index 3b33597fc7f..819e600a812 100644
--- a/Code/Mantid/Framework/MDAlgorithms/src/LoadMD.cpp
+++ b/Code/Mantid/Framework/MDAlgorithms/src/LoadMD.cpp
@@ -42,7 +42,8 @@ DECLARE_NEXUS_FILELOADER_ALGORITHM(LoadMD)
 LoadMD::LoadMD()
     : m_numDims(0), // uninitialized incorrect value
       m_coordSystem(None),
-      m_BoxStructureAndMethadata(true) // this is faster but rarely needed.
+      m_BoxStructureAndMethadata(true), // this is faster but rarely needed.
+      m_saveMDVersion(false)
 {}
 
 //----------------------------------------------------------------------------------------------
@@ -159,11 +160,11 @@ void LoadMD::exec() {
   m_file->openGroup(entryName, "NXentry");
 
   // Check is SaveMD version 2 was used
-  SaveMDVersion = 0;
+  m_saveMDVersion = 0;
   if (m_file->hasAttr("SaveMDVersion"))
-    m_file->getAttr("SaveMDVersion", SaveMDVersion);
+    m_file->getAttr("SaveMDVersion", m_saveMDVersion);
 
-  if (SaveMDVersion == 2)
+  if (m_saveMDVersion == 2)
     this->loadDimensions2();
   else {
     // How many dimensions?
@@ -261,7 +262,7 @@ void LoadMD::loadHisto() {
 
   this->loadAffineMatricies(boost::dynamic_pointer_cast<IMDWorkspace>(ws));
 
-  if (SaveMDVersion == 2 )
+  if (m_saveMDVersion == 2 )
     m_file->openGroup("data","NXdata");
   // Load each data slab
   this->loadSlab("signal", ws->getSignalArray(), ws, ::NeXus::FLOAT64);
diff --git a/Code/Mantid/Framework/MDAlgorithms/src/MergeMDFiles.cpp b/Code/Mantid/Framework/MDAlgorithms/src/MergeMDFiles.cpp
index 03f3afd4a05..5acf128290e 100644
--- a/Code/Mantid/Framework/MDAlgorithms/src/MergeMDFiles.cpp
+++ b/Code/Mantid/Framework/MDAlgorithms/src/MergeMDFiles.cpp
@@ -25,7 +25,10 @@ DECLARE_ALGORITHM(MergeMDFiles)
 //----------------------------------------------------------------------------------------------
 /** Constructor
  */
-MergeMDFiles::MergeMDFiles() {}
+MergeMDFiles::MergeMDFiles()
+    : m_nDims(0), m_MDEventType(), m_fileBasedTargetWS(false), m_Filenames(),
+      m_EventLoader(), m_OutIWS(), totalEvents(0), totalLoaded(0), fileMutex(),
+      statsMutex(), prog(NULL) {}
 
 //----------------------------------------------------------------------------------------------
 /** Destructor
@@ -315,7 +318,7 @@ void MergeMDFiles::finalizeOutput(const std::string &outputFile) {
     // its dimensions
     bool old_data_there;
     // clang-format off
-    boost::scoped_ptr< ::NeXus::File> file(MDBoxFlatTree::createOrOpenMDWSgroup(
+    boost::scoped_ptr<::NeXus::File> file(MDBoxFlatTree::createOrOpenMDWSgroup(
         outputFile, m_nDims, m_MDEventType, false, old_data_there));
     // clang-format on
     this->progress(0.94, "Saving ws history and dimensions");
diff --git a/Code/Mantid/Framework/MDAlgorithms/src/PreprocessDetectorsToMD.cpp b/Code/Mantid/Framework/MDAlgorithms/src/PreprocessDetectorsToMD.cpp
index f705eaaab27..837827c91fa 100644
--- a/Code/Mantid/Framework/MDAlgorithms/src/PreprocessDetectorsToMD.cpp
+++ b/Code/Mantid/Framework/MDAlgorithms/src/PreprocessDetectorsToMD.cpp
@@ -12,7 +12,9 @@ namespace MDAlgorithms {
 // Register the algorithm into the AlgorithmFactory
 DECLARE_ALGORITHM(PreprocessDetectorsToMD)
 
-PreprocessDetectorsToMD::PreprocessDetectorsToMD(){}
+PreprocessDetectorsToMD::PreprocessDetectorsToMD()
+    : m_getEFixed(false), m_getIsMasked(false) {}
+
 //----------------------------------------------------------------------------------------------
 /** Initialize the algorithm's properties. */
 void PreprocessDetectorsToMD::init() {
diff --git a/Code/Mantid/Framework/WorkflowAlgorithms/src/AlignAndFocusPowder.cpp b/Code/Mantid/Framework/WorkflowAlgorithms/src/AlignAndFocusPowder.cpp
index dd00c633272..b7ad3f6b09f 100644
--- a/Code/Mantid/Framework/WorkflowAlgorithms/src/AlignAndFocusPowder.cpp
+++ b/Code/Mantid/Framework/WorkflowAlgorithms/src/AlignAndFocusPowder.cpp
@@ -36,10 +36,10 @@ using API::FileProperty;
 DECLARE_ALGORITHM(AlignAndFocusPowder)
 
 AlignAndFocusPowder::AlignAndFocusPowder()
-    : API::Algorithm(), m_progress(NULL), m_l1(0.0), m_resampleX(0),
-      dspace(false), xmin(0.0), xmax(0.0), LRef(0.0), DIFCref(0.0), minwl(0.0),
-      tmin(0.0), tmax(0.0), m_preserveEvents(false), m_processLowResTOF(false),
-      m_lowResSpecOffset(0) {}
+    : API::Algorithm(), m_l1(0.0), m_resampleX(0), dspace(false), xmin(0.0),
+      xmax(0.0), LRef(0.0), DIFCref(0.0), minwl(0.0), tmin(0.0), tmax(0.0),
+      m_preserveEvents(false), m_processLowResTOF(false), m_lowResSpecOffset(0),
+      m_progress(NULL) {}
 
 AlignAndFocusPowder::~AlignAndFocusPowder() {
   if (m_progress)
-- 
GitLab