Skip to content

Commit c5e3df9

Browse files
committed
Hopefully fix cppcheck master new warnings
1 parent a0454d5 commit c5e3df9

File tree

16 files changed

+29
-30
lines changed

16 files changed

+29
-30
lines changed

frmts/adrg/srpdataset.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -971,11 +971,11 @@ DDFRecord *SRPDataset::FindRecordInGENForIMG(DDFModule &module,
971971
const char *pszBAD = record->GetStringSubfield("SPR", 0, "BAD", 0);
972972
if (pszBAD == nullptr || strlen(pszBAD) != 12)
973973
continue;
974-
const CPLString osBAD = pszBAD;
974+
CPLString osBAD(pszBAD);
975975
{
976-
char *c = (char *)strchr(osBAD.c_str(), ' ');
977-
if (c)
978-
*c = 0;
976+
const auto nSpacePos = osBAD.find(' ');
977+
if (nSpacePos != std::string::npos)
978+
osBAD.resize(nSpacePos);
979979
}
980980

981981
if (EQUAL(osShortIMGFilename.c_str(), osBAD.c_str()))
@@ -1028,7 +1028,7 @@ SRPDataset *SRPDataset::OpenDataset(const char *pszGENFileName,
10281028
if (pszNAM == nullptr)
10291029
return nullptr;
10301030

1031-
const CPLString osNAM = pszNAM;
1031+
const CPLString osNAM(pszNAM);
10321032
CPLDebug("SRP", "osNAM=%s", osNAM.c_str());
10331033
if (strlen(pszNAM) != 8)
10341034
{

frmts/miramon/miramon_dataset.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ GDALDataset *MMRDataset::CreateCopy(const char *pszFilename,
366366

367367
{
368368
// pszFilename doesn't have extension or must end in "I.rel"
369-
const CPLString osFileName = pszFilename;
369+
const CPLString osFileName(pszFilename);
370370
CPLString osRelName = CreateAssociatedMetadataFileName(osFileName);
371371
if (osRelName.empty())
372372
return nullptr;

frmts/pds/pdsdataset.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1613,7 +1613,7 @@ CPLString PDSDataset::CleanString(const CPLString &osInput)
16131613
pszWrk[i] = '_';
16141614
}
16151615

1616-
CPLString osOutput = pszWrk;
1616+
CPLString osOutput(pszWrk);
16171617
CPLFree(pszWrk);
16181618
return osOutput;
16191619
}

frmts/wcs/wcsutils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ void Swap(double &a, double &b)
3232
std::string URLEncode(const std::string &str)
3333
{
3434
char *pszEncoded = CPLEscapeString(str.c_str(), -1, CPLES_URL);
35-
std::string str2 = pszEncoded;
35+
std::string str2(pszEncoded);
3636
CPLFree(pszEncoded);
3737
return str2;
3838
}

ogr/ogrsf_frmts/amigocloud/ogramigoclouddatasource.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ json_object *OGRAmigoCloudDataSource::RunSQL(const char *pszUnescapedSQL)
788788
CPLString osSQL;
789789
std::string pszAPIURL = GetAPIURL();
790790
osSQL = pszAPIURL + "/users/0/projects/" + CPLString(pszProjectId) + "/sql";
791-
std::string sql = pszUnescapedSQL;
791+
const std::string sql(pszUnescapedSQL);
792792
if (sql.find("DELETE") != std::string::npos ||
793793
sql.find("delete") != std::string::npos ||
794794
sql.find("INSERT") != std::string::npos ||

ogr/ogrsf_frmts/dwg/ogrdwg_blockmap.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ OGRDWGDataSource::SimplifyBlockGeometry(OGRGeometryCollection *poCollection)
129129
DWGBlockDefinition *OGRDWGDataSource::LookupBlock(const char *pszName)
130130

131131
{
132-
CPLString osName = pszName;
132+
const CPLString osName(pszName);
133133

134134
if (oBlockMap.count(osName) == 0)
135135
return nullptr;

ogr/ogrsf_frmts/dxf/ogrdxf_blockmap.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ bool OGRDXFDataSource::ReadBlocksSection()
172172
DXFBlockDefinition *OGRDXFDataSource::LookupBlock(const char *pszName)
173173

174174
{
175-
CPLString l_osName = pszName;
175+
const CPLString l_osName(pszName);
176176

177177
if (oBlockMap.count(l_osName) == 0)
178178
return nullptr;
@@ -190,7 +190,7 @@ DXFBlockDefinition *OGRDXFDataSource::LookupBlock(const char *pszName)
190190
CPLString OGRDXFDataSource::GetBlockNameByRecordHandle(const char *pszID)
191191

192192
{
193-
CPLString l_osID = pszID;
193+
const CPLString l_osID(pszID);
194194

195195
if (oBlockRecordHandles.count(l_osID) == 0)
196196
return "";

ogr/ogrsf_frmts/dxf/ogrdxfdatasource.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ const char *OGRDXFDataSource::LookupTextStyleProperty(const char *pszTextStyle,
728728
CPLString OGRDXFDataSource::GetTextStyleNameByHandle(const char *pszID)
729729

730730
{
731-
CPLString l_osID = pszID;
731+
const CPLString l_osID(pszID);
732732

733733
if (oTextStyleHandles.count(l_osID) == 0)
734734
return "";

ogr/ogrsf_frmts/edigeo/ogredigeodatasource.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@ int OGREDIGEODataSource::SetStyle(const CPLString &osFEA,
954954
if (strcmp(poFeature->GetDefnRef()->GetName(), "ID_S_OBJ_Z_1_2_2") == 0 &&
955955
iATR != -1 && (pszATR = poFeature->GetFieldAsString(iATR)) != nullptr)
956956
{
957-
const CPLString osATR = pszATR;
957+
const CPLString osATR(pszATR);
958958
std::map<CPLString, CPLString>::iterator itFEA_FEA =
959959
mapFEA_FEA.find(osFEA);
960960
if (itFEA_FEA != mapFEA_FEA.end())

ogr/ogrsf_frmts/filegdb/FGdbUtils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ std::wstring StringToWString(const std::string &utf8string)
3030
{
3131
wchar_t *pszUTF16 =
3232
CPLRecodeToWChar(utf8string.c_str(), CPL_ENC_UTF8, CPL_ENC_UCS2);
33-
std::wstring utf16string = pszUTF16;
33+
std::wstring utf16string(pszUTF16);
3434
CPLFree(pszUTF16);
3535
return utf16string;
3636
}
@@ -43,7 +43,7 @@ std::string WStringToString(const std::wstring &utf16string)
4343
{
4444
char *pszUTF8 =
4545
CPLRecodeFromWChar(utf16string.c_str(), CPL_ENC_UCS2, CPL_ENC_UTF8);
46-
std::string utf8string = pszUTF8;
46+
std::string utf8string(pszUTF8);
4747
CPLFree(pszUTF8);
4848
return utf8string;
4949
}

0 commit comments

Comments
 (0)