Skip to content

Commit

Permalink
Merge pull request #10639 from rouault/fix_codeql
Browse files Browse the repository at this point in the history
Fix CodeQL cpp/unsigned-difference-expression-compared-zero warnings
  • Loading branch information
rouault committed Aug 25, 2024
2 parents 2c50449 + 13ffc67 commit 3aa4582
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions ogr/ogrsf_frmts/geojson/ogrgeojsonreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ bool OGRGeoJSONReader::FirstPassReadLayer(OGRGeoJSONDataSource *poDS,
bFirstSeg_ = false;
nSkip = SkipPrologEpilogAndUpdateJSonPLikeWrapper(nRead);
}
if (bFinished && bJSonPLikeWrapper_ && nRead - nSkip > 0)
if (bFinished && bJSonPLikeWrapper_ && nRead > nSkip)
nRead--;
if (!oParser.Parse(reinterpret_cast<const char *>(pabyBuffer_ + nSkip),
nRead - nSkip, bFinished) ||
Expand Down Expand Up @@ -704,7 +704,7 @@ OGRFeature *OGRGeoJSONReader::GetNextFeature(OGRGeoJSONLayer *poLayer)
bFirstSeg_ = false;
nSkip = SkipPrologEpilogAndUpdateJSonPLikeWrapper(nRead);
}
if (bFinished && bJSonPLikeWrapper_ && nRead - nSkip > 0)
if (bFinished && bJSonPLikeWrapper_ && nRead > nSkip)
nRead--;
if (!poStreamingParser_->Parse(
reinterpret_cast<const char *>(pabyBuffer_ + nSkip),
Expand Down Expand Up @@ -762,7 +762,7 @@ OGRFeature *OGRGeoJSONReader::GetFeature(OGRGeoJSONLayer *poLayer, GIntBig nFID)
bFirstSeg_ = false;
nSkip = SkipPrologEpilogAndUpdateJSonPLikeWrapper(nRead);
}
if (bFinished && bJSonPLikeWrapper_ && nRead - nSkip > 0)
if (bFinished && bJSonPLikeWrapper_ && nRead > nSkip)
nRead--;
auto pszPtr = reinterpret_cast<const char *>(pabyBuffer_ + nSkip);
for (size_t i = 0; i < nRead - nSkip; i++)
Expand Down
2 changes: 1 addition & 1 deletion ogr/ogrsf_frmts/openfilegdb/filegdbtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ class FileGDBTable
int64_t m_nTotalRecordCount = 0;
int m_iGeomField = -1;
int m_nCountNullableFields = 0;
int m_nNullableFieldsSizeInBytes = 0;
unsigned m_nNullableFieldsSizeInBytes = 0;

std::vector<double> m_adfSpatialIndexGridResolution{};

Expand Down
6 changes: 3 additions & 3 deletions ogr/ogrsf_frmts/openfilegdb/filegdbtable_write_fields.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ bool FileGDBTable::RewriteTableToAddLastAddedField()
{
nOldCountNullableFields--;
}
const int nOldNullableFieldsSizeInBytes =
const unsigned nOldNullableFieldsSizeInBytes =
BIT_ARRAY_SIZE_IN_BYTES(nOldCountNullableFields);
int nExtraBytes = 0;
if (nOldNullableFieldsSizeInBytes != m_nNullableFieldsSizeInBytes)
Expand Down Expand Up @@ -320,7 +320,7 @@ bool FileGDBTable::RewriteTableToAddLastAddedField()
return false;

// Write updated feature data
if (nOldNullableFieldsSizeInBytes > 0)
if (nOldNullableFieldsSizeInBytes != 0)
{
if (VSIFWriteL(m_abyBuffer.data(),
nOldNullableFieldsSizeInBytes, 1,
Expand All @@ -336,7 +336,7 @@ bool FileGDBTable::RewriteTableToAddLastAddedField()
oWholeFileRewriter.m_fpTable) != 1)
return false;
}
if (nFeatureSize - nOldNullableFieldsSizeInBytes > 0)
if (nFeatureSize > nOldNullableFieldsSizeInBytes)
{
if (VSIFWriteL(m_abyBuffer.data() +
nOldNullableFieldsSizeInBytes,
Expand Down

0 comments on commit 3aa4582

Please sign in to comment.