Catch exceptions by const reference
authorPavel Macenauer <pavel.macenauer@linaro.org>
Tue, 26 May 2020 10:54:22 +0000 (10:54 +0000)
committerInki Dae <inki.dae@samsung.com>
Mon, 27 Jul 2020 06:06:43 +0000 (15:06 +0900)
Change-Id: I4b4d8ae419dfb8470e8937e75cd3bab85f03b935
Signed-off-by: Pavel Macenauer <pavel.macenauer@nxp.com>
Back-ported from mainline.
Signed-off-by: Inki Dae <inki.dae@samsung.com>
python/pyarmnn/src/pyarmnn/swig/standard_header.i
src/profiling/test/ProfilingTests.cpp
tests/ModelAccuracyTool-Armnn/ModelAccuracyTool-Armnn.cpp
tests/MultipleNetworksCifar10/MultipleNetworksCifar10.cpp
tests/NetworkExecutionUtils/NetworkExecutionUtils.hpp
tests/TfLiteYoloV3Big-Armnn/TfLiteYoloV3Big-Armnn.cpp

index b26cb0d..a469815 100644 (file)
@@ -23,7 +23,7 @@
 %exception{
     try {
         $action
-    } catch (armnn::Exception &e) {
+    } catch (const armnn::Exception& e) {
         SWIG_exception(SWIG_RuntimeError, const_cast<char*>(e.what()));
     }
 };
@@ -31,7 +31,7 @@
 %exception __getitem__ {
     try {
         $action
-    } catch (armnn::InvalidArgumentException &e) {
+    } catch (const armnn::InvalidArgumentException &e) {
         SWIG_exception(SWIG_ValueError, const_cast<char*>(e.what()));
     } catch (const std::out_of_range &e) {
         SWIG_exception(SWIG_IndexError, const_cast<char*>(e.what()));
@@ -43,7 +43,7 @@
 %exception __setitem__ {
     try {
         $action
-    } catch (armnn::InvalidArgumentException &e) {
+    } catch (const armnn::InvalidArgumentException &e) {
         SWIG_exception(SWIG_ValueError, const_cast<char*>(e.what()));
     } catch (const std::out_of_range &e) {
         SWIG_exception(SWIG_IndexError, const_cast<char*>(e.what()));
index c541c82..e3a49e4 100644 (file)
@@ -2088,7 +2088,7 @@ BOOST_AUTO_TEST_CASE(CheckSocketConnectionException2)
     {
         new SocketProfilingConnection();
     }
-    catch (armnnProfiling::SocketConnectionException& ex)
+    catch (const armnnProfiling::SocketConnectionException& ex)
     {
         BOOST_CHECK(ex.GetSocketFd() == 0);
         BOOST_CHECK(ex.GetErrorNo() == 111);
index 20f6180..85d757f 100644 (file)
@@ -160,7 +160,7 @@ int main(int argc, char* argv[])
         {
             optimizedNet = armnn::Optimize(*network, computeDevice, runtime->GetDeviceSpec());
         }
-        catch (armnn::Exception& e)
+        catch (const armnn::Exception& e)
         {
             std::stringstream message;
             message << "armnn::Exception (" << e.what() << ") caught from optimize.";
@@ -367,7 +367,7 @@ int main(int argc, char* argv[])
         ARMNN_LOG(info) << "Accuracy Tool ran successfully!";
         return 0;
     }
-    catch (armnn::Exception const & e)
+    catch (const armnn::Exception& e)
     {
         // Coverity fix: BOOST_LOG_TRIVIAL (typically used to report errors) may throw an
         // exception of type std::length_error.
@@ -375,7 +375,7 @@ int main(int argc, char* argv[])
         std::cerr << "Armnn Error: " << e.what() << std::endl;
         return 1;
     }
-    catch (const std::exception & e)
+    catch (const std::exception& e)
     {
         // Coverity fix: various boost exceptions can be thrown by methods called by this test.
         std::cerr << "WARNING: ModelAccuracyTool-Armnn: An error has occurred when running the "
index 0e72f7b..c802601 100644 (file)
@@ -137,7 +137,7 @@ int main(int argc, char* argv[])
             {
                 optimizedNet = armnn::Optimize(*network, computeDevice, runtime->GetDeviceSpec());
             }
-            catch (armnn::Exception& e)
+            catch (const armnn::Exception& e)
             {
                 std::stringstream message;
                 message << "armnn::Exception ("<<e.what()<<") caught from optimize.";
@@ -216,7 +216,7 @@ int main(int argc, char* argv[])
         ARMNN_LOG(info) << "Multiple networks inference ran successfully!";
         return 0;
     }
-    catch (armnn::Exception const& e)
+    catch (const armnn::Exception& e)
     {
         // Coverity fix: BOOST_LOG_TRIVIAL (typically used to report errors) may throw an
         // exception of type std::length_error.
index ec0eaf9..ff28eb4 100644 (file)
@@ -519,7 +519,7 @@ int MainImpl(const ExecuteNetworkParams& params,
             }
         }
     }
-    catch (armnn::Exception const& e)
+    catch (const armnn::Exception& e)
     {
         ARMNN_LOG(fatal) << "Armnn Error: " << e.what();
         return EXIT_FAILURE;
index c96d1f2..1905e90 100644 (file)
@@ -28,17 +28,17 @@ static const int LOAD_NETWORK_ERROR = -4;
 static const int LOAD_IMAGE_ERROR = -5;
 static const int GENERAL_ERROR = -100;
 
-#define CHECK_OK(v)                                 \
-    do {                                            \
-        try {                                       \
-            auto r_local = v;                       \
-            if (r_local != 0) { return r_local;}    \
-        }                                           \
-        catch(armnn::Exception e)                                  \
-        { \
-            ARMNN_LOG(error) << "Oops: " << e.what(); \
-            return GENERAL_ERROR; \
-        }                 \
+#define CHECK_OK(v)                                     \
+    do {                                                \
+        try {                                           \
+            auto r_local = v;                           \
+            if (r_local != 0) { return r_local;}        \
+        }                                               \
+        catch (const armnn::Exception& e)               \
+        {                                               \
+            ARMNN_LOG(error) << "Oops: " << e.what();   \
+            return GENERAL_ERROR;                       \
+        }                                               \
     } while(0)