From 633f559b23e583b8840c4867f5c35b515a0298c0 Mon Sep 17 00:00:00 2001 From: Pavel Macenauer Date: Tue, 26 May 2020 10:54:22 +0000 Subject: [PATCH] Catch exceptions by const reference Change-Id: I4b4d8ae419dfb8470e8937e75cd3bab85f03b935 Signed-off-by: Pavel Macenauer Back-ported from mainline. Signed-off-by: Inki Dae --- python/pyarmnn/src/pyarmnn/swig/standard_header.i | 6 +++--- src/profiling/test/ProfilingTests.cpp | 2 +- .../ModelAccuracyTool-Armnn.cpp | 6 +++--- .../MultipleNetworksCifar10.cpp | 4 ++-- .../NetworkExecutionUtils.hpp | 2 +- .../TfLiteYoloV3Big-Armnn.cpp | 22 +++++++++++----------- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/python/pyarmnn/src/pyarmnn/swig/standard_header.i b/python/pyarmnn/src/pyarmnn/swig/standard_header.i index b26cb0d..a469815 100644 --- a/python/pyarmnn/src/pyarmnn/swig/standard_header.i +++ b/python/pyarmnn/src/pyarmnn/swig/standard_header.i @@ -23,7 +23,7 @@ %exception{ try { $action - } catch (armnn::Exception &e) { + } catch (const armnn::Exception& e) { SWIG_exception(SWIG_RuntimeError, const_cast(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(e.what())); } catch (const std::out_of_range &e) { SWIG_exception(SWIG_IndexError, const_cast(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(e.what())); } catch (const std::out_of_range &e) { SWIG_exception(SWIG_IndexError, const_cast(e.what())); diff --git a/src/profiling/test/ProfilingTests.cpp b/src/profiling/test/ProfilingTests.cpp index c541c82..e3a49e4 100644 --- a/src/profiling/test/ProfilingTests.cpp +++ b/src/profiling/test/ProfilingTests.cpp @@ -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); diff --git a/tests/ModelAccuracyTool-Armnn/ModelAccuracyTool-Armnn.cpp b/tests/ModelAccuracyTool-Armnn/ModelAccuracyTool-Armnn.cpp index 20f6180..85d757f 100644 --- a/tests/ModelAccuracyTool-Armnn/ModelAccuracyTool-Armnn.cpp +++ b/tests/ModelAccuracyTool-Armnn/ModelAccuracyTool-Armnn.cpp @@ -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 " diff --git a/tests/MultipleNetworksCifar10/MultipleNetworksCifar10.cpp b/tests/MultipleNetworksCifar10/MultipleNetworksCifar10.cpp index 0e72f7b..c802601 100644 --- a/tests/MultipleNetworksCifar10/MultipleNetworksCifar10.cpp +++ b/tests/MultipleNetworksCifar10/MultipleNetworksCifar10.cpp @@ -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 ("<