Skip to content

Commit

Permalink
Merge pull request #46181 from iarspider/iarspider-patch-20241001-2
Browse files Browse the repository at this point in the history
[LLVM Analyzer] Avoid storing pointer to a temporary string's internal buffer in SiPixelFakeGenErrorDBObjectESSource::produce and SiPixelTemplateDBObjectReader::analyze
  • Loading branch information
cmsbuild authored Oct 12, 2024
2 parents 21636e8 + 19c25e2 commit 32c7e17
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ std::unique_ptr<SiPixelGenErrorDBObject> SiPixelFakeGenErrorDBObjectESSource::pr
SiPixelGenErrorDBObject* obj = new SiPixelGenErrorDBObject;

// Local variables
const char* tempfile;
int m;

// Set the number of GenErrors to be passed to the dbobject
Expand All @@ -35,9 +34,7 @@ std::unique_ptr<SiPixelGenErrorDBObject> 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")
Expand Down Expand Up @@ -84,7 +81,7 @@ std::unique_ptr<SiPixelGenErrorDBObject> 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;
}
}

Expand Down
4 changes: 1 addition & 3 deletions CondTools/SiPixel/plugins/SiPixelTemplateDBObjectReader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down

0 comments on commit 32c7e17

Please sign in to comment.