-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[LLVM Analyzer] Avoid storing pointer to a temporary string's internal buffer in SiPixelFakeGenErrorDBObjectESSource::produce and SiPixelTemplateDBObjectReader::analyze #46181
Conversation
cms-bot internal usage |
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-46181/41978 |
A new Pull Request was created by @iarspider for master. It involves the following packages:
@atpathak, @cmsbuild, @consuegs, @perrotta can you please review it and eventually sign? Thanks. cms-bot commands are listed here |
@@ -35,9 +34,9 @@ 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::string tempfile = file.fullPath(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@iarspider , isn't it better/faster to create std::string tempfile
outside the for loop?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Dr15Jones @makortel , is it intentional that FileInPath::fullPath
returns a copy and not a const string&
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure. If we really care about repeated (de)allocation of memory, maybe change fullPath
to return reference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it intentional that
FileInPath::fullPath
returns a copy and not aconst string&
?
I'd guess "not intentional". Or, I can't think of any good reason why it returns a copy and not a const reference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@makortel can you prepare a PR, or should I make one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@iarspider It would be great if you could do it. On the same go I'd suggest to change relativePath()
to return const string&
as well, and remove the explicit definitions of copy constructor and assignment operator, and destructor.
|
||
std::ifstream in_file(tempfile, std::ios::in); | ||
std::ifstream in_file(tempfile.c_str(), std::ios::in); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will it work if we pass file.fullPath().c_str()
directly here (without create tempfile string)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tempfile
is used also in else
branch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
frequency of hitting else
is very low. So one can just use file.fullPath()
there too ... right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
frequency of hitting
else
is very low. So one can just usefile.fullPath()
there too ... right?
I would think so.
@iarspider can the title of the PR reflect the name of the changed class? |
94fac8c
to
ce52df2
Compare
please test with #46200 |
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-46181/42198 |
please abort |
please test with #46200 |
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-46181/42199 |
Pull request #46181 was updated. @atpathak, @consuegs, @francescobrivio, @perrotta can you please check and sign again. |
-1 Failed Tests: RelVals-INPUT RelVals-INPUT
Comparison SummarySummary:
|
@cmsbuild ignore tests-rejected with external-failure |
+1 |
This pull request is fully signed and it will be integrated in one of the next master IBs (test failures were overridden). This pull request will now be reviewed by the release team before it's merged. @antoniovilela, @sextonkennedy, @mandrenguyen, @rappoccio (and backports should be raised in the release meeting by the corresponding L2) |
+1 |
PR description:
LLVM report: link
PR validation:
Bot tests