Skip to content

Commit

Permalink
fix uninit coverity issues in Kernel::Unit, 1075357-1075365, re #11829
Browse files Browse the repository at this point in the history
  • Loading branch information
FedeMPouzols committed May 26, 2015
1 parent 6efe910 commit 1a8942b
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions Code/Mantid/Framework/Kernel/src/Unit.cpp
Expand Up @@ -317,7 +317,9 @@ double TOF::conversionTOFMax() const { return DBL_MAX; }
*/
DECLARE_UNIT(Wavelength)

Wavelength::Wavelength() : Unit() {
Wavelength::Wavelength()
: Unit(), sfpTo(DBL_MIN), factorTo(DBL_MIN), sfpFrom(DBL_MIN),
factorFrom(DBL_MIN), do_sfpFrom(false) {
const double AngstromsSquared = 1e20;
const double factor =
(AngstromsSquared * PhysicalConstants::h * PhysicalConstants::h) /
Expand Down Expand Up @@ -442,7 +444,7 @@ DECLARE_UNIT(Energy)
const UnitLabel Energy::label() const { return Symbol::MilliElectronVolts; }

/// Constructor
Energy::Energy() : Unit() {
Energy::Energy() : Unit(), factorTo(DBL_MIN), factorFrom(DBL_MIN) {
addConversion("Energy_inWavenumber", PhysicalConstants::meVtoWavenumber);
const double toAngstroms = 1e10;
const double factor =
Expand Down Expand Up @@ -498,7 +500,8 @@ DECLARE_UNIT(Energy_inWavenumber)
const UnitLabel Energy_inWavenumber::label() const { return Symbol::InverseCM; }

/// Constructor
Energy_inWavenumber::Energy_inWavenumber() : Unit() {
Energy_inWavenumber::Energy_inWavenumber()
: Unit(), factorTo(DBL_MIN), factorFrom(DBL_MIN) {
addConversion("Energy", 1.0 / PhysicalConstants::meVtoWavenumber);
const double toAngstroms = 1e10;
const double factor =
Expand Down Expand Up @@ -565,7 +568,7 @@ DECLARE_UNIT(dSpacing)

const UnitLabel dSpacing::label() const { return Symbol::Angstrom; }

dSpacing::dSpacing() : Unit() {
dSpacing::dSpacing() : Unit(), factorTo(DBL_MIN), factorFrom(DBL_MIN) {
const double factor = 2.0 * M_PI;
addConversion("MomentumTransfer", factor, -1.0);
addConversion("QSquared", (factor * factor), -2.0);
Expand Down Expand Up @@ -607,7 +610,8 @@ const UnitLabel MomentumTransfer::label() const {
return Symbol::InverseAngstrom;
}

MomentumTransfer::MomentumTransfer() : Unit() {
MomentumTransfer::MomentumTransfer()
: Unit(), factorTo(DBL_MIN), factorFrom(DBL_MIN) {
addConversion("QSquared", 1.0, 2.0);
const double factor = 2.0 * M_PI;
addConversion("dSpacing", factor, -1.0);
Expand Down Expand Up @@ -660,7 +664,7 @@ DECLARE_UNIT(QSquared)

const UnitLabel QSquared::label() const { return Symbol::InverseAngstromSq; }

QSquared::QSquared() : Unit() {
QSquared::QSquared() : Unit(), factorTo(DBL_MIN), factorFrom(DBL_MIN) {
addConversion("MomentumTransfer", 1.0, 0.5);
const double factor = 2.0 * M_PI;
addConversion("dSpacing", factor, -0.5);
Expand Down Expand Up @@ -721,6 +725,12 @@ DECLARE_UNIT(DeltaE)

const UnitLabel DeltaE::label() const { return Symbol::MilliElectronVolts; }

DeltaE::DeltaE()
: Unit(), factorTo(DBL_MIN), factorFrom(DBL_MIN), t_other(DBL_MIN),
t_otherFrom(DBL_MIN), unitScaling(DBL_MIN) {
addConversion("DeltaE_inWavenumber", PhysicalConstants::meVtoWavenumber, 1.);
}

void DeltaE::init() {
// Efixed must be set to something
if (efixed == 0.0)
Expand Down Expand Up @@ -829,10 +839,6 @@ double DeltaE::conversionTOFMax() const {

Unit *DeltaE::clone() const { return new DeltaE(*this); }

DeltaE::DeltaE() : Unit() {
addConversion("DeltaE_inWavenumber", PhysicalConstants::meVtoWavenumber, 1.);
}

// =====================================================================================================
/* Energy Transfer in units of wavenumber
* =====================================================================================================
Expand Down Expand Up @@ -874,7 +880,9 @@ DECLARE_UNIT(Momentum)

const UnitLabel Momentum::label() const { return Symbol::InverseAngstrom; }

Momentum::Momentum() : Unit() {
Momentum::Momentum()
: Unit(), sfpTo(DBL_MIN), factorTo(DBL_MIN), sfpFrom(DBL_MIN),
factorFrom(DBL_MIN), do_sfpFrom(false) {

const double AngstromsSquared = 1e20;
const double factor =
Expand Down Expand Up @@ -1089,7 +1097,7 @@ DECLARE_UNIT(Time)

const UnitLabel Time::label() const { return Symbol::Second; }

Time::Time() : Unit() {}
Time::Time() : Unit(), factorTo(DBL_MIN), factorFrom(DBL_MIN) {}

void Time::init() {}

Expand Down

0 comments on commit 1a8942b

Please sign in to comment.