Coverity fixes
authoriarsene <iarsene@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 16 Mar 2011 19:02:59 +0000 (19:02 +0000)
committeriarsene <iarsene@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 16 Mar 2011 19:02:59 +0000 (19:02 +0000)
TUHKMgen/AliGenUHKM.cxx
TUHKMgen/AliGenUHKM.h
TUHKMgen/TUHKMgen.cxx
TUHKMgen/TUHKMgen.h
TUHKMgen/UHKM/DatabasePDG.cxx
TUHKMgen/UHKM/DecayChannel.cxx
TUHKMgen/UHKM/InitialStateHydjet.cxx
TUHKMgen/UHKM/ParticlePDG.cxx

index f84e5f1..71c1902 100755 (executable)
@@ -119,8 +119,10 @@ AliGenUHKM::AliGenUHKM()
   fHydjetParams.fIenglu=0;
   fHydjetParams.fIanglu=0;
 */
-  strncpy(fParticleFilename, Form("%s/TUHKMgen/UHKM/particles.data", gSystem->Getenv("ALICE_ROOT")), 256);
-  strncpy(fDecayFilename, Form("%s/TUHKMgen/UHKM/tabledecay.txt", gSystem->Getenv("ALICE_ROOT")), 256);
+  if(strlen(Form("%s/TUHKMgen/UHKM/particles.data", gSystem->Getenv("ALICE_ROOT")))<255)
+    strncpy(fParticleFilename, Form("%s/TUHKMgen/UHKM/particles.data", gSystem->Getenv("ALICE_ROOT")), 256);
+  if(strlen(Form("%s/TUHKMgen/UHKM/tabledecay.txt",gSystem->Getenv("ALICE_ROOT")))<255)
+    strncpy(fDecayFilename, Form("%s/TUHKMgen/UHKM/tabledecay.txt", gSystem->Getenv("ALICE_ROOT")), 256);
   for(Int_t i=0; i<500; i++) {
     fStableFlagPDG[i] = 0;
     fStableFlagStatus[i] = kFALSE;
@@ -209,8 +211,10 @@ AliGenUHKM::AliGenUHKM(Int_t npart)
   fHydjetParams.fIanglu=0;
 */
 
-  strncpy(fParticleFilename, Form("%s/TUHKMgen/UHKM/particles.data", gSystem->Getenv("ALICE_ROOT")), 256);
-  strncpy(fDecayFilename, Form("%s/TUHKMgen/UHKM/tabledecay.txt", gSystem->Getenv("ALICE_ROOT")), 256);
+  if(strlen(Form("%s/TUHKMgen/UHKM/particles.data", gSystem->Getenv("ALICE_ROOT")))<255)
+    strncpy(fParticleFilename, Form("%s/TUHKMgen/UHKM/particles.data", gSystem->Getenv("ALICE_ROOT")), 256);
+  if(strlen(Form("%s/TUHKMgen/UHKM/tabledecay.txt", gSystem->Getenv("ALICE_ROOT")))<255)
+    strncpy(fDecayFilename, Form("%s/TUHKMgen/UHKM/tabledecay.txt", gSystem->Getenv("ALICE_ROOT")), 256);
   for(Int_t i=0; i<500; i++) {
     fStableFlagPDG[i] = 0;
     fStableFlagStatus[i] = kFALSE;
index 3a35c25..79b8661 100755 (executable)
@@ -86,8 +86,8 @@ class AliGenUHKM : public AliGenMC
                                                    //gluons (0: small-angular, 1: wide-angular, 2:collinear) (default: 0).
 
 
-  void SetPDGParticleFile(const Char_t *name) {strncpy(fParticleFilename, name, 256);}//Set the filename containing the particle PDG info
-  void SetPDGDecayFile(const Char_t *name) {strncpy(fDecayFilename, name, 256);} //Set the filename containing the PDG decay channels info
+  void SetPDGParticleFile(const Char_t *name) {if(strlen(name)<255) strncpy(fParticleFilename, name, 256);}//Set the filename containing the particle PDG info
+  void SetPDGDecayFile(const Char_t *name) {if(strlen(name)<255) strncpy(fDecayFilename, name, 256);} //Set the filename containing the PDG decay channels info
   void SetPDGParticleStable(Int_t pdg, Bool_t value) { // Turn on/off the decay flag for a PDG particle
     fStableFlagPDG[fStableFlagged] = pdg;
     fStableFlagStatus[fStableFlagged++] = value;
index 893923b..2726f7c 100755 (executable)
@@ -120,9 +120,11 @@ TUHKMgen::TUHKMgen() :
   fHydjetParams.fIenglu=0;     
   fHydjetParams.fIanglu=0;  
 */
-   
-  strncpy(fParticleFilename, Form("%s/TUHKMgen/UHKM/particles.data", gSystem->Getenv("ALICE_ROOT")), 256);
-  strncpy(fDecayFilename, Form("%s/TUHKMgen/UHKM/tabledecay.txt", gSystem->Getenv("ALICE_ROOT")), 256);
+
+  if(strlen(Form("%s/TUHKMgen/UHKM/particles.data", gSystem->Getenv("ALICE_ROOT")))<255)   
+    strncpy(fParticleFilename, Form("%s/TUHKMgen/UHKM/particles.data", gSystem->Getenv("ALICE_ROOT")), 256);
+  if(strlen(Form("%s/TUHKMgen/UHKM/tabledecay.txt",gSystem->Getenv("ALICE_ROOT")))<255)
+    strncpy(fDecayFilename, Form("%s/TUHKMgen/UHKM/tabledecay.txt", gSystem->Getenv("ALICE_ROOT")), 256);
   for(Int_t i=0; i<500; i++) {
     fStableFlagPDG[i] = 0;
     fStableFlagStatus[i] = kFALSE;
index 8b89989..12c2387 100755 (executable)
@@ -107,8 +107,8 @@ class TUHKMgen : public TGenerator {
                                   // gluons (0: small-angular, 1: wide-angular, 2:collinear) (default: 0).
   
  
-  void SetPDGParticleFile(const Char_t *name)              {strncpy(fParticleFilename, name, 256);}     // Set the filename containing the particle PDG info
-  void SetPDGDecayFile(const Char_t *name)                 {strncpy(fDecayFilename, name, 256);}        // Set the filename containing the PDG decay channels info
+  void SetPDGParticleFile(const Char_t *name)              {if(strlen(name)<255) strncpy(fParticleFilename, name, 256);}     // Set the filename containing the particle PDG info
+  void SetPDGDecayFile(const Char_t *name)                 {if(strlen(name)<255) strncpy(fDecayFilename, name, 256);}        // Set the filename containing the PDG decay channels info
   void SetPDGParticleStable(Int_t pdg, Bool_t value) {                                      // Turn on/off the decay flag for a PDG particle
     fStableFlagPDG[fStableFlagged] = pdg;
     fStableFlagStatus[fStableFlagged++] = value;
index 4810c53..7270477 100644 (file)
@@ -56,11 +56,13 @@ DatabasePDG::~DatabasePDG() {
 }
 
 void DatabasePDG::SetParticleFilename(Char_t *filename) {
-  strncpy(fParticleFilename, filename, 256);
+  if(strlen(filename)<255)
+    strncpy(fParticleFilename, filename, 256);
 }
 
 void DatabasePDG::SetDecayFilename(Char_t *filename) {
-  strncpy(fDecayFilename, filename, 256);
+  if(strlen(filename)<255)
+    strncpy(fDecayFilename, filename, 256);
 }
 
 Bool_t DatabasePDG::LoadData() {
index 28464c6..fc121f5 100644 (file)
@@ -51,10 +51,6 @@ DecayChannel::DecayChannel(Int_t mother, Double_t branching, Int_t nDaughters, c
   // constructor
   //
   for(Int_t i=0; i<kMaxDaughters; i++) {
-    if(i >= kMaxDaughters) {
-      cout << "ERROR in DecayChannel explicit constructor: " << endl;
-      cout << "Number of daughters bigger than the maximum allowed one (" << kMaxDaughters << ") !!" << endl;
-    }
     if(i<nDaughters)
       fDaughtersPDG[fNDaughters++] = *(daughters+i);
     else
index 3d77eec..4412ebb 100644 (file)
@@ -469,7 +469,12 @@ Bool_t InitialStateHydjet::MultIni() {
     particleDensityPiTh = gcPiTh.ParticleNumberDensity(fDatabase->GetPDGParticle(211));
   }
 
-  for(Int_t particleIndex = 0; particleIndex < TMath::Min(fDatabase->GetNParticles(), kNPartTypes); particleIndex++) {
+  for(Int_t particleIndex = 0; particleIndex < fDatabase->GetNParticles(); particleIndex++) {
+    if(particleIndex>=kNPartTypes) {
+      cout << "InitialStateHydjet::MultIni(): ERROR Particle definitions in the PDG database exceeds the hardcoded limit of " << kNPartTypes << endl;
+      cout << "      There is either an error with reading the particles file or you might need to increase the maximum allowed definitions" << endl;
+      break;
+    }
     ParticlePDG *currParticle = fDatabase->GetPDGParticleByIndex(particleIndex);
     Int_t encoding = currParticle->GetPDG();
     //strangeness supression
index b37b2ea..0754ec6 100644 (file)
@@ -35,7 +35,7 @@ ParticlePDG::ParticlePDG() :
 //
 // default constructor
 //
-  memset(fName,'0',9);
+  memset(fName,'a',9);
   for(Int_t i=0; i<kMaxDecayChannels; i++)
     fDecayChannels[i] = new DecayChannel();
 }