Coverity fixes in TUHKMgen
authoriarsene <iarsene@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 20 Mar 2011 17:10:33 +0000 (17:10 +0000)
committeriarsene <iarsene@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 20 Mar 2011 17:10:33 +0000 (17:10 +0000)
TUHKMgen/AliGenUHKM.cxx
TUHKMgen/AliGenUHKM.h
TUHKMgen/TUHKMgen.cxx
TUHKMgen/TUHKMgen.h
TUHKMgen/UHKM/DatabasePDG.cxx

index 71c1902..7e659fb 100755 (executable)
@@ -119,10 +119,8 @@ AliGenUHKM::AliGenUHKM()
   fHydjetParams.fIenglu=0;
   fHydjetParams.fIanglu=0;
 */
-  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);
+  strncpy(fParticleFilename, Form("%s/TUHKMgen/UHKM/particles.data", gSystem->Getenv("ALICE_ROOT")), 255);
+  strncpy(fDecayFilename, Form("%s/TUHKMgen/UHKM/tabledecay.txt", gSystem->Getenv("ALICE_ROOT")), 255);
   for(Int_t i=0; i<500; i++) {
     fStableFlagPDG[i] = 0;
     fStableFlagStatus[i] = kFALSE;
@@ -211,10 +209,8 @@ AliGenUHKM::AliGenUHKM(Int_t npart)
   fHydjetParams.fIanglu=0;
 */
 
-  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);
+  strncpy(fParticleFilename, Form("%s/TUHKMgen/UHKM/particles.data", gSystem->Getenv("ALICE_ROOT")), 255);
+  strncpy(fDecayFilename, Form("%s/TUHKMgen/UHKM/tabledecay.txt", gSystem->Getenv("ALICE_ROOT")), 255);
   for(Int_t i=0; i<500; i++) {
     fStableFlagPDG[i] = 0;
     fStableFlagStatus[i] = kFALSE;
@@ -503,7 +499,7 @@ void AliGenUHKM::Generate()
   fCollisionGeometry = (AliGenHijingEventHeader*)  header;
 
   delete [] idsOnStack;
-
+  delete [] newPos;
 }
 
 void AliGenUHKM::Copy(TObject &) const
index 79b8661..401f826 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) {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 SetPDGParticleFile(const Char_t *name) {strncpy(fParticleFilename, name, 255);}//Set the filename containing the particle PDG info
+  void SetPDGDecayFile(const Char_t *name) {strncpy(fDecayFilename, name, 255);} //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 2726f7c..bd8ff34 100755 (executable)
@@ -121,10 +121,8 @@ TUHKMgen::TUHKMgen() :
   fHydjetParams.fIanglu=0;  
 */
 
-  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);
+  strncpy(fParticleFilename, Form("%s/TUHKMgen/UHKM/particles.data", gSystem->Getenv("ALICE_ROOT")), 255);
+  strncpy(fDecayFilename, Form("%s/TUHKMgen/UHKM/tabledecay.txt", gSystem->Getenv("ALICE_ROOT")), 255);
   for(Int_t i=0; i<500; i++) {
     fStableFlagPDG[i] = 0;
     fStableFlagStatus[i] = kFALSE;
index 12c2387..0d6405f 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)              {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 SetPDGParticleFile(const Char_t *name)   {strncpy(fParticleFilename, name, 255);}     // Set the filename containing the particle PDG info
+  void SetPDGDecayFile(const Char_t *name) {strncpy(fDecayFilename, name, 255);}        // 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 7270477..c290c6d 100644 (file)
@@ -56,13 +56,11 @@ DatabasePDG::~DatabasePDG() {
 }
 
 void DatabasePDG::SetParticleFilename(Char_t *filename) {
-  if(strlen(filename)<255)
-    strncpy(fParticleFilename, filename, 256);
+  strncpy(fParticleFilename, filename, 255);
 }
 
 void DatabasePDG::SetDecayFilename(Char_t *filename) {
-  if(strlen(filename)<255)
-    strncpy(fDecayFilename, filename, 256);
+  strncpy(fDecayFilename, filename, 255);
 }
 
 Bool_t DatabasePDG::LoadData() {