Skip to content

Commit

Permalink
Merge pull request #11592 from rouault/coverity
Browse files Browse the repository at this point in the history
Coverity Scan fixes
  • Loading branch information
rouault authored Jan 7, 2025
2 parents 9405aa2 + 8357b10 commit 0b82a9c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
4 changes: 3 additions & 1 deletion frmts/libertiff/libertiffdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ struct LIBERTIFFDatasetFileReader final : public LIBERTIFF_NS::FileReader

uint64_t size() const override
{
// coverity[missing_lock,lock_evasion]
if (m_nFileSize == 0)
{
std::lock_guard oLock(m_oMutex);
Expand Down Expand Up @@ -342,6 +343,7 @@ class LIBERTIFFBand final : public GDALPamRasterBand
CPLDebug("LIBERTIFF", "GetLockedBlockRef() called");
}
std::lock_guard oLock(m_oMutexBlockCache);
// coverity[sleep]
return GDALRasterBand::GetLockedBlockRef(nXBlockOff, nYBlockOff,
bJustInitialize);
}
Expand Down Expand Up @@ -1246,7 +1248,7 @@ bool LIBERTIFFDataset::ReadBlock(GByte *pabyBlockData, int nBlockXOff,

if constexpr (sizeof(size_t) < sizeof(uint64_t))
{
if (size64 > std::numeric_limits<size_t>::max())
if (size64 > std::numeric_limits<size_t>::max() - 1)
{
CPLError(CE_Failure, CPLE_NotSupported, "Too large strile");
return false;
Expand Down
8 changes: 4 additions & 4 deletions gcore/gdalalgorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2258,7 +2258,7 @@ GDALAlgorithm::AddOpenOptionsArg(std::vector<std::string> *pValue)
{
auto poDM = GetGDALDriverManager();
auto &datasetValue = inputArg->Get<GDALArgDatasetValue>();
const auto osDSName = datasetValue.GetName();
const auto &osDSName = datasetValue.GetName();
const std::string osExt = CPLGetExtension(osDSName.c_str());
if (!osExt.empty())
{
Expand Down Expand Up @@ -2575,7 +2575,7 @@ GDALAlgorithm::AddCreationOptionsArg(std::vector<std::string> *pValue)
{
auto poDM = GetGDALDriverManager();
auto &datasetValue = outputArg->Get<GDALArgDatasetValue>();
const auto osDSName = datasetValue.GetName();
const auto &osDSName = datasetValue.GetName();
const std::string osExt = CPLGetExtension(osDSName.c_str());
if (!osExt.empty())
{
Expand Down Expand Up @@ -2665,7 +2665,7 @@ GDALAlgorithm::AddLayerCreationOptionsArg(std::vector<std::string> *pValue)
{
auto poDM = GetGDALDriverManager();
auto &datasetValue = outputArg->Get<GDALArgDatasetValue>();
const auto osDSName = datasetValue.GetName();
const auto &osDSName = datasetValue.GetName();
const std::string osExt = CPLGetExtension(osDSName.c_str());
if (!osExt.empty())
{
Expand Down Expand Up @@ -3247,7 +3247,7 @@ std::string GDALAlgorithm::GetUsageAsJSON() const
if (subAlg->m_displayInJSONUsage)
{
CPLJSONDocument oSubDoc;
oSubDoc.LoadMemory(subAlg->GetUsageAsJSON());
CPL_IGNORE_RET_VAL(oSubDoc.LoadMemory(subAlg->GetUsageAsJSON()));
jSubAlgorithms.Add(oSubDoc.GetRoot());
}
}
Expand Down
2 changes: 1 addition & 1 deletion gcore/gdalalgorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -1627,7 +1627,7 @@ class CPL_DLL GDALInConstructionAlgorithmArg final : public GDALAlgorithmArg
GDALInConstructionAlgorithmArg &SetAutoCompleteFunction(
std::function<std::vector<std::string>(const std::string &)> f)
{
m_autoCompleteFunction = f;
m_autoCompleteFunction = std::move(f);
return *this;
}

Expand Down
4 changes: 2 additions & 2 deletions gcore/gdalmultidim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9514,12 +9514,12 @@ GDALDatasetFromArray *GDALDatasetFromArray::Create(
BandImageryMetadata &item = aoBandImageryMetadata[iExtraDimIdx];
if (oJsonItem.GetName() == "CENTRAL_WAVELENGTH_UM")
{
item.poCentralWavelengthArray = poArray;
item.poCentralWavelengthArray = std::move(poArray);
item.dfCentralWavelengthToMicrometer = dfConvToUM;
}
else
{
item.poFWHMArray = poArray;
item.poFWHMArray = std::move(poArray);
item.dfFWHMToMicrometer = dfConvToUM;
}
}
Expand Down

0 comments on commit 0b82a9c

Please sign in to comment.