|
| 1 | +diff --git a/cmake/helpers/configure.cmake b/cmake/helpers/configure.cmake |
| 2 | +index 989778bb7a..38973207cb 100644 |
| 3 | +--- a/cmake/helpers/configure.cmake |
| 4 | ++++ b/cmake/helpers/configure.cmake |
| 5 | +@@ -226,13 +226,13 @@ else () |
| 6 | + #endif |
| 7 | + #include <sys/types.h> |
| 8 | + #include <sys/stat.h> |
| 9 | +- int main() { struct _stat64 buf; _wstat64( \"\", &buf ); return 0; } |
| 10 | ++ int main() { struct _stat64 buf; wchar_t path = 0; _wstat64( &path, &buf ); return 0; } |
| 11 | + " |
| 12 | +- NO_UNIX_STDIO_64) |
| 13 | ++ WINDOWS_STAT64) |
| 14 | + |
| 15 | +- if (NO_UNIX_STDIO_64) |
| 16 | ++ if (WINDOWS_STAT64) |
| 17 | + set(VSI_STAT64 _stat64) |
| 18 | +- set(VSI_STAT64_T __stat64) |
| 19 | ++ set(VSI_STAT64_T _stat64) |
| 20 | + endif () |
| 21 | + |
| 22 | + check_function_exists(fopen64 HAVE_FOPEN64) |
| 23 | +diff --git a/frmts/gtiff/libgeotiff/geotiff_proj4.c b/frmts/gtiff/libgeotiff/geotiff_proj4.c |
| 24 | +index 8e38120599..9d25a7c1a7 100644 |
| 25 | +--- a/frmts/gtiff/libgeotiff/geotiff_proj4.c |
| 26 | ++++ b/frmts/gtiff/libgeotiff/geotiff_proj4.c |
| 27 | +@@ -85,7 +85,7 @@ static char **OSRProj4Tokenize( const char *pszFull ) |
| 28 | + if( pszFull == NULL ) |
| 29 | + return NULL; |
| 30 | + |
| 31 | +- char **papszTokens = (char **) calloc(sizeof(char*),nMaxTokens); |
| 32 | ++ char **papszTokens = (char **) calloc(nMaxTokens, sizeof(char*)); |
| 33 | + |
| 34 | + char *pszFullWrk = CPLStrdup(pszFull); |
| 35 | + |
| 36 | +diff --git a/frmts/northwood/northwood.cpp b/frmts/northwood/northwood.cpp |
| 37 | +index a386df96f9..d21f00f8ab 100644 |
| 38 | +--- a/frmts/northwood/northwood.cpp |
| 39 | ++++ b/frmts/northwood/northwood.cpp |
| 40 | +@@ -184,14 +184,14 @@ int nwt_ParseHeader(NWT_GRID *pGrd, const unsigned char *nwtHeader) |
| 41 | + } |
| 42 | + CPL_LSBPTR16(&usTmp); |
| 43 | + pGrd->stClassDict = reinterpret_cast<NWT_CLASSIFIED_DICT *>( |
| 44 | +- calloc(sizeof(NWT_CLASSIFIED_DICT), 1)); |
| 45 | ++ calloc(1, sizeof(NWT_CLASSIFIED_DICT))); |
| 46 | + |
| 47 | + pGrd->stClassDict->nNumClassifiedItems = usTmp; |
| 48 | + |
| 49 | + pGrd->stClassDict->stClassifiedItem = |
| 50 | + reinterpret_cast<NWT_CLASSIFIED_ITEM **>( |
| 51 | +- calloc(sizeof(NWT_CLASSIFIED_ITEM *), |
| 52 | +- pGrd->stClassDict->nNumClassifiedItems + 1)); |
| 53 | ++ calloc(pGrd->stClassDict->nNumClassifiedItems + 1, |
| 54 | ++ sizeof(NWT_CLASSIFIED_ITEM *))); |
| 55 | + |
| 56 | + // load the dictionary |
| 57 | + for (usTmp = 0; usTmp < pGrd->stClassDict->nNumClassifiedItems; usTmp++) |
| 58 | +@@ -199,7 +199,7 @@ int nwt_ParseHeader(NWT_GRID *pGrd, const unsigned char *nwtHeader) |
| 59 | + NWT_CLASSIFIED_ITEM *psItem = |
| 60 | + pGrd->stClassDict->stClassifiedItem[usTmp] = |
| 61 | + reinterpret_cast<NWT_CLASSIFIED_ITEM *>( |
| 62 | +- calloc(sizeof(NWT_CLASSIFIED_ITEM), 1)); |
| 63 | ++ calloc(1, sizeof(NWT_CLASSIFIED_ITEM))); |
| 64 | + |
| 65 | + unsigned char cTmp[256]; |
| 66 | + if (!VSIFReadL(&cTmp, 9, 1, pGrd->fp)) |
| 67 | +@@ -423,7 +423,7 @@ NWT_GRID *nwtOpenGrid(char *filename) |
| 68 | + nwtHeader[3] != 'C') |
| 69 | + return nullptr; |
| 70 | + |
| 71 | +- NWT_GRID *pGrd = reinterpret_cast<NWT_GRID *>(calloc(sizeof(NWT_GRID), 1)); |
| 72 | ++ NWT_GRID *pGrd = reinterpret_cast<NWT_GRID *>(calloc(1, sizeof(NWT_GRID))); |
| 73 | + |
| 74 | + if (nwtHeader[4] == '1') |
| 75 | + pGrd->cFormat = 0x00; // grd - surface type |
| 76 | +diff --git a/frmts/stacit/stacitdataset.cpp b/frmts/stacit/stacitdataset.cpp |
| 77 | +index 91ccc95c1a..eee65ade8d 100644 |
| 78 | +--- a/frmts/stacit/stacitdataset.cpp |
| 79 | ++++ b/frmts/stacit/stacitdataset.cpp |
| 80 | +@@ -288,6 +288,10 @@ static void ParseAsset(const CPLJSONObject &jAsset, |
| 81 | + for (const auto &oItem : oProjTransform) |
| 82 | + transform.push_back(oItem.ToDouble()); |
| 83 | + CPLAssert(transform.size() == 6 || transform.size() == 9); |
| 84 | ++#if defined(__GNUC__) |
| 85 | ++#pragma GCC diagnostic push |
| 86 | ++#pragma GCC diagnostic ignored "-Wnull-dereference" |
| 87 | ++#endif |
| 88 | + if (transform[0] <= 0 || transform[1] != 0 || transform[3] != 0 || |
| 89 | + transform[4] >= 0 || |
| 90 | + (transform.size() == 9 && |
| 91 | +@@ -300,6 +304,9 @@ static void ParseAsset(const CPLJSONObject &jAsset, |
| 92 | + osAssetName.c_str()); |
| 93 | + return; |
| 94 | + } |
| 95 | ++#if defined(__GNUC__) |
| 96 | ++#pragma GCC diagnostic pop |
| 97 | ++#endif |
| 98 | + } |
| 99 | + |
| 100 | + if (bIsBBOXValid && bIsShapeValid) |
| 101 | +diff --git a/ogr/ogrsf_frmts/shape/dbfopen.c b/ogr/ogrsf_frmts/shape/dbfopen.c |
| 102 | +index 7b3b7a5d5c..789b665830 100644 |
| 103 | +--- a/ogr/ogrsf_frmts/shape/dbfopen.c |
| 104 | ++++ b/ogr/ogrsf_frmts/shape/dbfopen.c |
| 105 | +@@ -1937,13 +1937,13 @@ int SHPAPI_CALL DBFReorderFields(DBFHandle psDBF, int *panMap) |
| 106 | + /* a simple malloc() would be enough, but calloc() helps clang static |
| 107 | + * analyzer */ |
| 108 | + int *panFieldOffsetNew = |
| 109 | +- STATIC_CAST(int *, calloc(sizeof(int), psDBF->nFields)); |
| 110 | ++ STATIC_CAST(int *, calloc(psDBF->nFields, sizeof(int))); |
| 111 | + int *panFieldSizeNew = |
| 112 | +- STATIC_CAST(int *, calloc(sizeof(int), psDBF->nFields)); |
| 113 | ++ STATIC_CAST(int *, calloc(psDBF->nFields, sizeof(int))); |
| 114 | + int *panFieldDecimalsNew = |
| 115 | +- STATIC_CAST(int *, calloc(sizeof(int), psDBF->nFields)); |
| 116 | ++ STATIC_CAST(int *, calloc(psDBF->nFields, sizeof(int))); |
| 117 | + char *pachFieldTypeNew = |
| 118 | +- STATIC_CAST(char *, calloc(sizeof(char), psDBF->nFields)); |
| 119 | ++ STATIC_CAST(char *, calloc(psDBF->nFields, sizeof(char))); |
| 120 | + char *pszHeaderNew = STATIC_CAST( |
| 121 | + char *, malloc(sizeof(char) * XBASE_FLDHDR_SZ * psDBF->nFields)); |
| 122 | + |
| 123 | +diff --git a/ogr/ogrsf_frmts/shape/sbnsearch.c b/ogr/ogrsf_frmts/shape/sbnsearch.c |
| 124 | +index 73b573ae7a..7027057c8f 100644 |
| 125 | +--- a/ogr/ogrsf_frmts/shape/sbnsearch.c |
| 126 | ++++ b/ogr/ogrsf_frmts/shape/sbnsearch.c |
| 127 | +@@ -191,7 +191,7 @@ SBNSearchHandle SBNOpenDiskTree(const char *pszSBNFilename, SAHooks *psHooks) |
| 128 | + /* Initialize the handle structure. */ |
| 129 | + /* -------------------------------------------------------------------- */ |
| 130 | + SBNSearchHandle hSBN = |
| 131 | +- STATIC_CAST(SBNSearchHandle, calloc(sizeof(struct SBNSearchInfo), 1)); |
| 132 | ++ STATIC_CAST(SBNSearchHandle, calloc(1, sizeof(struct SBNSearchInfo))); |
| 133 | + |
| 134 | + if (psHooks == SHPLIB_NULLPTR) |
| 135 | + SASetupDefaultHooks(&(hSBN->sHooks)); |
| 136 | +diff --git a/ogr/ogrsf_frmts/shape/shpopen.c b/ogr/ogrsf_frmts/shape/shpopen.c |
| 137 | +index df0bd4996d..a5c7f5e057 100644 |
| 138 | +--- a/ogr/ogrsf_frmts/shape/shpopen.c |
| 139 | ++++ b/ogr/ogrsf_frmts/shape/shpopen.c |
| 140 | +@@ -363,7 +363,7 @@ SHPHandle SHPAPI_CALL SHPOpenLL(const char *pszLayer, const char *pszAccess, |
| 141 | + /* -------------------------------------------------------------------- */ |
| 142 | + /* Initialize the info structure. */ |
| 143 | + /* -------------------------------------------------------------------- */ |
| 144 | +- SHPHandle psSHP = STATIC_CAST(SHPHandle, calloc(sizeof(SHPInfo), 1)); |
| 145 | ++ SHPHandle psSHP = STATIC_CAST(SHPHandle, calloc(1, sizeof(SHPInfo))); |
| 146 | + |
| 147 | + psSHP->bUpdated = FALSE; |
| 148 | + memcpy(&(psSHP->sHooks), psHooks, sizeof(SAHooks)); |
| 149 | +@@ -1174,7 +1174,7 @@ SHPHandle SHPAPI_CALL SHPCreateLL(const char *pszLayer, int nShapeType, |
| 150 | + return NULL; |
| 151 | + } |
| 152 | + |
| 153 | +- SHPHandle psSHP = STATIC_CAST(SHPHandle, calloc(sizeof(SHPInfo), 1)); |
| 154 | ++ SHPHandle psSHP = STATIC_CAST(SHPHandle, calloc(1, sizeof(SHPInfo))); |
| 155 | + |
| 156 | + psSHP->bUpdated = FALSE; |
| 157 | + memcpy(&(psSHP->sHooks), psHooks, sizeof(SAHooks)); |
| 158 | +@@ -1318,7 +1318,7 @@ SHPObject SHPAPI_CALL1(*) |
| 159 | + psObject->nParts = MAX(1, nParts); |
| 160 | + |
| 161 | + psObject->panPartStart = |
| 162 | +- STATIC_CAST(int *, calloc(sizeof(int), psObject->nParts)); |
| 163 | ++ STATIC_CAST(int *, calloc(psObject->nParts, sizeof(int))); |
| 164 | + psObject->panPartType = |
| 165 | + STATIC_CAST(int *, malloc(sizeof(int) * psObject->nParts)); |
| 166 | + |
| 167 | +@@ -1348,16 +1348,16 @@ SHPObject SHPAPI_CALL1(*) |
| 168 | + const size_t nSize = sizeof(double) * nVertices; |
| 169 | + psObject->padfX = |
| 170 | + STATIC_CAST(double *, padfX ? malloc(nSize) |
| 171 | +- : calloc(sizeof(double), nVertices)); |
| 172 | ++ : calloc(nVertices, sizeof(double))); |
| 173 | + psObject->padfY = |
| 174 | + STATIC_CAST(double *, padfY ? malloc(nSize) |
| 175 | +- : calloc(sizeof(double), nVertices)); |
| 176 | ++ : calloc(nVertices, sizeof(double))); |
| 177 | + psObject->padfZ = STATIC_CAST( |
| 178 | + double *, |
| 179 | +- padfZ &&bHasZ ? malloc(nSize) : calloc(sizeof(double), nVertices)); |
| 180 | ++ padfZ &&bHasZ ? malloc(nSize) : calloc(nVertices, sizeof(double))); |
| 181 | + psObject->padfM = STATIC_CAST( |
| 182 | + double *, |
| 183 | +- padfM &&bHasM ? malloc(nSize) : calloc(sizeof(double), nVertices)); |
| 184 | ++ padfM &&bHasM ? malloc(nSize) : calloc(nVertices, sizeof(double))); |
| 185 | + if (padfX != SHPLIB_NULLPTR) |
| 186 | + memcpy(psObject->padfX, padfX, nSize); |
| 187 | + if (padfY != SHPLIB_NULLPTR) |
| 188 | +diff --git a/ogr/ogrsf_frmts/shape/shptree.c b/ogr/ogrsf_frmts/shape/shptree.c |
| 189 | +index ed7681583e..a52f1a03b4 100644 |
| 190 | +--- a/ogr/ogrsf_frmts/shape/shptree.c |
| 191 | ++++ b/ogr/ogrsf_frmts/shape/shptree.c |
| 192 | +@@ -751,7 +751,7 @@ SHPTreeDiskHandle SHPOpenDiskTree(const char *pszQIXFilename, SAHooks *psHooks) |
| 193 | + SHPTreeDiskHandle hDiskTree; |
| 194 | + |
| 195 | + hDiskTree = STATIC_CAST(SHPTreeDiskHandle, |
| 196 | +- calloc(sizeof(struct SHPDiskTreeInfo), 1)); |
| 197 | ++ calloc(1, sizeof(struct SHPDiskTreeInfo))); |
| 198 | + |
| 199 | + if (psHooks == SHPLIB_NULLPTR) |
| 200 | + SASetupDefaultHooks(&(hDiskTree->sHooks)); |
0 commit comments