_Possible_ bugs revealed by cppcheck scan.
Scanning the code with cppcheck 2.17, there are many performance or small issues. A few stand out as possible actual bugs, and I report them here:
- Using pointer to local variable that is out of scope
GeoModelG4/GeoModel2G4/original_GeoModel2G4/src/Geo2G4Builder.cxx:117:60: error: Using pointer to local variable 'shNext' that is out of scope. [invalidLifetime]
GeoLogVol* lvEnvelope = new GeoLogVol(m_detectorName,shResult,m_matAir);
^
GeoModelG4/GeoModel2G4/original_GeoModel2G4/src/Geo2G4Builder.cxx:113:32: note: Assigned to reference.
const GeoShape& shNext = (*shResult).add((*(m_treeTops[i]->getLogVol()->getShape()))<<(m_treeTops[i]->getX()));
^
GeoModelG4/GeoModel2G4/original_GeoModel2G4/src/Geo2G4Builder.cxx:114:20: note: Address of variable taken here.
shResult = &shNext;
^
GeoModelG4/GeoModel2G4/original_GeoModel2G4/src/Geo2G4Builder.cxx:112:30: note: Assuming condition is false
for(unsigned int i=1; i<m_treeTops.size(); i++){
^
GeoModelG4/GeoModel2G4/original_GeoModel2G4/src/Geo2G4Builder.cxx:113:25: note: Variable created here.
const GeoShape& shNext = (*shResult).add((*(m_treeTops[i]->getLogVol()->getShape()))<<(m_treeTops[i]->getX()));
^
GeoModelG4/GeoModel2G4/original_GeoModel2G4/src/Geo2G4Builder.cxx:117:60: note: Using pointer to local variable 'shNext' that is out of scope.
GeoLogVol* lvEnvelope = new GeoLogVol(m_detectorName,shResult,m_matAir);
- Possible ineffective lock
GeoModelIO/GeoModelDBManager/src/GMDBManager.cpp:512:9: warning: The lock is ineffective because the mutex is locked at the same scope as the mutex itself. [localMutex]
coutMutex.lock();
^
GeoModelIO/GeoModelDBManager/src/GMDBManager.cpp:546:13: warning: The lock is ineffective because the mutex is locked at the same scope as the mutex itself. [localMutex]
coutMutex.lock();
^
GeoModelIO/GeoModelDBManager/src/GMDBManager.cpp:573:9: warning: The lock is ineffective because the mutex is locked at the same scope as the mutex itself. [localMutex]
coutMutex.lock();
^
GeoModelIO/GeoModelDBManager/src/GMDBManager.cpp:603:9: warning: The lock is ineffective because the mutex is locked at the same scope as the mutex itself. [localMutex]
coutMutex.lock();
^
GeoModelIO/GeoModelDBManager/src/GMDBManager.cpp:1123:13: warning: The lock is ineffective because the mutex is locked at the same scope as the mutex itself. [localMutex]
coutMutex.lock();
^
- Logic condition always evaluates to 'false'
GeoModelCore/GeoModelKernel/src/GeoDiamondSurface.cxx:30:33: warning: Logical conjunction always evaluates to false: Pp_z > 1e-5 && Pp_z < -1e-5. [incorrectLogicOperator]
if(Pp_z != 0 && Pp_z > 1e-5 && Pp_z < -1e-5){
^
GeoModelCore/GeoModelKernel/src/GeoTrapezoidSurface.cxx:28:33: warning: Logical conjunction always evaluates to false: Pp_z > 1e-5 && Pp_z < -1e-5. [incorrectLogicOperator]
if(Pp_z != 0 && Pp_z > 1e-5 && Pp_z < -1e-5){