From 8bce9d7332304c7a7741b296be5ff72340e85850 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Mon, 27 Feb 2012 18:14:43 +0000 Subject: [PATCH] Fixed compiler warnings revealed by MinGW --- include/cantera/base/mdp_allo.h | 4 ---- include/cantera/numerics/ResidEval.h | 5 ----- src/base/mdp_allo.cpp | 4 ---- src/base/misc.cpp | 3 +++ src/equil/MultiPhaseEquil.cpp | 2 +- src/equil/vcs_solve_TP.cpp | 5 ++--- src/equil/vcs_solve_phaseStability.cpp | 4 ---- src/kinetics/solveSP.cpp | 2 +- src/numerics/BandMatrix.cpp | 2 +- src/numerics/NonlinearSolver.cpp | 6 +++--- src/numerics/SquareMatrix.cpp | 6 +++--- src/thermo/MixtureFugacityTP.cpp | 9 ++------- src/thermo/RedlichKwongMFTP.cpp | 6 ------ 13 files changed, 16 insertions(+), 42 deletions(-) diff --git a/include/cantera/base/mdp_allo.h b/include/cantera/base/mdp_allo.h index fdffe1a76..33100cefe 100644 --- a/include/cantera/base/mdp_allo.h +++ b/include/cantera/base/mdp_allo.h @@ -18,10 +18,6 @@ #ifndef MDP_ALLO_H #define MDP_ALLO_H -#ifdef WIN32 -#pragma warning(disable:4290) -#endif - #include /* diff --git a/include/cantera/numerics/ResidEval.h b/include/cantera/numerics/ResidEval.h index a994a35f7..64f070d3a 100644 --- a/include/cantera/numerics/ResidEval.h +++ b/include/cantera/numerics/ResidEval.h @@ -11,11 +11,6 @@ #ifndef CT_RESIDEVAL_H #define CT_RESIDEVAL_H -#ifdef WIN32 -#pragma warning(disable:4786) -#pragma warning(disable:4503) -#endif - #include "cantera/base/ct_defs.h" #include "cantera/base/ctexceptions.h" diff --git a/src/base/mdp_allo.cpp b/src/base/mdp_allo.cpp index af74be129..a46d644f4 100644 --- a/src/base/mdp_allo.cpp +++ b/src/base/mdp_allo.cpp @@ -23,10 +23,6 @@ using namespace std; -#ifdef WIN32 -#pragma warning(disable:4996) -#endif - namespace mdp { /* diff --git a/src/base/misc.cpp b/src/base/misc.cpp index acaa4a984..f2017f4ef 100644 --- a/src/base/misc.cpp +++ b/src/base/misc.cpp @@ -1203,6 +1203,9 @@ long int Application::readStringRegistryKey(const std::string& keyName, const st HKEY key; long open_error = RegOpenKeyEx(HKEY_LOCAL_MACHINE, keyName.c_str(), 0, KEY_READ, &key); + if (open_error != ERROR_SUCCESS) { + return open_error; + } value = defaultValue; CHAR buffer[1024]; DWORD bufferSize = sizeof(buffer); diff --git a/src/equil/MultiPhaseEquil.cpp b/src/equil/MultiPhaseEquil.cpp index e6a44f657..684b6182b 100644 --- a/src/equil/MultiPhaseEquil.cpp +++ b/src/equil/MultiPhaseEquil.cpp @@ -863,7 +863,7 @@ void MultiPhaseEquil::computeN() bool ok; for (size_t m = 0; m < m_nel; m++) { - size_t k; + size_t k = 0; for (size_t ik = 0; ik < m_nsp; ik++) { k = m_sortindex[ik]; if (m_mix->nAtoms(m_species[k],m_element[m]) != 0) { diff --git a/src/equil/vcs_solve_TP.cpp b/src/equil/vcs_solve_TP.cpp index e70934f8a..aae85cf5e 100644 --- a/src/equil/vcs_solve_TP.cpp +++ b/src/equil/vcs_solve_TP.cpp @@ -4335,7 +4335,7 @@ void VCS_SOLVE::vcs_dfe(const int stateCalc, tPhMoles_ptr = VCS_DATA_PTR(m_tPhaseMoles_old); actCoeff_ptr = VCS_DATA_PTR(m_actCoeffSpecies_old); molNum = VCS_DATA_PTR(m_molNumSpecies_old); - } else if (stateCalc == VCS_STATECALC_NEW) { + } else { // stateCalc == VCS_STATECALC_NEW feSpecies = VCS_DATA_PTR(m_feSpecies_new); tPhMoles_ptr = VCS_DATA_PTR(m_tPhaseMoles_new); actCoeff_ptr = VCS_DATA_PTR(m_actCoeffSpecies_new); @@ -5399,8 +5399,7 @@ void VCS_SOLVE::vcs_deltag_Phase(const size_t iphase, const bool doDeleted, feSpecies = VCS_DATA_PTR(m_feSpecies_new); deltaGRxn = VCS_DATA_PTR(m_deltaGRxn_new); actCoeffSpecies = VCS_DATA_PTR(m_actCoeffSpecies_new); - - } else if (stateCalc == VCS_STATECALC_OLD) { + } else { // stateCalc == VCS_STATECALC_OLD feSpecies = VCS_DATA_PTR(m_feSpecies_old); deltaGRxn = VCS_DATA_PTR(m_deltaGRxn_old); actCoeffSpecies = VCS_DATA_PTR(m_actCoeffSpecies_old); diff --git a/src/equil/vcs_solve_phaseStability.cpp b/src/equil/vcs_solve_phaseStability.cpp index cd23d97ce..dc321ac36 100644 --- a/src/equil/vcs_solve_phaseStability.cpp +++ b/src/equil/vcs_solve_phaseStability.cpp @@ -24,10 +24,6 @@ #include "cantera/base/clockWC.h" -#ifdef WIN32 -#pragma warning(disable:4996) -#endif - using namespace std; namespace VCSnonideal diff --git a/src/kinetics/solveSP.cpp b/src/kinetics/solveSP.cpp index 10d1a47c0..0778520cf 100644 --- a/src/kinetics/solveSP.cpp +++ b/src/kinetics/solveSP.cpp @@ -212,7 +212,7 @@ int solveSP::solveSurfProb(int ifunc, doublereal time_scale, doublereal TKelvin, } int info = 0; int label_t=-1; /* Species IDs for time control */ - int label_d; /* Species IDs for damping control */ + int label_d = -1; /* Species IDs for damping control */ int label_t_old=-1; doublereal label_factor = 1.0; int iter=0; // iteration number on numlinear solver diff --git a/src/numerics/BandMatrix.cpp b/src/numerics/BandMatrix.cpp index f789be5b7..2fb3e6cd5 100644 --- a/src/numerics/BandMatrix.cpp +++ b/src/numerics/BandMatrix.cpp @@ -386,7 +386,7 @@ doublereal BandMatrix::rcond(doublereal a1norm) // doublereal anorm = oneNorm(); size_t ldab = (2 *m_kl + m_ku + 1); - int rinfo; + int rinfo = 0; rcond = ct_dgbcon('1', m_n, m_kl, m_ku, DATA_PTR(ludata), ldab, DATA_PTR(m_ipiv), a1norm, DATA_PTR(work_), DATA_PTR(iwork_), rinfo); if (rinfo != 0) { diff --git a/src/numerics/NonlinearSolver.cpp b/src/numerics/NonlinearSolver.cpp index e3847fb0d..a1cddbab1 100644 --- a/src/numerics/NonlinearSolver.cpp +++ b/src/numerics/NonlinearSolver.cpp @@ -1256,7 +1256,7 @@ int NonlinearSolver::doAffineNewtonSolve(const doublereal* const y_curr, const /* * Factor the Hessian */ - int info; + int info = 0; ct_dpotrf(ctlapack::UpperTriangular, neq_, &(*(HessianPtr_->begin())), neq_, info); if (info) { if (m_print_flag >= 2) { @@ -1826,7 +1826,7 @@ void NonlinearSolver::residualComparisonLeg(const doublereal time_curr, const do doublereal* y1 = DATA_PTR(m_wksp); doublereal* ydot1 = DATA_PTR(m_wksp_2); doublereal sLen; - doublereal alpha; + doublereal alpha = 0; doublereal residSteepBest = 1.0E300; doublereal residSteepLinBest = 0.0; @@ -3453,7 +3453,7 @@ int NonlinearSolver::solve_nonlinear_problem(int SolnType, doublereal* const y_c printf(" N "); } if (doDogLeg_) { - printf("%5.1F |", log10(m_conditionNumber)); + printf("%5.1f |", log10(m_conditionNumber)); // printf("\t Iter Resid NewJac | DS_Cauchy DS_Newton DS_Trust | legID legAlpha Fbound | | DS_F ResidFinal \n"); printf("%10.3E %10.3E %10.3E %10.3E|", ResidDecreaseSDExp_, ResidDecreaseSD_, ResidDecreaseNewtExp_, ResidDecreaseNewt_); diff --git a/src/numerics/SquareMatrix.cpp b/src/numerics/SquareMatrix.cpp index 8eb0431b0..af70a4c8f 100644 --- a/src/numerics/SquareMatrix.cpp +++ b/src/numerics/SquareMatrix.cpp @@ -218,7 +218,7 @@ int SquareMatrix::factorQR() work.resize(8 * m_nrows, 0.0); } a1norm_ = ct_dlange('1', m_nrows, m_nrows, &(*(begin())), m_nrows, DATA_PTR(work)); - int info; + int info = 0; m_factored = 2; size_t lwork = work.size(); ct_dgeqrf(m_nrows, m_nrows, &(*(begin())), m_nrows, DATA_PTR(tau), DATA_PTR(work), lwork, info); @@ -312,7 +312,7 @@ doublereal SquareMatrix::rcond(doublereal anorm) // doublereal anorm = ct_dlange('1', m_nrows, m_nrows, &(*(begin())), m_nrows, DATA_PTR(work)); - int rinfo; + int rinfo = 0; rcond = ct_dgecon('1', m_nrows, &(*(begin())), m_nrows, anorm, DATA_PTR(work), DATA_PTR(iwork_), rinfo); if (rinfo != 0) { @@ -345,7 +345,7 @@ doublereal SquareMatrix::rcondQR() throw CELapackError("SquareMatrix::rcondQR()", "matrix isn't factored correctly"); } - int rinfo; + int rinfo = 0; rcond = ct_dtrcon(0, ctlapack::UpperTriangular, 0, m_nrows, &(*(begin())), m_nrows, DATA_PTR(work), DATA_PTR(iwork_), rinfo); if (rinfo != 0) { diff --git a/src/thermo/MixtureFugacityTP.cpp b/src/thermo/MixtureFugacityTP.cpp index a4a7f8264..7141a179a 100644 --- a/src/thermo/MixtureFugacityTP.cpp +++ b/src/thermo/MixtureFugacityTP.cpp @@ -16,12 +16,6 @@ * $Revision: 388 $ */ -// turn off warnings under Windows -#ifdef WIN32 -#pragma warning(disable:4786) -#pragma warning(disable:4503) -#endif - #include "cantera/thermo/MixtureFugacityTP.h" #include "cantera/thermo/VPSSMgr.h" #include "cantera/thermo/PDSS.h" @@ -1169,7 +1163,8 @@ doublereal MixtureFugacityTP::calculatePsat(doublereal TKelvin, doublereal& mola doublereal volLiquid = liquidVolEst(TKelvin, pres); RhoLiquidGood = mw / volLiquid; RhoGasGood = pres * mw / (GasConstant * TKelvin); - doublereal delGRT, liqGRT, gasGRT; + doublereal delGRT = 1.0E6; + doublereal liqGRT, gasGRT; int stab; doublereal presLast = pres; diff --git a/src/thermo/RedlichKwongMFTP.cpp b/src/thermo/RedlichKwongMFTP.cpp index ca0aa4a74..989f74da1 100644 --- a/src/thermo/RedlichKwongMFTP.cpp +++ b/src/thermo/RedlichKwongMFTP.cpp @@ -17,12 +17,6 @@ * $Revision: 255 $ */ -// turn off warnings under Windows -#ifdef WIN32 -#pragma warning(disable:4786) -#pragma warning(disable:4503) -#endif - #include "cantera/thermo/RedlichKwongMFTP.h"