Skip to content
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

Merged
merged 2 commits into from
Oct 8, 2024

Conversation

@cmsbuild
Copy link
Contributor

cmsbuild commented Oct 4, 2024

cms-bot internal usage

@cmsbuild
Copy link
Contributor

cmsbuild commented Oct 4, 2024

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-46258/42081

@cmsbuild
Copy link
Contributor

cmsbuild commented Oct 4, 2024

A new Pull Request was created by @smuzaffar for master.

It involves the following packages:

  • RecoJets/JetPlusTracks (reconstruction)
  • RecoJets/JetProducers (reconstruction)
  • RecoMET/METAlgorithms (reconstruction)
  • RecoTBCalo/EcalTBHodoscopeReconstructor (reconstruction)
  • RecoTBCalo/HcalTBObjectUnpacker (reconstruction)
  • RecoTauTag/RecoTau (reconstruction)
  • RecoTracker/FinalTrackSelectors (reconstruction)
  • RecoTracker/MkFitCore (reconstruction)
  • RecoTracker/PixelSeeding (reconstruction)
  • RecoTracker/TkSeedGenerator (reconstruction)

@cmsbuild, @jfernan2, @mandrenguyen can you please review it and eventually sign? Thanks.
@AnnikaStein, @GiacomoSguazzoni, @JanFSchulte, @ReyerBand, @VinInn, @VourMa, @ahinzmann, @argiro, @azotz, @bsunanda, @clelange, @dgulhan, @felicepantaleo, @gkasieczka, @gouskos, @gpetruc, @jdamgov, @jdolen, @makortel, @mariadalfonso, @mbluj, @missirol, @mmarionncern, @mmusich, @mtosi, @nhanvtran, @rappoccio, @rchatter, @rovere, @schoef, @seemasharmafnal, @thomreis, @wang0jin, @yslai this is something you requested to watch as well.
@antoniovilela, @mandrenguyen, @rappoccio, @sextonkennedy you are the release manager for this.

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);
Copy link
Contributor Author

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);
Copy link
Contributor Author

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]]
Copy link
Contributor Author

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);
Copy link
Contributor Author

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]]
Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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);
Copy link
Contributor

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?

Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@cmsbuild
Copy link
Contributor

cmsbuild commented Oct 4, 2024

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-46258/42091

@cmsbuild
Copy link
Contributor

cmsbuild commented Oct 4, 2024

Pull request #46258 was updated. @cmsbuild, @jfernan2, @mandrenguyen can you please check and sign again.

@jfernan2
Copy link
Contributor

jfernan2 commented Oct 7, 2024

please test

@cmsbuild
Copy link
Contributor

cmsbuild commented Oct 7, 2024

+1

Size: This PR adds an extra 12KB to repository
Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-542d7d/42024/summary.html
COMMIT: 5af2b72
CMSSW: CMSSW_14_2_X_2024-10-07-1100/el8_amd64_gcc12
User test area: For local testing, you can use /cvmfs/cms-ci.cern.ch/week0/cms-sw/cmssw/46258/42024/install.sh to create a dev area with all the needed externals and cmssw changes.

Comparison Summary

Summary:

@jfernan2
Copy link
Contributor

jfernan2 commented Oct 8, 2024

+1

@cmsbuild
Copy link
Contributor

cmsbuild commented Oct 8, 2024

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)

@mandrenguyen
Copy link
Contributor

+1

@cmsbuild cmsbuild merged commit d4aca16 into cms-sw:master Oct 8, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants