From 19c25e2ebf7d93001e3e9d20ae4c8be8982edd94 Mon Sep 17 00:00:00 2001 From: Ivan Razumov Date: Tue, 1 Oct 2024 15:33:17 +0200 Subject: [PATCH] [LLVM Analyzer] Avoid storing pointer to a temporary string's internal buffer --- .../plugins/SiPixelFakeGenErrorDBObjectESSource.cc | 7 ++----- CondTools/SiPixel/plugins/SiPixelTemplateDBObjectReader.cc | 4 +--- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/CalibTracker/SiPixelESProducers/plugins/SiPixelFakeGenErrorDBObjectESSource.cc b/CalibTracker/SiPixelESProducers/plugins/SiPixelFakeGenErrorDBObjectESSource.cc index f014574e95dea..20de51d53b3b5 100644 --- a/CalibTracker/SiPixelESProducers/plugins/SiPixelFakeGenErrorDBObjectESSource.cc +++ b/CalibTracker/SiPixelESProducers/plugins/SiPixelFakeGenErrorDBObjectESSource.cc @@ -23,7 +23,6 @@ std::unique_ptr SiPixelFakeGenErrorDBObjectESSource::pr SiPixelGenErrorDBObject* obj = new SiPixelGenErrorDBObject; // Local variables - const char* tempfile; int m; // Set the number of GenErrors to be passed to the dbobject @@ -35,9 +34,7 @@ std::unique_ptr SiPixelFakeGenErrorDBObjectESSource::pr // open the GenError file(s) for (m = 0; m < obj->numOfTempl(); ++m) { edm::FileInPath file(GenErrorCalibrations_[m].c_str()); - tempfile = (file.fullPath()).c_str(); - - std::ifstream in_file(tempfile, std::ios::in); + std::ifstream in_file(file.fullPath(), std::ios::in); if (in_file.is_open()) { edm::LogInfo("SiPixelFakeGenErrorDBObjectESSource") @@ -84,7 +81,7 @@ std::unique_ptr SiPixelFakeGenErrorDBObjectESSource::pr in_file.close(); } else { // If file didn't open, report this - edm::LogError("SiPixeFakelGenErrorDBObjectESSource") << "Error opening File" << tempfile << std::endl; + edm::LogError("SiPixeFakelGenErrorDBObjectESSource") << "Error opening File" << file.fullPath() << std::endl; } } diff --git a/CondTools/SiPixel/plugins/SiPixelTemplateDBObjectReader.cc b/CondTools/SiPixel/plugins/SiPixelTemplateDBObjectReader.cc index 579fa915173b9..6e79fe51db61d 100644 --- a/CondTools/SiPixel/plugins/SiPixelTemplateDBObjectReader.cc +++ b/CondTools/SiPixel/plugins/SiPixelTemplateDBObjectReader.cc @@ -114,7 +114,6 @@ void SiPixelTemplateDBObjectReader::analyze(const edm::Event& iEvent, const edm: edm::LogPrint("SiPixelTemplateDBObjectReader") << std::endl; //local variables - const char* tempfile; int numOfTempl = dbobject.numOfTempl(); int index = 0; float tempnum = 0, diff = 0; @@ -139,8 +138,7 @@ void SiPixelTemplateDBObjectReader::analyze(const edm::Event& iEvent, const edm: << std::right << dbobject.sVector()[index] << ".out" << std::ends; edm::FileInPath file(tout.str()); - tempfile = (file.fullPath()).c_str(); - std::ifstream in_file(tempfile, std::ios::in); + std::ifstream in_file(file.fullPath(), std::ios::in); if (in_file.is_open()) { //Removes header in textfile from diff