In AliMUONGeometryModuleTransformer, AliMUONVGeometryBuilder:
authorivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 27 Sep 2010 16:55:27 +0000 (16:55 +0000)
committerivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 27 Sep 2010 16:55:27 +0000 (16:55 +0000)
Fixing NEGATIVE_RETURNS defects reported by Coverity

MUON/AliMUONGeometryModuleTransformer.cxx
MUON/AliMUONVGeometryBuilder.cxx

index 95aec65..2f9bf0f 100644 (file)
@@ -190,7 +190,8 @@ TString AliMUONGeometryModuleTransformer::GetMotherVolumeName() const
   
   std::string volPath = fVolumePath.Data();
   std::string::size_type first = volPath.rfind('/');
-  volPath = volPath.substr(0, first);
+  if ( first != std::string::npos )
+    volPath = volPath.substr(0, first);
 
   std::string::size_type next = volPath.rfind('/')+1;
   std::string::size_type last = volPath.rfind('_');
index 9a4d3dd..1ae1432 100644 (file)
@@ -447,13 +447,17 @@ void  AliMUONVGeometryBuilder::RebuildSVMaps(Bool_t withEnvelopes) const
       if ( ! withEnvelopes && geometry->IsVirtual() ) {
          std::string vName = geometry->GetTransformer()->GetVolumeName().Data();
         std::string vPath = ComposePath(vName, 1).Data();
-        path0.erase(path0.find(vPath), vPath.size());
+         std::string::size_type vPathPos = path0.find(vPath);
+         if ( vPathPos != std::string::npos )
+           path0.erase(vPathPos, vPath.size());
       }  
        
       if ( ! withEnvelopes && envelope->IsVirtual()) {
          std::string eName = envelope->GetName();
         std::string ePath = ComposePath(eName, envelope->GetCopyNo()).Data();
-        path0.erase(path0.find(ePath), ePath.size());
+         std::string::size_type ePathPos = path0.find(ePath);
+         if ( ePathPos != std::string::npos )
+           path0.erase(path0.find(ePath), ePath.size());
       }
 
       if ( ! envelope->IsVirtual() )