From 4c76b0e521ae3040c0e2c7f17cb743d05a7032e7 Mon Sep 17 00:00:00 2001
From: Markus Frank <Markus.Frank@cern.ch>
Date: Wed, 25 Jan 2017 21:01:15 +0100
Subject: [PATCH] Fix various warnings from coverty

---
 DDG4/include/DDG4/Geant4GeneratorAction.h | 14 +++++++-------
 DDG4/include/DDG4/Geant4SteppingAction.h  |  8 ++++++--
 DDG4/include/DDG4/Geant4TrackingAction.h  | 15 ++++++++-------
 DDG4/src/Geant4ParticlePrint.cpp          |  2 +-
 UtilityApps/src/dumpdetector.cpp          | 16 +++++++++++++---
 UtilityApps/src/run_plugin.h              | 16 +++++++++++++++-
 6 files changed, 50 insertions(+), 21 deletions(-)

diff --git a/DDG4/include/DDG4/Geant4GeneratorAction.h b/DDG4/include/DDG4/Geant4GeneratorAction.h
index f1f5749dc..1da6ea268 100644
--- a/DDG4/include/DDG4/Geant4GeneratorAction.h
+++ b/DDG4/include/DDG4/Geant4GeneratorAction.h
@@ -51,8 +51,8 @@ namespace DD4hep {
     protected:
       Callback m_calls;
     public:
-      /// Inhibit default constructor
-      Geant4GeneratorAction() = delete;
+      /// Default constructor
+      Geant4GeneratorAction() = default;
       /// Standard constructor
       Geant4GeneratorAction(Geant4Context* context, const std::string& name);
       /// Default destructor
@@ -78,10 +78,10 @@ namespace DD4hep {
     class Geant4SharedGeneratorAction : public Geant4GeneratorAction {
     protected:
       /// Reference to the shared action
-      Geant4GeneratorAction* m_action;
+      Geant4GeneratorAction* m_action = 0;
     public:
-      /// Inhibit default constructor
-      Geant4SharedGeneratorAction() = delete;
+      /// Default constructor
+      Geant4SharedGeneratorAction() = default;
       /// Standard constructor
       Geant4SharedGeneratorAction(Geant4Context* context, const std::string& nam);
       /// Default destructor
@@ -118,8 +118,8 @@ namespace DD4hep {
       /// The list of action objects to be called
       Actors<Geant4GeneratorAction> m_actors;
     public:
-      /// Inhibit default constructor
-      Geant4GeneratorActionSequence() = delete;
+      /// Default constructor
+      Geant4GeneratorActionSequence() = default;
       /// Standard constructor
       Geant4GeneratorActionSequence(Geant4Context* context, const std::string& name);
       /// Default destructor
diff --git a/DDG4/include/DDG4/Geant4SteppingAction.h b/DDG4/include/DDG4/Geant4SteppingAction.h
index d4e7ecf1d..1da17bd59 100644
--- a/DDG4/include/DDG4/Geant4SteppingAction.h
+++ b/DDG4/include/DDG4/Geant4SteppingAction.h
@@ -41,8 +41,10 @@ namespace DD4hep {
     public:
       typedef Geant4SharedSteppingAction shared_type;
     public:
+      /// Default constructor
+      Geant4SteppingAction() = default;
       /// Inhibit copy constructor
-      Geant4SteppingAction(const Geant4SteppingAction& copy) = delete;
+      Geant4SteppingAction(const Geant4SteppingAction& copy) = default;
       /// Standard constructor
       Geant4SteppingAction(Geant4Context* context, const std::string& name);
       /// Default destructor
@@ -67,8 +69,10 @@ namespace DD4hep {
     class Geant4SharedSteppingAction : public Geant4SteppingAction {
     protected:
       /// Reference to the shared action
-      Geant4SteppingAction* m_action;
+      Geant4SteppingAction* m_action = 0;
     public:
+      /// Default constructor
+      Geant4SharedSteppingAction() = default;
       /// Inhibit copy constructor
       Geant4SharedSteppingAction(const Geant4SteppingAction& copy) = delete;
       /// Standard constructor
diff --git a/DDG4/include/DDG4/Geant4TrackingAction.h b/DDG4/include/DDG4/Geant4TrackingAction.h
index e6f2da7ef..26fba8875 100644
--- a/DDG4/include/DDG4/Geant4TrackingAction.h
+++ b/DDG4/include/DDG4/Geant4TrackingAction.h
@@ -43,8 +43,8 @@ namespace DD4hep {
     public:
       typedef Geant4SharedTrackingAction shared_type;
     public:
-      /// Inhibit default constructor
-      Geant4TrackingAction() = delete;
+      /// Default constructor
+      Geant4TrackingAction() = default;
       /// Inhibit copy constructor
       Geant4TrackingAction(const Geant4TrackingAction& copy) = delete;
       /// Standard constructor
@@ -79,10 +79,11 @@ namespace DD4hep {
     class Geant4SharedTrackingAction : public Geant4TrackingAction {
     protected:
       /// Reference to the shared action
-      Geant4TrackingAction* m_action;
+      Geant4TrackingAction* m_action = 0;
+
     public:
-      /// Inhibit default constructor
-      Geant4SharedTrackingAction() = delete;
+      /// Default constructor
+      Geant4SharedTrackingAction() = default;
       /// Inhibit copy constructor
       Geant4SharedTrackingAction(const Geant4TrackingAction& copy) = delete;
       /// Standard constructor
@@ -127,8 +128,8 @@ namespace DD4hep {
       /// The list of action objects to be called
       Actors<Geant4TrackingAction> m_actors;
     public:
-      /// Inhibit default constructor
-      Geant4TrackingActionSequence() = delete;
+      /// Default constructor
+      Geant4TrackingActionSequence() = default;
       /// Inhibit copy constructor
       Geant4TrackingActionSequence(const Geant4TrackingActionSequence& copy) = delete;
       /// Standard constructor
diff --git a/DDG4/src/Geant4ParticlePrint.cpp b/DDG4/src/Geant4ParticlePrint.cpp
index 73a5d6ece..04e7d7116 100644
--- a/DDG4/src/Geant4ParticlePrint.cpp
+++ b/DDG4/src/Geant4ParticlePrint.cpp
@@ -149,7 +149,7 @@ void Geant4ParticlePrint::printParticle(const std::string& prefix, const G4Event
       }
       else  {
         print("+++ Hit unknown hit collection type: %s --> %s",
-              c->GetName(),typeName(typeid(*c)).c_str());
+              c->GetName().c_str(),typeName(typeid(*c)).c_str());
       }
     }
   }
diff --git a/UtilityApps/src/dumpdetector.cpp b/UtilityApps/src/dumpdetector.cpp
index de5e1785b..4ed85de76 100644
--- a/UtilityApps/src/dumpdetector.cpp
+++ b/UtilityApps/src/dumpdetector.cpp
@@ -76,7 +76,7 @@ void printDetectorSets( std::string name, unsigned int includeFlag,  unsigned in
 
 //=============================================================================
 
-int main(int argc, char** argv ){
+int run_main(int argc, char** argv ){
     
   if( argc < 2 ) {
     std::cout << " usage: dumpdetector compact.xml [-s]" 
@@ -231,7 +231,17 @@ int main(int argc, char** argv ){
 }
 
 
-
-
+int main(int argc, char** argv ){
+  try {
+    return run_main(argc,argv);
+  }
+  catch(const std::exception& e)  {
+    std::cout << "Got uncaught exception: " << e.what() << std::endl;
+  }
+  catch (...)  {
+    std::cout << "Got UNKNOWN uncaught exception." << std::endl;
+  }
+  return EINVAL;    
+}
 
 //=============================================================================
diff --git a/UtilityApps/src/run_plugin.h b/UtilityApps/src/run_plugin.h
index 50684eacf..cfe5ddea8 100644
--- a/UtilityApps/src/run_plugin.h
+++ b/UtilityApps/src/run_plugin.h
@@ -247,7 +247,7 @@ namespace {
   }
 
   //______________________________________________________________________________
-  int main_default(const char* name, int argc,char** argv)  {
+  int main_wrapper(const char* name, int argc, char** argv)  {
     Args args;
     for(int i=1; i<argc;++i) {
       if ( argv[i][0]=='-' ) {
@@ -290,4 +290,18 @@ namespace {
     if ( args.destroy ) delete &lcdd;
     return 0;
   }
+
+  //______________________________________________________________________________
+  int main_default(const char* name, int argc, char** argv)  {
+    try {
+      return main_wrapper(name,argc,argv);
+    }
+    catch(const std::exception& e)  {
+      std::cout << "Got uncaught exception: " << e.what() << std::endl;
+    }
+    catch (...)  {
+      std::cout << "Got UNKNOWN uncaught exception." << std::endl;
+    }
+    return EINVAL;    
+  }
 }
-- 
GitLab