[clib] Fix some size_t related compiler warnings

This commit is contained in:
Ray Speth 2018-08-28 13:06:58 -04:00
parent 719dbcc650
commit fc7c85f8d1
5 changed files with 23 additions and 23 deletions

View file

@ -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);

View file

@ -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<int>(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<int>(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<int>(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<int>(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<int>(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<int>(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<int>(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<int>(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<bool>(suppress));
suppress_thermo_warnings(suppress != 0);
return 0;
} catch (...) {
return handleAllExceptions(-1, ERR);

View file

@ -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<int>(copyString(dom.componentName(n), buf, sz));
} catch (...) {
return handleAllExceptions(-1, ERR);
}

View file

@ -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<int>(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<int>(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<int>(copyString(XmlCabinet::item(i).value(), value, lenval));
} catch (...) {
return handleAllExceptions(-1, ERR);
}

View file

@ -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]);