From b07b1e288fe0851a0a924c76f159339a13d4f0f8 Mon Sep 17 00:00:00 2001
From: scott snyder <snyder@bnl.gov>
Date: Sun, 23 Apr 2017 02:55:27 +0200
Subject: [PATCH] MuonReadoutGeometry: Fix more undefined behavior sanitizer
 warnings.

Former-commit-id: 9d7f8df309a871b3caf0d6daa27c5baa2668778b
---
 .../MuonReadoutGeometry/src/MMReadoutElement.cxx             | 5 ++---
 .../MuonReadoutGeometry/src/sTgcReadoutElement.cxx           | 5 ++---
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/src/MMReadoutElement.cxx b/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/src/MMReadoutElement.cxx
index 616182cc737..04654a94c2d 100644
--- a/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/src/MMReadoutElement.cxx
+++ b/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/src/MMReadoutElement.cxx
@@ -16,6 +16,7 @@
 #include "GeoModelKernel/GeoPhysVol.h"
 #include "GeoModelKernel/GeoTrd.h"
 #include "GeoModelKernel/GeoShapeSubtraction.h"
+#include "GeoModelKernel/GeoFullPhysVol.h"
 #include "GaudiKernel/MsgStream.h"
 #include "TrkSurfaces/PlaneSurface.h"
 #include "TrkSurfaces/RectangleBounds.h"
@@ -64,9 +65,7 @@ namespace MuonGM {
     bool foundShape = false;
 
     if (mgr->MinimalGeoFlag() == 0) {
-      GeoPhysVol* pvc = NULL;
-      pvc = (GeoPhysVol*)pv;
-      if (pvc != NULL) {
+      if (GeoFullPhysVol* pvc = dynamic_cast<GeoFullPhysVol*> (pv)) {
 	unsigned int nchildvol = pvc->getNChildVols();
 	int llay = 0;
 	std::string::size_type npos;
diff --git a/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/src/sTgcReadoutElement.cxx b/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/src/sTgcReadoutElement.cxx
index 2dd742acdbb..9f598d4d00e 100644
--- a/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/src/sTgcReadoutElement.cxx
+++ b/MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry/src/sTgcReadoutElement.cxx
@@ -19,6 +19,7 @@
 #include "GeoModelKernel/GeoSimplePolygonBrep.h"
 #include "GeoModelKernel/GeoShapeSubtraction.h"
 #include "GeoModelKernel/GeoShapeShift.h"
+#include "GeoModelKernel/GeoFullPhysVol.h"
 #include "GaudiKernel/MsgStream.h"
 #include "TrkSurfaces/PlaneSurface.h"
 #include "TrkSurfaces/RectangleBounds.h"
@@ -93,9 +94,7 @@ namespace MuonGM {
 
     
     if (mgr->MinimalGeoFlag() == 0) {
-      GeoPhysVol* pvc = NULL;
-      pvc = (GeoPhysVol*)pv;
-      if (pvc != NULL) {
+      if (GeoFullPhysVol* pvc = dynamic_cast<GeoFullPhysVol*> (pv)) {
 	unsigned int nchildvol = pvc->getNChildVols();
 	int llay = 0;
 	std::string::size_type npos;
-- 
GitLab