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

Fixed static analyzer warnings #11097

Merged
merged 2 commits into from Sep 4, 2015

Conversation

civanch
Copy link
Contributor

@civanch civanch commented Sep 3, 2015

The most of fixes are trivial and fixes are obvious. Few places may provide crash. For example, RunManagerMTWorker in abnormal case may crash at exit, which will shadow real problem.

@cmsbuild
Copy link
Contributor

cmsbuild commented Sep 3, 2015

A new Pull Request was created by @civanch (Vladimir Ivantchenko) for CMSSW_7_6_X.

Fixed static analyzer warnings

It involves the following packages:

SimCalorimetry/EcalSelectiveReadoutAlgos
SimG4CMS/Calo
SimG4CMS/FP420
SimG4CMS/Forward
SimG4CMS/HcalTestBeam
SimG4Core/Application
SimG4Core/CustomPhysics
SimG4Core/PhysicsLists
SimMuon/RPCDigitizer
SimTracker/Common
SimTracker/SiStripDigitizer

@cmsbuild, @civanch, @mdhildreth can you please review it and eventually sign? Thanks.
@jlagram, @makortel, @GiacomoSguazzoni, @gbenelli, @rovere, @argiro, @cnuttens, @prolay, @jhgoh, @cerati, @VinInn, @threus, @dgulhan, @LBeck this is something you requested to watch as well.
You can sign-off by replying to this message having '+1' in the first line of your reply.
You can reject by replying to this message having '-1' in the first line of your reply.
If you are a L2 or a release manager you can ask for tests by saying 'please test' in the first line of a comment.
@Degano you are the release manager for this.
You can merge this pull request by typing 'merge' in the first line of your comment.

@civanch
Copy link
Contributor Author

civanch commented Sep 3, 2015

please test

@cmsbuild
Copy link
Contributor

cmsbuild commented Sep 3, 2015

The tests are being triggered in jenkins.

@smuzaffar
Copy link
Contributor

Ok I have restarted the tests

@cmsbuild
Copy link
Contributor

cmsbuild commented Sep 3, 2015

@cmsbuild
Copy link
Contributor

cmsbuild commented Sep 3, 2015

@civanch
Copy link
Contributor Author

civanch commented Sep 3, 2015

+1
comparisons shows statistical agreement and not full identity, because part of fixes was removal of unused calls to random number generator in RPC digitisation.

@cmsbuild
Copy link
Contributor

cmsbuild commented Sep 3, 2015

This pull request is fully signed and it will be integrated in one of the next CMSSW_7_6_X IBs (tests are also fine). This pull request requires discussion in the ORP meeting before it's merged. @davidlange6, @Degano, @smuzaffar

@@ -222,7 +207,7 @@ double SiG4UniversalFluctuation::SampleFluctuations(const double momentum,
//
if (suma > sumalim)
{
p1 = 0., p2 = 0 ;
double p1, p2;
Copy link
Contributor

Choose a reason for hiding this comment

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

@civanch - you need the initialization here, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi David, no, because both p1 and p2 are defined below in any case. The static analyser complains to this line.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see if (something) p1=blah then if (something2) p2=blah, then bah=p1_a+p2_b. So you definitely need to initialize p1 and p2.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

HI David, the full block:
double p1, p2;
if((a1+a2) > 0.)
{
// excitation type 1
if (a1>alim) {
siga=sqrt(a1) ;
p1 = max(0., CLHEP::RandGaussQ::shoot(engine, a1, siga) + 0.5);
} else {
p1 = double(CLHEP::RandPoissonQ::shoot(engine,a1));
}

  // excitation type 2
  if (a2>alim) {
    siga=sqrt(a2) ;
    p2 = max(0., CLHEP::RandGaussQ::shoot(engine, a2, siga) + 0.5);
  } else {
p2 = double(CLHEP::RandPoissonQ::shoot(engine,a2));
  }

  loss = p1*e1Fluct+p2*e2Fluct;

  // smearing to avoid unphysical peaks
  if (p2 > 0.)
    loss += (1.-2.*CLHEP::RandFlat::shoot(engine))*e2Fluct;
  else if (loss>0.)
    loss += (1.-2.*CLHEP::RandFlat::shoot(engine))*e1Fluct;
  if (loss < 0.) loss = 0.0;
}

so, for both p1 and p2 we have if()p1=value1; else p1=value2, the same for p2 - both are defined in any case.

However, what I see now: the line 'double p1, p2;' may be moved down inside the block. Minor thing, should I do this?

@civanch
Copy link
Contributor Author

civanch commented Sep 4, 2015

+1
additional commit adds a minor code improvements, also unused commented out lines of code are removed

@cmsbuild
Copy link
Contributor

cmsbuild commented Sep 4, 2015

This pull request is fully signed and it will be integrated in one of the next CMSSW_7_6_X IBs or unless it breaks tests. This pull request requires discussion in the ORP meeting before it's merged. @davidlange6, @Degano, @smuzaffar

@cmsbuild
Copy link
Contributor

cmsbuild commented Sep 4, 2015

Pull request #11097 was updated. @cmsbuild can you please check and sign again.

@civanch
Copy link
Contributor Author

civanch commented Sep 4, 2015

please test

@cmsbuild
Copy link
Contributor

cmsbuild commented Sep 4, 2015

The tests are being triggered in jenkins.

@cmsbuild
Copy link
Contributor

cmsbuild commented Sep 4, 2015

This pull request is fully signed and it will be integrated in one of the next CMSSW_7_6_X IBs or unless it breaks tests. This pull request requires discussion in the ORP meeting before it's merged. @davidlange6, @Degano, @smuzaffar

@davidlange6
Copy link
Contributor

ah -whoops - thanks @civanch

@cmsbuild
Copy link
Contributor

cmsbuild commented Sep 4, 2015

@cmsbuild
Copy link
Contributor

cmsbuild commented Sep 4, 2015

This pull request is fully signed and it will be integrated in one of the next CMSSW_7_6_X IBs (tests are also fine). This pull request requires discussion in the ORP meeting before it's merged. @davidlange6, @Degano, @smuzaffar

@cmsbuild
Copy link
Contributor

cmsbuild commented Sep 4, 2015

@cmsbuild
Copy link
Contributor

cmsbuild commented Sep 4, 2015

This pull request is fully signed and it will be integrated in one of the next CMSSW_7_6_X IBs (tests are also fine). This pull request requires discussion in the ORP meeting before it's merged. @davidlange6, @Degano, @smuzaffar

@davidlange6
Copy link
Contributor

+1

cmsbuild added a commit that referenced this pull request Sep 4, 2015
@cmsbuild cmsbuild merged commit e042f6d into cms-sw:CMSSW_7_6_X Sep 4, 2015
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.

None yet

4 participants