Skip to content

Commit

Permalink
Fix various compiler warnings on 32bit with clang -Wshorten-64-to-32
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed May 23, 2024
1 parent c64cb04 commit 153b819
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
11 changes: 7 additions & 4 deletions frmts/ceos2/sar_ceosdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,10 @@ CPLErr SAR_CEOSRasterBand::IReadBlock(int /* nBlockXOff */, int nBlockYOff,
/* -------------------------------------------------------------------- */
int nPixelsRead = 0;

GByte *pabyRecord = (GByte *)CPLMalloc(
static_cast<size_t>(ImageDesc->BytesPerPixel) * nBlockXSize);
GByte *pabyRecord =
(GByte *)VSI_MALLOC2_VERBOSE(ImageDesc->BytesPerPixel, nBlockXSize);
if (!pabyRecord)
return CE_Failure;

for (int iRecord = 0; iRecord < ImageDesc->RecordsPerLine; iRecord++)
{
Expand All @@ -268,8 +270,9 @@ CPLErr SAR_CEOSRasterBand::IReadBlock(int /* nBlockXOff */, int nBlockYOff,

CPL_IGNORE_RET_VAL(VSIFSeekL(poGDS->fpImage, offset, SEEK_SET));
CPL_IGNORE_RET_VAL(VSIFReadL(
pabyRecord + nPixelsRead * ImageDesc->BytesPerPixel, 1,
static_cast<vsi_l_offset>(nPixelsToRead) * ImageDesc->BytesPerPixel,
pabyRecord +
static_cast<size_t>(nPixelsRead) * ImageDesc->BytesPerPixel,
1, static_cast<size_t>(nPixelsToRead) * ImageDesc->BytesPerPixel,
poGDS->fpImage));

nPixelsRead += nPixelsToRead;
Expand Down
2 changes: 1 addition & 1 deletion frmts/null/nulldataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ CPLErr GDALNullRasterBand::IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff,
if (nPixelSpace == GDALGetDataTypeSizeBytes(eBufType) &&
nLineSpace == nPixelSpace * nBufXSize)
{
memset(pData, 0, nLineSpace * nBufYSize);
memset(pData, 0, static_cast<size_t>(nLineSpace) * nBufYSize);
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions ogr/ogrsf_frmts/hana/ogrhanatablelayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1702,12 +1702,12 @@ OGRErr OGRHanaTableLayer::AlterFieldDefn(int field, OGRFieldDefn *newFieldDefn,

OGRFieldDefn *fieldDefn = featureDefn_->GetFieldDefn(field);

int64_t columnDescIdx = -1;
int columnDescIdx = -1;
for (size_t i = 0; i < attrColumns_.size(); ++i)
{
if (EQUAL(attrColumns_[i].name.c_str(), fieldDefn->GetNameRef()))
{
columnDescIdx = i;
columnDescIdx = static_cast<int>(i);
break;
}
}
Expand Down
5 changes: 3 additions & 2 deletions port/cpl_multiproc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1783,8 +1783,9 @@ CPLCondTimedWaitReason CPLCondTimedWait(CPLCond *hCond, CPLMutex *hMutex,

gettimeofday(&tv, nullptr);
ts.tv_sec = time(nullptr) + static_cast<int>(dfWaitInSeconds);
ts.tv_nsec = tv.tv_usec * 1000 + static_cast<int>(1000 * 1000 * 1000 *
fmod(dfWaitInSeconds, 1));
ts.tv_nsec =
static_cast<int>(tv.tv_usec) * 1000 +
static_cast<int>(1000 * 1000 * 1000 * fmod(dfWaitInSeconds, 1));
ts.tv_sec += ts.tv_nsec / (1000 * 1000 * 1000);
ts.tv_nsec %= (1000 * 1000 * 1000);
int ret = pthread_cond_timedwait(pCond, pMutex, &ts);
Expand Down

0 comments on commit 153b819

Please sign in to comment.