Skip to content

Commit

Permalink
Merge pull request #8715 from rouault/cppcheck_fixes
Browse files Browse the repository at this point in the history
Fix a few cppcheck warnings
  • Loading branch information
rouault authored Nov 15, 2023
2 parents 61b83a3 + 916bda0 commit 8944c22
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion apps/gdalbuildvrt_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,7 @@ void VRTBuilder::CreateVRTSeparate(VRTDatasetH hVRTDS)
const int nSrcBandIdx = nSelectedBands > 0
? panSelectedBandList[iBandToIter] - 1
: iBandToIter;

assert(nSrcBandIdx >= 0);
GDALAddBand(hVRTDS, psDatasetProperties->aeBandType[nSrcBandIdx],
nullptr);

Expand Down
2 changes: 2 additions & 0 deletions frmts/gtiff/gtiffdataset_read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "gtiffsplitbitmapband.h"

#include <algorithm>
#include <cassert>
#include <limits>
#include <memory>
#include <mutex>
Expand Down Expand Up @@ -937,6 +938,7 @@ static void CPL_STDCALL ThreadDecompressionFuncErrorHandler(
psContext->bCacheAllBands ? psContext->panBandMap[i] - 1
: poDS->m_nPlanarConfig == PLANARCONFIG_CONTIG ? i
: 0;
assert(iSrcBandIdx >= 0);
const int iDstBandIdx = poDS->m_nPlanarConfig == PLANARCONFIG_CONTIG
? i
: psJob->iDstBandIdxSeparate;
Expand Down
2 changes: 1 addition & 1 deletion frmts/raw/loslasdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ GDALDataset *LOSLASDataset::Open(GDALOpenInfo *poOpenInfo)
poDS->adfGeoTransform[2] = 0.0;
poDS->adfGeoTransform[3] = min_lat + (poDS->nRasterYSize - 0.5) * delta_lat;
poDS->adfGeoTransform[4] = 0.0;
poDS->adfGeoTransform[5] = -1 * delta_lat;
poDS->adfGeoTransform[5] = -1.0 * delta_lat;

/* -------------------------------------------------------------------- */
/* Initialize any PAM information. */
Expand Down
1 change: 1 addition & 0 deletions ogr/ogrsf_frmts/gpkg/ogrgeopackagetablelayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ OGRErr OGRGeoPackageTableLayer::FeatureBindParameters(
{
const int iField =
nUpdatedFieldsCount < 0 ? idx : panUpdatedFieldsIdx[idx];
assert(iField >= 0);
if (iField == m_iFIDAsRegularColumnIndex ||
m_abGeneratedColumns[iField])
continue;
Expand Down
4 changes: 2 additions & 2 deletions ogr/ogrsf_frmts/s57/s57reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3409,15 +3409,15 @@ bool S57Reader::FindAndApplyUpdates(const char *pszPath)
extension.append(buf);
dirname.append(buf);
}
else if (10 <= iUpdate && iUpdate < 100)
else if (iUpdate < 100)
{
char buf[3];
CPLsnprintf(buf, sizeof(buf), "%i", iUpdate);
extension.append("0");
extension.append(buf);
dirname.append(buf);
}
else if (100 <= iUpdate && iUpdate < 1000)
else if (iUpdate < 1000)
{
char buf[4];
CPLsnprintf(buf, sizeof(buf), "%i", iUpdate);
Expand Down

0 comments on commit 8944c22

Please sign in to comment.