Skip to content

Commit 93878ec

Browse files
committed
Fix Coverity Scan warnings
1 parent 607bec8 commit 93878ec

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

autotest/cpp/test_marching_squares_polygon.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,9 @@ TEST_F(test_ms_polygon, four_pixels_2)
344344
}
345345
{
346346
EXPECT_EQ(w.polygons_.size(), 2);
347-
EXPECT_EQ(w.polygons_.find(Inf)->second.size(), 0);
347+
auto iter = w.polygons_.find(Inf);
348+
ASSERT_TRUE(iter != w.polygons_.end());
349+
EXPECT_TRUE(iter->second.empty());
348350
}
349351

350352
{

port/cpl_path.cpp

+6-7
Original file line numberDiff line numberDiff line change
@@ -720,14 +720,13 @@ std::string CPLFormFilenameSafe(const char *pszPath, const char *pszBasename,
720720
pszPath = "";
721721
size_t nLenPath = strlen(pszPath);
722722

723-
size_t nSuffixPos = 0;
723+
const char *pszQuestionMark = nullptr;
724724
if (STARTS_WITH_CI(pszPath, "/vsicurl/http"))
725725
{
726-
const char *pszQuestionMark = strchr(pszPath, '?');
726+
pszQuestionMark = strchr(pszPath, '?');
727727
if (pszQuestionMark)
728728
{
729-
nSuffixPos = static_cast<size_t>(pszQuestionMark - pszPath);
730-
nLenPath = nSuffixPos;
729+
nLenPath = pszQuestionMark - pszPath;
731730
}
732731
pszAddedPathSep = "/";
733732
}
@@ -811,16 +810,16 @@ std::string CPLFormFilenameSafe(const char *pszPath, const char *pszBasename,
811810
std::string osRes;
812811
osRes.reserve(nLenPath + strlen(pszAddedPathSep) + strlen(pszBasename) +
813812
strlen(pszAddedExtSep) + strlen(pszExtension) +
814-
(nSuffixPos ? strlen(pszPath + nSuffixPos) : 0));
813+
(pszQuestionMark ? strlen(pszQuestionMark) : 0));
815814
osRes.assign(pszPath, nLenPath);
816815
osRes += pszAddedPathSep;
817816
osRes += pszBasename;
818817
osRes += pszAddedExtSep;
819818
osRes += pszExtension;
820819

821-
if (nSuffixPos)
820+
if (pszQuestionMark)
822821
{
823-
osRes += (pszPath + nSuffixPos);
822+
osRes += pszQuestionMark;
824823
}
825824

826825
return osRes;

0 commit comments

Comments
 (0)