From fc7c85f8d1d340ad52cf2d6bf8bae359e2562e87 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Tue, 28 Aug 2018 13:06:58 -0400 Subject: [PATCH] [clib] Fix some size_t related compiler warnings --- include/cantera/clib/ct.h | 8 ++++---- src/clib/ct.cpp | 26 +++++++++++++------------- src/clib/ctonedim.cpp | 2 +- src/clib/ctxml.cpp | 6 +++--- test_problems/clib_test/clib_test.c | 4 ++-- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/include/cantera/clib/ct.h b/include/cantera/clib/ct.h index 596ed8809..debf93c82 100644 --- a/include/cantera/clib/ct.h +++ b/include/cantera/clib/ct.h @@ -102,9 +102,9 @@ extern "C" { CANTERA_CAPI int thermo_setState_Psat(int n, double p, double x); CANTERA_CAPI int thermo_setState_Tsat(int n, double t, double x); - CANTERA_CAPI size_t kin_newFromXML(int mxml, int iphase, - int neighbor1, int neighbor2, int neighbor3, - int neighbor4); + CANTERA_CAPI int kin_newFromXML(int mxml, int iphase, + int neighbor1, int neighbor2, int neighbor3, + int neighbor4); CANTERA_CAPI int kin_del(int n); CANTERA_CAPI size_t kin_nSpecies(int n); CANTERA_CAPI size_t kin_nReactions(int n); @@ -137,7 +137,7 @@ extern "C" { CANTERA_CAPI int kin_advanceCoverages(int n, double tstep); CANTERA_CAPI size_t kin_phase(int n, size_t i); - CANTERA_CAPI size_t trans_new(const char* model, int th, int loglevel); + CANTERA_CAPI int trans_new(const char* model, int th, int loglevel); CANTERA_CAPI int trans_del(int n); CANTERA_CAPI double trans_viscosity(int n); CANTERA_CAPI double trans_electricalConductivity(int n); diff --git a/src/clib/ct.cpp b/src/clib/ct.cpp index 99e047a59..b93d412f7 100644 --- a/src/clib/ct.cpp +++ b/src/clib/ct.cpp @@ -287,7 +287,7 @@ extern "C" { int thermo_getName(int n, size_t lennm, char* nm) { try { - return copyString(ThermoCabinet::item(n).name(), nm, lennm); + return static_cast(copyString(ThermoCabinet::item(n).name(), nm, lennm)); } catch (...) { return handleAllExceptions(-1, ERR); } @@ -306,7 +306,7 @@ extern "C" { int thermo_getSpeciesName(int n, size_t k, size_t lennm, char* nm) { try { - return copyString(ThermoCabinet::item(n).speciesName(k), nm, lennm); + return static_cast(copyString(ThermoCabinet::item(n).speciesName(k), nm, lennm)); } catch (...) { return handleAllExceptions(-1, ERR); } @@ -315,7 +315,7 @@ extern "C" { int thermo_getElementName(int n, size_t m, size_t lennm, char* nm) { try { - return copyString(ThermoCabinet::item(n).elementName(m), nm, lennm); + return static_cast(copyString(ThermoCabinet::item(n).elementName(m), nm, lennm)); } catch (...) { return handleAllExceptions(-1, ERR); } @@ -357,7 +357,7 @@ extern "C" { int thermo_getEosType(int n, size_t leneos, char* eos) { try { - return copyString(ThermoCabinet::item(n).type(), eos, leneos); + return static_cast(copyString(ThermoCabinet::item(n).type(), eos, leneos)); } catch (...) { return handleAllExceptions(-1, ERR); } @@ -869,9 +869,9 @@ extern "C" { //-------------- Kinetics ------------------// - size_t kin_newFromXML(int mxml, int iphase, - int neighbor1, int neighbor2, int neighbor3, - int neighbor4) + int kin_newFromXML(int mxml, int iphase, + int neighbor1, int neighbor2, int neighbor3, + int neighbor4) { try { XML_Node& x = XmlCabinet::item(mxml); @@ -904,7 +904,7 @@ extern "C" { int kin_getType(int n, size_t lennm, char* nm) { try { - return copyString(KineticsCabinet::item(n).kineticsType(), nm, lennm); + return static_cast(copyString(KineticsCabinet::item(n).kineticsType(), nm, lennm)); } catch (...) { return handleAllExceptions(-1, ERR); } @@ -1241,7 +1241,7 @@ extern "C" { //------------------- Transport --------------------------- - size_t trans_new(const char* model, int ith, int loglevel) + int trans_new(const char* model, int ith, int loglevel) { try { Transport* tr = newTransportMgr(model, &ThermoCabinet::item(ith), @@ -1413,7 +1413,7 @@ extern "C" { int ct_getDataDirectories(int buflen, char* buf, const char* sep) { try { - return copyString(getDataDirectories(sep), buf, buflen); + return static_cast(copyString(getDataDirectories(sep), buf, buflen)); } catch (...) { return handleAllExceptions(-1, ERR); } @@ -1422,7 +1422,7 @@ extern "C" { int ct_getCanteraVersion(int buflen, char* buf) { try { - return copyString(CANTERA_VERSION, buf, buflen); + return static_cast(copyString(CANTERA_VERSION, buf, buflen)); } catch (...) { return handleAllExceptions(-1, ERR); } @@ -1431,7 +1431,7 @@ extern "C" { int ct_getGitCommit(int buflen, char* buf) { try { - return copyString(gitCommit(), buf, buflen); + return static_cast(copyString(gitCommit(), buf, buflen)); } catch (...) { return handleAllExceptions(-1, ERR); } @@ -1440,7 +1440,7 @@ extern "C" { int ct_suppress_thermo_warnings(int suppress) { try { - suppress_thermo_warnings(static_cast(suppress)); + suppress_thermo_warnings(suppress != 0); return 0; } catch (...) { return handleAllExceptions(-1, ERR); diff --git a/src/clib/ctonedim.cpp b/src/clib/ctonedim.cpp index 3f57fc1e6..5bfb2ad4b 100644 --- a/src/clib/ctonedim.cpp +++ b/src/clib/ctonedim.cpp @@ -93,7 +93,7 @@ extern "C" { try { Domain1D& dom = DomainCabinet::item(i); dom.checkComponentIndex(n); - return copyString(dom.componentName(n), buf, sz); + return static_cast(copyString(dom.componentName(n), buf, sz)); } catch (...) { return handleAllExceptions(-1, ERR); } diff --git a/src/clib/ctxml.cpp b/src/clib/ctxml.cpp index 9812cd7ab..93a56586c 100644 --- a/src/clib/ctxml.cpp +++ b/src/clib/ctxml.cpp @@ -105,7 +105,7 @@ extern "C" { try { XML_Node& node = XmlCabinet::item(i); if (node.hasAttrib(key)) { - return copyString(node[key], value, lenval); + return static_cast(copyString(node[key], value, lenval)); } else { throw CanteraError("xml_attrib","node " " has no attribute '"+string(key)+"'"); @@ -138,7 +138,7 @@ extern "C" { int xml_tag(int i, size_t lentag, char* tag) { try { - return copyString(XmlCabinet::item(i).name(), tag, lentag); + return static_cast(copyString(XmlCabinet::item(i).name(), tag, lentag)); } catch (...) { return handleAllExceptions(-1, ERR); } @@ -147,7 +147,7 @@ extern "C" { int xml_value(int i, size_t lenval, char* value) { try { - return copyString(XmlCabinet::item(i).value(), value, lenval); + return static_cast(copyString(XmlCabinet::item(i).value(), value, lenval)); } catch (...) { return handleAllExceptions(-1, ERR); } diff --git a/test_problems/clib_test/clib_test.c b/test_problems/clib_test/clib_test.c index a425fb67f..6c6accd95 100644 --- a/test_problems/clib_test/clib_test.c +++ b/test_problems/clib_test/clib_test.c @@ -23,7 +23,7 @@ int main(int argc, char** argv) int thermo = thermo_newFromXML(phase_node); assert(thermo > 0); - int nsp = thermo_nSpecies(thermo); + size_t nsp = thermo_nSpecies(thermo); assert(nsp == 53); ret = thermo_setTemperature(thermo, 500); @@ -54,7 +54,7 @@ int main(int argc, char** argv) double ropf[325]; printf("\n Reaction Forward ROP\n"); kin_getFwdRatesOfProgress(kin, 325, ropf); - size_t n; // declare this here for C89 compatibility + int n; // declare this here for C89 compatibility for (n = 0; n < nr; n++) { kin_getReactionString(kin, n, 1000, buf); printf("%35s %8.6e\n", buf, ropf[n]);