From 7038a248b50ff8e0e58aa89144c2f657859eaaad Mon Sep 17 00:00:00 2001 From: Thomas Beutlich Date: Wed, 1 Nov 2023 19:46:41 +0100 Subject: [PATCH] Add type casts for MSVC build w/o warnings --- contrib/shpdxf.c | 2 +- contrib/shpgeo.c | 2 +- dbfdump.c | 5 +++-- safileio.c | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/contrib/shpdxf.c b/contrib/shpdxf.c index ff203f2..0aff05c 100644 --- a/contrib/shpdxf.c +++ b/contrib/shpdxf.c @@ -283,7 +283,7 @@ int main(int argc, char **argv) char id[255]; // Proceed to process data. - for (int recNum = 0; (recNum < shp_numrec) && (recNum < MaxElem); recNum++) + for (int recNum = 0; (recNum < shp_numrec) && (recNum < (int)MaxElem); recNum++) { if (idfld >= 0) switch (idfld_type) diff --git a/contrib/shpgeo.c b/contrib/shpgeo.c index b17455f..72b9a98 100644 --- a/contrib/shpgeo.c +++ b/contrib/shpgeo.c @@ -80,7 +80,7 @@ char *asFileName(const char *fil, char *ext) /* -------------------------------------------------------------------- */ char pszBasename[120]; strcpy(pszBasename, fil); - int i = strlen(pszBasename) - 1; + int i = (int)strlen(pszBasename) - 1; for (; i > 0 && pszBasename[i] != '.' && pszBasename[i] != '/' && pszBasename[i] != '\\'; i--) diff --git a/dbfdump.c b/dbfdump.c index 9de8d91..1a9159c 100644 --- a/dbfdump.c +++ b/dbfdump.c @@ -138,8 +138,9 @@ int main(int argc, char **argv) { const DBFFieldType eType = DBFGetFieldInfo(hDBF, i, szTitle, &nWidth, &nDecimals); - if ((int)strlen(szTitle) > nWidth) - panWidth[i] = strlen(szTitle); + const int titleLen = (int)strlen(szTitle); + if (titleLen > nWidth) + panWidth[i] = titleLen; else panWidth[i] = nWidth; diff --git a/safileio.c b/safileio.c index 2cf6149..61a2adb 100644 --- a/safileio.c +++ b/safileio.c @@ -124,7 +124,7 @@ void SASetupDefaultHooks(SAHooks *psHooks) static wchar_t *Utf8ToWideChar(const char *pszFilename) { - const int nMulti = strlen(pszFilename) + 1; + const int nMulti = (int)strlen(pszFilename) + 1; const int nWide = MultiByteToWideChar(CP_UTF8, 0, pszFilename, nMulti, 0, 0); if (nWide == 0)