-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
[RECONSTRUCTION] [Clang]Cleanup clang-analyzer warnings #46258
[RECONSTRUCTION] [Clang]Cleanup clang-analyzer warnings #46258
Conversation
cms-bot internal usage |
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-46258/42081
|
A new Pull Request was created by @smuzaffar for master. It involves the following packages:
@cmsbuild, @jfernan2, @mandrenguyen can you please review it and eventually sign? Thanks. cms-bot commands are listed here |
@@ -195,13 +190,13 @@ void JetPlusTrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iS | |||
bool validMatches = false; | |||
|
|||
if (!vectorial_) { | |||
scaleJPT = mJPTalgo->correction(corrected, oldjet, iEvent, iSetup, pions, muons, elecs, validMatches); | |||
double scaleJPT = mJPTalgo->correction(corrected, oldjet, iEvent, iSetup, pions, muons, elecs, validMatches); |
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.
looks like scaleJPT
was only use in this block of code, so I have moved the definition here
@@ -157,13 +153,13 @@ void JetPlusTrackProducerAA::produce(edm::Event& iEvent, const edm::EventSetup& | |||
bool validMatches = false; | |||
|
|||
if (!vectorial_) { | |||
scaleJPT = mJPTalgo->correction(corrected, oldjet, iEvent, iSetup, pions, muons, elecs, validMatches); | |||
double scaleJPT = mJPTalgo->correction(corrected, oldjet, iEvent, iSetup, pions, muons, elecs, validMatches); |
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.
looks like scaleJPT was only use in this block of code, so I have moved the definition here
@@ -752,6 +752,8 @@ void VirtualJetProducer::writeJets(edm::Event& iEvent, edm::EventSetup const& iS | |||
// Here it is assumed that fjJets_ is in decreasing order of pT, | |||
// which should happen in FastjetJetProducer::runAlgorithm() | |||
jetArea = M_PI; | |||
//rij is properly initialized above | |||
[[clang::suppress]] |
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.
rij
is properly initialized above. It is false positive report from cland-analyzer.
@@ -338,6 +338,7 @@ PileupJetIdentifier PileupJetIdAlgo::computeIdVariables(const reco::Jet* jet, | |||
for (unsigned i = 0; i < jet->numberOfSourceCandidatePtrs(); ++i) { | |||
reco::CandidatePtr pfJetConstituent = jet->sourceCandidatePtr(i); | |||
const reco::Candidate* icand = pfJetConstituent.get(); | |||
assert(icand); |
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.
just to silence the clang-analyzer warning. clang analyzer clains that pfJetConstituent.get()
can return nullptr
string cmssw_base(std::getenv("CMSSW_BASE")); | ||
[[clang::suppress]] |
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.
suppress these warnings. in cmssw env both CMSSW_BASE
and CMSSW_RELEASE_BASE
are set
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 think this code should use edm::FileInPath
instead.
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
@@ -233,7 +233,7 @@ void MultiHitGeneratorFromChi2::hitSets(const TrackingRegion& region, | |||
foundNodes.reserve(100); | |||
declareDynArray(KDTreeLinkerAlgo<RecHitsSortedInPhi::HitIter>, nThirdLayers, hitTree); | |||
declareDynArray(LayerRZPredictions, nThirdLayers, mapPred); | |||
float rzError[nThirdLayers]; //save maximum errors | |||
std::vector<float> rzError(nThirdLayers); //save maximum errors |
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.
to avoid variable length array
@@ -169,7 +169,7 @@ void PixelTripletLargeTipGenerator::hitTriplets(const TrackingRegion& region, | |||
declareDynArray(KDTreeLinkerAlgo<unsigned int>, nThirdLayers, hitTree); | |||
declareDynArray(LayerRZPredictions, nThirdLayers, mapPred); | |||
|
|||
float rzError[nThirdLayers]; //save maximum errors | |||
std::vector<float> rzError(nThirdLayers); //save maximum errors |
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.
to avoid variable length array
@@ -133,7 +133,7 @@ void PixelTripletHLTGenerator::hitTriplets(const TrackingRegion& region, | |||
foundNodes.reserve(100); | |||
|
|||
declareDynArray(KDTreeLinkerAlgo<unsigned int>, nThirdLayers, hitTree); | |||
float rzError[nThirdLayers]; //save maximum errors | |||
std::vector<float> rzError(nThirdLayers); //save maximum errors |
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.
to avoid variable length array
@@ -111,6 +111,7 @@ namespace reco { | |||
if (pfCand) | |||
return pfCand->positionAtECALEntrance(); | |||
|
|||
assert(part); |
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.
As far as I understand it it is protection against nullptr, right? It is unlikely to happen, but it is OK to have this protection. But, would it be more logical to move this assert to l.110 before dynamic_cast?
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 "unlikely to happen" or "should never happen"? If it is the latter, how about changing the function to take the part
as const reference instead of pointer to const?
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 think both :) I think nobody have touched this code for years, but I think it is called with well behaving, i.e. non null pointers. Anyway I agree that using const ref is better design than what is present currently. I can put this to my todo, butI think that in scope of this PR it makes sense to move the assert a few lines earlier.
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.
sure, I will move it up
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
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-46258/42091
|
Pull request #46258 was updated. @cmsbuild, @jfernan2, @mandrenguyen can you please check and sign again. |
please test |
+1 Size: This PR adds an extra 12KB 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. @rappoccio, @antoniovilela, @sextonkennedy, @mandrenguyen (and backports should be raised in the release meeting by the corresponding L2) |
+1 |
This PR fixes clang-analyzer warnings