Skip to content

Commit

Permalink
newer coverity issues in framework, up to 1127165, re #11829
Browse files Browse the repository at this point in the history
  • Loading branch information
FedeMPouzols committed May 28, 2015
1 parent f397c92 commit 2fa2270
Show file tree
Hide file tree
Showing 17 changed files with 101 additions and 81 deletions.
Expand Up @@ -116,11 +116,7 @@ class DLLExport SphericalAbsorption : public API::Algorithm {
int64_t x_step; ///< The step in bin number between adjacent points
int64_t m_emode; ///< The energy mode: 0 - elastic, 1 - direct, 2 - indirect
double m_lambdaFixed; ///< The wavelength corresponding to the fixed energy,
/// if provided

typedef double (*expfunction)(
double); ///< Typedef pointer to exponential function
expfunction EXPONENTIAL; ///< Pointer to exponential function
/// if provided
};

} // namespace Algorithms
Expand Down
Expand Up @@ -276,7 +276,11 @@ ChopperConfiguration::parseStringUnsignedInt(const string &instring) const {
//----------------------------------------------------------------------------------------------
/** Constructor
*/
SaveGSASInstrumentFile::SaveGSASInstrumentFile() {}
SaveGSASInstrumentFile::SaveGSASInstrumentFile()
: API::Algorithm(), m_instrument(), m_L1(0.), m_L2(0.), m_2theta(0.),
m_frequency(0), m_id_line(), m_sample(), m_vecBankID2File(),
m_gsasFileName(), m_configuration(), m_profileMap(), m_gdsp(), m_gdt(),
m_galpha(), m_gbeta(), m_bank_mndsp(), m_bank_mxtof() {}

//----------------------------------------------------------------------------------------------
/** Destructor
Expand Down
5 changes: 4 additions & 1 deletion Code/Mantid/Framework/Algorithms/src/SmoothNeighbours.cpp
Expand Up @@ -36,7 +36,10 @@ const std::string SmoothNeighbours::RECTANGULAR_GROUP = "Rectangular Detectors";
const std::string SmoothNeighbours::INPUT_WORKSPACE = "InputWorkspace";

SmoothNeighbours::SmoothNeighbours()
: API::Algorithm(), WeightedSum(new NullWeighting) {}
: API::Algorithm(), AdjX(0), AdjY(0), Edge(0), Radius(0.), nNeighbours(0),
WeightedSum(new NullWeighting), PreserveEvents(false),
expandSumAllPixels(false), outWI(0), inWS(), m_neighbours(),
m_prog(NULL) {}

/** Initialisation method.
*
Expand Down
5 changes: 4 additions & 1 deletion Code/Mantid/Framework/Algorithms/src/SphericalAbsorption.cpp
Expand Up @@ -25,7 +25,10 @@ using namespace API;
using namespace DataObjects;

SphericalAbsorption::SphericalAbsorption()
: API::Algorithm(), m_inputWS(), m_refAtten(0.0), m_scattering(0) {}
: API::Algorithm(), m_inputWS(), m_sampleObject(NULL), m_beamDirection(),
m_L1s(), m_elementVolumes(), m_elementPositions(), m_numVolumeElements(0),
m_sampleVolume(0.), m_refAtten(0.0), m_scattering(0.), n_lambda(0),
x_step(0), m_emode(0), m_lambdaFixed(0.) {}

void SphericalAbsorption::init() {
// The input workspace must have an instrument and units of wavelength
Expand Down
53 changes: 28 additions & 25 deletions Code/Mantid/Framework/Algorithms/src/StripPeaks.cpp
Expand Up @@ -14,7 +14,7 @@ DECLARE_ALGORITHM(StripPeaks)
using namespace Kernel;
using namespace API;

StripPeaks::StripPeaks() : API::Algorithm() {}
StripPeaks::StripPeaks() : API::Algorithm(), m_maxChiSq(0.) {}

void StripPeaks::init() {
declareProperty(
Expand Down Expand Up @@ -110,7 +110,7 @@ API::ITableWorkspace_sptr StripPeaks::findPeaks(API::MatrixWorkspace_sptr WS) {
std::vector<double> peakpositions = getProperty("PeakPositions");
double peakpostol = getProperty("PeakPositionTolerance");
if (peakpostol < 0.)
peakpostol = EMPTY_DBL();
peakpostol = EMPTY_DBL();

// Set up and execute algorithm
bool showlog = true;
Expand Down Expand Up @@ -216,36 +216,39 @@ StripPeaks::removePeaks(API::MatrixWorkspace_const_sptr input,
<< " denoted by chi^2 = " << chisq << " <= 0. \n";
}
{
auto left = lower_bound(X.begin(), X.end(), centre);
double delta_d = (*left) - (*(left-1));
if ((width/delta_d) < 1.) {
g_log.warning() << "StripPeaks(): Peak Index = " << i
<< " @ X = " << centre
<< " Error: Peak fit with too narrow of peak "
<< "delta_d = " << delta_d
<< " sigma/delta_d = " << (width/delta_d) << "\n";
continue;
}
auto left = lower_bound(X.begin(), X.end(), centre);
double delta_d = (*left) - (*(left - 1));
if ((width / delta_d) < 1.) {
g_log.warning() << "StripPeaks(): Peak Index = " << i
<< " @ X = " << centre
<< " Error: Peak fit with too narrow of peak "
<< "delta_d = " << delta_d
<< " sigma/delta_d = " << (width / delta_d) << "\n";
continue;
}
}

g_log.information() << "Subtracting peak " << i << " from spectrum "
<< peakslist->getRef<int>("spectrum", i)
<< " at x = " << centre << " h = " << height
<< " s = " << width << " chi2 = " << chisq << "\n";

{ // log the background function
double a0 = 0.;
double a1 = 0.;
double a2 = 0.;
const std::vector<std::string> columnNames = peakslist->getColumnNames();
if (std::find(columnNames.begin(), columnNames.end(), "A0") != columnNames.end())
a0 = peakslist->getRef<double>("A0", i);
if (std::find(columnNames.begin(), columnNames.end(), "A1") != columnNames.end())
a1 = peakslist->getRef<double>("A1", i);
if (std::find(columnNames.begin(), columnNames.end(), "A2") != columnNames.end())
a2 = peakslist->getRef<double>("A2", i);
g_log.information() << " background = " << a0 << " + "
<< a1 << " x + " << a2 << " x^2\n";
{ // log the background function
double a0 = 0.;
double a1 = 0.;
double a2 = 0.;
const std::vector<std::string> columnNames = peakslist->getColumnNames();
if (std::find(columnNames.begin(), columnNames.end(), "A0") !=
columnNames.end())
a0 = peakslist->getRef<double>("A0", i);
if (std::find(columnNames.begin(), columnNames.end(), "A1") !=
columnNames.end())
a1 = peakslist->getRef<double>("A1", i);
if (std::find(columnNames.begin(), columnNames.end(), "A2") !=
columnNames.end())
a2 = peakslist->getRef<double>("A2", i);
g_log.information() << " background = " << a0 << " + " << a1
<< " x + " << a2 << " x^2\n";
}

// Loop over the spectrum elements
Expand Down
4 changes: 3 additions & 1 deletion Code/Mantid/Framework/Algorithms/src/UnwrapMonitor.cpp
Expand Up @@ -16,7 +16,9 @@ using namespace Kernel;
using namespace API;

/// Default constructor
UnwrapMonitor::UnwrapMonitor() : m_progress(NULL) {}
UnwrapMonitor::UnwrapMonitor()
: m_conversionConstant(0.), m_inputWS(), m_LRef(0.), m_Tmin(0.), m_Tmax(0.),
m_XSize(0), m_progress(NULL) {}

/// Destructor
UnwrapMonitor::~UnwrapMonitor() {
Expand Down
4 changes: 3 additions & 1 deletion Code/Mantid/Framework/Algorithms/src/UnwrapSNS.cpp
Expand Up @@ -23,7 +23,9 @@ using Kernel::Exception::NotFoundError;
using std::size_t;

/// Default constructor
UnwrapSNS::UnwrapSNS() : m_progress(NULL) {}
UnwrapSNS::UnwrapSNS()
: m_inputWS(), m_inputEvWS(), m_LRef(0.), m_L1(0.), m_Tmin(0.), m_Tmax(0.),
m_frameWidth(0.), m_numberOfSpectra(0), m_XSize(0), m_progress(NULL) {}

/// Destructor
UnwrapSNS::~UnwrapSNS() {
Expand Down
Expand Up @@ -136,8 +136,8 @@ class DLLExport AnvredCorrection : public API::Algorithm {
double m_radius; ///< sample radius in cm
double m_power_th; ///< Power of lamda in BuildLamdaWeights
std::vector<double> m_lamda_weight; ///< lmabda weights
bool m_OnlySphericalAbsorption;
bool m_ReturnTransmissionOnly;
bool m_onlySphericalAbsorption;
bool m_returnTransmissionOnly;
bool m_useScaleFactors;
};

Expand Down
28 changes: 14 additions & 14 deletions Code/Mantid/Framework/Crystal/src/AnvredCorrection.cpp
Expand Up @@ -72,8 +72,8 @@ std::map<int, double> detScale = map_list_of(17, 1.092114823)(18, 0.869105443)(

AnvredCorrection::AnvredCorrection()
: API::Algorithm(), m_smu(0.), m_amu(0.), m_radius(0.), m_power_th(0.),
m_lamda_weight(), m_OnlySphericalAbsorption(false),
m_ReturnTransmissionOnly(false), m_useScaleFactors(false) {}
m_lamda_weight(), m_onlySphericalAbsorption(false),
m_returnTransmissionOnly(false), m_useScaleFactors(false) {}

void AnvredCorrection::init() {

Expand Down Expand Up @@ -105,10 +105,10 @@ void AnvredCorrection::init() {
"input has events (default).\n"
"If false, then the workspace gets converted to a "
"Workspace2D histogram.");
declareProperty("m_OnlySphericalAbsorption", false,
declareProperty("OnlySphericalAbsorption", false,
"All corrections done if false (default).\n"
"If true, only the spherical absorption correction.");
declareProperty("m_ReturnTransmissionOnly", false,
declareProperty("ReturnTransmissionOnly", false,
"Corrections applied to data if false (default).\n"
"If true, only return the transmission coefficient.");
declareProperty("PowerLambda", 4.0, "Power of lamda ");
Expand All @@ -122,19 +122,19 @@ void AnvredCorrection::init() {
void AnvredCorrection::exec() {
// Retrieve the input workspace
m_inputWS = getProperty("InputWorkspace");
m_OnlySphericalAbsorption = getProperty("m_OnlySphericalAbsorption");
m_ReturnTransmissionOnly = getProperty("m_ReturnTransmissionOnly");
m_onlySphericalAbsorption = getProperty("OnlySphericalAbsorption");
m_returnTransmissionOnly = getProperty("ReturnTransmissionOnly");
m_useScaleFactors = getProperty("DetectorBankScaleFactors");
if (!m_OnlySphericalAbsorption) {
if (!m_onlySphericalAbsorption) {
const API::Run &run = m_inputWS->run();
if (run.hasProperty("LorentzCorrection")) {
Kernel::Property *prop = run.getProperty("LorentzCorrection");
bool lorentzDone = boost::lexical_cast<bool, std::string>(prop->value());
if (lorentzDone) {
m_OnlySphericalAbsorption = true;
m_onlySphericalAbsorption = true;
g_log.warning()
<< "Lorentz Correction was already done for this "
"workspace. m_OnlySphericalAbsorption was changed to "
"workspace. OnlySphericalAbsorption was changed to "
"true." << std::endl;
}
}
Expand All @@ -151,7 +151,7 @@ void AnvredCorrection::exec() {
if (eventW)
eventW->sortAll(TOF_SORT, NULL);
if ((getProperty("PreserveEvents")) && (eventW != NULL) &&
!m_ReturnTransmissionOnly) {
!m_returnTransmissionOnly) {
// Input workspace is an event workspace. Use the other exec method
this->execEvent();
this->cleanup();
Expand Down Expand Up @@ -233,7 +233,7 @@ void AnvredCorrection::exec() {
double lambda = timeflight[0];
timeflight.clear();

if (m_ReturnTransmissionOnly) {
if (m_returnTransmissionOnly) {
Y[j] = 1.0 / this->getEventWeight(lambda, scattering);
} else {
double value = this->getEventWeight(lambda, scattering);
Expand All @@ -255,7 +255,7 @@ void AnvredCorrection::exec() {
// set the absorption correction values in the run parameters
API::Run &run = correctionFactors->mutableRun();
run.addProperty<double>("Radius", m_radius, true);
if (!m_OnlySphericalAbsorption && !m_ReturnTransmissionOnly)
if (!m_onlySphericalAbsorption && !m_returnTransmissionOnly)
run.addProperty<bool>("LorentzCorrection", 1, true);
setProperty("OutputWorkspace", correctionFactors);
}
Expand Down Expand Up @@ -372,7 +372,7 @@ void AnvredCorrection::execEvent() {
// set the absorption correction values in the run parameters
API::Run &run = correctionFactors->mutableRun();
run.addProperty<double>("Radius", m_radius, true);
if (!m_OnlySphericalAbsorption && !m_ReturnTransmissionOnly)
if (!m_onlySphericalAbsorption && !m_returnTransmissionOnly)
run.addProperty<bool>("LorentzCorrection", 1, true);
setProperty("OutputWorkspace",
boost::dynamic_pointer_cast<MatrixWorkspace>(correctionFactors));
Expand Down Expand Up @@ -429,7 +429,7 @@ double AnvredCorrection::getEventWeight(double lamda, double two_theta) {
if (m_radius > 0)
transinv = absor_sphere(two_theta, lamda);
// Only Spherical absorption correction
if (m_OnlySphericalAbsorption || m_ReturnTransmissionOnly)
if (m_onlySphericalAbsorption || m_returnTransmissionOnly)
return transinv;

// Resolution of the lambda table
Expand Down
Expand Up @@ -27,7 +27,11 @@ DECLARE_FUNCTION(NeutronBk2BkExpConvPVoigt)
//----------------------------------------------------------------------------------------------
/** Constructor
*/
NeutronBk2BkExpConvPVoigt::NeutronBk2BkExpConvPVoigt() { mHKLSet = false; }
NeutronBk2BkExpConvPVoigt::NeutronBk2BkExpConvPVoigt()
: API::IPowderDiffPeakFunction(), m_Alpha(), m_Beta(), m_Sigma2(),
m_Gamma(), m_eta(), m_N() {
mHKLSet = false;
}

//----------------------------------------------------------------------------------------------
/** Destructor
Expand Down
Expand Up @@ -240,7 +240,9 @@ class DetParameters {
/// the detector's ID
int64_t detID;
// default detector ID -- -1 means undefined
DetParameters() : detID(-1) {}
DetParameters()
: azimutAngle(0.), polarAngle(0.), secondaryFlightPath(0.), azimWidth(0.),
polarWidth(0.), detID(-1) {}
};

/** helper class-collection to keep together the parameters, which characterize
Expand Down
Expand Up @@ -21,7 +21,8 @@ using Kernel::Matrix;
/** Empty constructor
*/
RectangularDetector::RectangularDetector()
: CompAssembly(), IObjComponent(NULL), m_minDetId(0), m_maxDetId(0) {
: CompAssembly(), IObjComponent(NULL), m_rectBase(NULL), m_minDetId(0),
m_maxDetId(0) {

init();
setGeometryHandler(new BitmapGeometryHandler(this));
Expand Down Expand Up @@ -57,9 +58,7 @@ RectangularDetector::RectangularDetector(const std::string &n,
setGeometryHandler(new BitmapGeometryHandler(this));
}

void RectangularDetector::init()
{
m_rectBase = NULL;
void RectangularDetector::init() {
m_xpixels = m_ypixels = 0;
m_xsize = m_ysize = 0;
m_xstart = m_ystart = 0;
Expand Down
Expand Up @@ -94,8 +94,8 @@ struct TCPStreamEventHeaderSetup {
char inst_name[32]; ///< instrument name

TCPStreamEventHeaderSetup()
: length(sizeof(TCPStreamEventHeaderSetup)), start_time(0), run_number(0),
run_state(0) {
: ChangedFields(), length(sizeof(TCPStreamEventHeaderSetup)),
start_time(0), run_number(0), run_state(0) {
inst_name[0] = '\0';
}
bool isValid() const { return length >= sizeof(TCPStreamEventHeaderSetup); }
Expand Down Expand Up @@ -126,7 +126,8 @@ struct TCPStreamEventHeaderNeutron {
uint32_t nevents; ///< number of TCPStreamEvent() structures in this packet

TCPStreamEventHeaderNeutron()
: length(sizeof(TCPStreamEventHeaderNeutron)), nevents(0) {}
: length(sizeof(TCPStreamEventHeaderNeutron)), frame_number(0), period(0),
protons(0.), frame_time_zero(0.), nevents(0) {}
bool isValid() const { return length >= sizeof(TCPStreamEventHeaderNeutron); }
};

Expand Down
Expand Up @@ -94,8 +94,8 @@ struct TCPStreamEventHeaderSetup {
char inst_name[32]; ///< instrument name

TCPStreamEventHeaderSetup()
: length(sizeof(TCPStreamEventHeaderSetup)), start_time(0), run_number(0),
run_state(0) {
: ChangedFields(), length(sizeof(TCPStreamEventHeaderSetup)),
start_time(0), run_number(0), run_state(0) {
inst_name[0] = '\0';
}
bool isValid() const { return length >= sizeof(TCPStreamEventHeaderSetup); }
Expand Down
3 changes: 2 additions & 1 deletion Code/Mantid/Framework/LiveData/src/FileEventDataListener.cpp
Expand Up @@ -19,7 +19,8 @@ Kernel::Logger g_log("FileEventDataListener");

/// Constructor
FileEventDataListener::FileEventDataListener()
: ILiveListener(), m_tempWSname("__filelistenerchunk"), m_nextChunk(1),
: ILiveListener(), m_filename(), m_runNumber(-1),
m_tempWSname("__filelistenerchunk"), m_nextChunk(1),
m_filePropName("Filename"), m_loaderName(""), m_canLoadMonitors(true),
m_chunkload(NULL) {
std::string tfilename =
Expand Down
Expand Up @@ -73,7 +73,7 @@ class DLLExport FindPeaksMD : public API::Algorithm {
double DensityThresholdFactor;

/// Max # of peaks
int64_t MaxPeaks;
int64_t m_maxPeaks;

/// Flag to include the detectors within the peak
bool m_addDetectors;
Expand All @@ -91,11 +91,11 @@ class DLLExport FindPeaksMD : public API::Algorithm {
/// Instrument
Mantid::Geometry::Instrument_const_sptr inst;
/// Run number of the peaks
int runNumber;
int m_runNumber;
/// Dimension type
eDimensionType dimType;
/// Goniometer matrix
Mantid::Kernel::Matrix<double> goniometer;
Mantid::Kernel::Matrix<double> m_goniometer;
};

} // namespace Mantid
Expand Down

0 comments on commit 2fa2270

Please sign in to comment.