Skip to content

Commit 3facaa4

Browse files
committed
Fix Coverity Scan warnings
1 parent 9706306 commit 3facaa4

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

apps/gdalgetgdalpath.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#include "gdal.h"
1616
#include "gdalgetgdalpath.h"
1717

18+
#include <cassert>
19+
1820
/************************************************************************/
1921
/* GDALGetGDALPath() */
2022
/************************************************************************/
@@ -38,7 +40,7 @@ std::string GDALGetGDALPath()
3840
#endif
3941
})
4042
{
41-
const std::string osPath =
43+
std::string osPath =
4244
CPLFormFilenameSafe(pszGDAL_PATH, pszProgramName, nullptr);
4345
if (VSIStatL(osPath.c_str(), &sStat) == 0)
4446
return osPath;
@@ -83,7 +85,7 @@ std::string GDALGetGDALPath()
8385
if (VSIStatL(osBinFilename.c_str(), &sStat) == 0)
8486
{
8587
// Case if pszLibName=/usr/lib/libgdal.so.xxx
86-
osPath = osBinFilename;
88+
osPath = std::move(osBinFilename);
8789
}
8890
else
8991
{
@@ -96,7 +98,7 @@ std::string GDALGetGDALPath()
9698
if (VSIStatL(osBinFilename.c_str(), &sStat) == 0)
9799
{
98100
// Case if pszLibName=/usr/lib/yyyyy/libgdal.so.xxx
99-
osPath = osBinFilename;
101+
osPath = std::move(osBinFilename);
100102
}
101103
else
102104
{
@@ -105,7 +107,7 @@ std::string GDALGetGDALPath()
105107
if (VSIStatL(osBinFilename.c_str(), &sStat) == 0)
106108
{
107109
// Case if pszLibName=/path/to/build_dir/libgdal.so.xxx
108-
osPath = osBinFilename;
110+
osPath = std::move(osBinFilename);
109111
}
110112
}
111113
}
@@ -145,7 +147,7 @@ std::string GDALGetGDALPath()
145147
fpOut->Read(szVersion, 1, nVersionSize);
146148
for (const char ch : {'\n', '\r'})
147149
{
148-
if (szVersion[nVersionSize - 1] == ch)
150+
if (nVersionSize >= 1 && szVersion[nVersionSize - 1] == ch)
149151
{
150152
szVersion[nVersionSize - 1] = 0;
151153
--nVersionSize;

ogr/ogrsf_frmts/arrow_common/ograrrowlayer.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "ogr_wkb.h"
2525

2626
#include <algorithm>
27+
#include <cassert>
2728
#include <cinttypes>
2829
#include <limits>
2930
#include <string_view>
@@ -5217,6 +5218,7 @@ inline OGRErr OGRArrowLayer::IGetExtent(int iGeomField, OGREnvelope *psExtent,
52175218
}
52185219
else
52195220
{
5221+
assert(largeArray);
52205222
int64_t out_length = 0;
52215223
const uint8_t *data =
52225224
largeArray->GetValue(m_nIdxInBatch, &out_length);

port/cpl_spawn.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ CPLSpawnAsync(int (*pfnMain)(CPL_FILE_HANDLE, CPL_FILE_HANDLE),
610610
int pipe_out[2] = {-1, -1};
611611
int pipe_err[2] = {-1, -1};
612612

613-
const auto ClosePipes = [pipe_in, pipe_out, pipe_err]()
613+
const auto ClosePipes = [&pipe_in, &pipe_out, &pipe_err]()
614614
{
615615
for (int i = 0; i < 2; i++)
616616
{

0 commit comments

Comments
 (0)