-
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
[SIMULATION] [Clang]Cleanup clang-analyzer warnings #46238
Conversation
cms-bot internal usage |
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-46238/42054 |
A new Pull Request was created by @smuzaffar for master. It involves the following packages:
@civanch, @cmsbuild, @kpedro88, @mdhildreth can you please review it and eventually sign? Thanks. cms-bot commands are listed here |
@@ -87,7 +87,7 @@ G4double CMSSQNeutronAnnih::momDistr(G4double x_in) { | |||
|
|||
//now interpolate the above points for x_in | |||
G4double result = 9999; | |||
for (int i = 0; i < n_entries; i++) { | |||
for (int i = 1; i < n_entries; i++) { |
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.
clang-analyzer was complaining that for i=0
, we are trying to access CDF_k[-1] and x[-1
. So I started the loop from 1
. @cms-sw/simulation-l2 please check if this is correct
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.
I am not sure what is real range for x_in but I would use following code, which is valid in all cases:
if (x_in <= 0.0) { return 0.0; }
if (x_in >= 1.0) { return CDF_k[n_entries - 1];}
for (int i = 1; i < n_entries; ++i) {
if (x[i] >= x_in) {
return (CDF_k[i] - CDF_k[i - 1]) *(x_in - x[i - 1]) / (x[i] - x[i - 1]) + CDF_k[i - 1];
}
}
return 0.0;
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.
done
@@ -240,6 +240,8 @@ void CMSG4CheckOverlap::makeReportForOverlaps(std::ofstream& fout, | |||
if (!reg) { | |||
fout << "### NO G4Region found - EXIT" | |||
<< "\n"; | |||
if (gdml) | |||
delete gdml; |
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.
this was a possible memory leak if we fail to get region
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.
It is a correct fix. As an alternative, I would remove the check if(!reg), because this should never happens.
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.
done, I have removed the if (!reg){}
block
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-46238/42066 |
Pull request #46238 was updated. @civanch, @cmsbuild, @kpedro88, @mdhildreth can you please check and sign again. |
please test |
+1 Size: This PR adds an extra 60KB to repository Comparison SummarySummary:
|
+1 |
This pull request is fully signed and it will be integrated in one of the next master IBs (tests are also fine). This pull request will now be reviewed by the release team before it's merged. @sextonkennedy, @mandrenguyen, @rappoccio, @antoniovilela (and backports should be raised in the release meeting by the corresponding L2) |
+1 |
This fixes clang static analyzer warnings https://cmssdt.cern.ch/SDT/jenkins-artifacts/ib-static-analysis/CMSSW_14_2_X_2024-10-02-1100/el8_amd64_gcc12/build-logs/