catch exceptions as const
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Ia8f2ae95679f98f2fc3f32239bbf3b3578c35888
diff --git a/extensions/phal/create_pel.cpp b/extensions/phal/create_pel.cpp
index c10f32c..b1557e7 100644
--- a/extensions/phal/create_pel.cpp
+++ b/extensions/phal/create_pel.cpp
@@ -80,7 +80,7 @@
throw std::runtime_error(
"Error in invoking D-Bus logging create interface");
}
- catch (std::exception& e)
+ catch (const std::exception& e)
{
throw e;
}
@@ -138,7 +138,7 @@
throw std::runtime_error(
"Error in invoking D-Bus logging create interface");
}
- catch (std::exception& e)
+ catch (const std::exception& e)
{
throw e;
}
@@ -180,7 +180,7 @@
throw std::runtime_error(
"Error in invoking D-Bus logging create interface");
}
- catch (std::exception& e)
+ catch (const std::exception& e)
{
log<level::ERR>(
fmt::format("D-bus call exception", "EXCEPTION={}", e.what())
diff --git a/extensions/phal/devtree_export.cpp b/extensions/phal/devtree_export.cpp
index 922c341..ad21332 100644
--- a/extensions/phal/devtree_export.cpp
+++ b/extensions/phal/devtree_export.cpp
@@ -23,7 +23,7 @@
// Watch for software update
eventRet = event.loop();
}
- catch (std::exception& e)
+ catch (const std::exception& e)
{
using namespace phosphor::logging;
log<level::ERR>(
diff --git a/extensions/phal/fw_update_watch.cpp b/extensions/phal/fw_update_watch.cpp
index 2c6f813..b778734 100644
--- a/extensions/phal/fw_update_watch.cpp
+++ b/extensions/phal/fw_update_watch.cpp
@@ -91,7 +91,7 @@
// Colect device tree data
openpower::phal::fwupdate::exportDevtree();
}
- catch (fs::filesystem_error& e)
+ catch (const fs::filesystem_error& e)
{
log<level::ERR>(
fmt::format("Filesystem error reported Error:({})", e.what())
diff --git a/extensions/phal/phal_error.cpp b/extensions/phal/phal_error.cpp
index d769d11..b6dc1d7 100644
--- a/extensions/phal/phal_error.cpp
+++ b/extensions/phal/phal_error.cpp
@@ -492,7 +492,7 @@
openpower::pel::createBootErrorPEL(pelAdditionalData,
jsonCalloutDataList);
}
- catch (std::exception& ex)
+ catch (const std::exception& ex)
{
reset();
throw ex;
@@ -595,7 +595,7 @@
logLevel = std::stoi(env_p);
}
}
- catch (std::exception& e)
+ catch (const std::exception& e)
{
log<level::ERR>(("Conversion Failure"), entry("ENVIRONMENT=%s", env),
entry("EXCEPTION=%s", e.what()));
diff --git a/proc_control.cpp b/proc_control.cpp
index eca7812..f8b7d09 100644
--- a/proc_control.cpp
+++ b/proc_control.cpp
@@ -70,42 +70,42 @@
{
procedure->second();
}
- catch (file_error::Seek& e)
+ catch (const file_error::Seek& e)
{
commit<file_error::Seek>();
return -1;
}
- catch (file_error::Open& e)
+ catch (const file_error::Open& e)
{
commit<file_error::Open>();
return -1;
}
- catch (device_error::WriteFailure& e)
+ catch (const device_error::WriteFailure& e)
{
commit<device_error::WriteFailure>();
return -1;
}
- catch (device_error::ReadFailure& e)
+ catch (const device_error::ReadFailure& e)
{
commit<device_error::ReadFailure>();
return -1;
}
- catch (common_error::InvalidArgument& e)
+ catch (const common_error::InvalidArgument& e)
{
commit<common_error::InvalidArgument>();
return -1;
}
- catch (fsi_error::MasterDetectionFailure& e)
+ catch (const fsi_error::MasterDetectionFailure& e)
{
commit<fsi_error::MasterDetectionFailure>();
return -1;
}
- catch (fsi_error::SlaveDetectionFailure& e)
+ catch (const fsi_error::SlaveDetectionFailure& e)
{
commit<fsi_error::SlaveDetectionFailure>();
return -1;
}
- catch (std::exception& e)
+ catch (const std::exception& e)
{
log<level::ERR>("exception raised", entry("EXCEPTION=%s", e.what()));
return -1;
diff --git a/procedures/openfsi/scan.cpp b/procedures/openfsi/scan.cpp
index 48e00a3..c7543d1 100644
--- a/procedures/openfsi/scan.cpp
+++ b/procedures/openfsi/scan.cpp
@@ -52,7 +52,7 @@
file.open(path);
file << "1";
}
- catch (std::exception& e)
+ catch (const std::exception& e)
{
auto err = errno;
throw std::system_error(err, std::generic_category());
@@ -78,7 +78,7 @@
{
doScan(masterScanPath);
}
- catch (std::system_error& e)
+ catch (const std::system_error& e)
{
log<level::ERR>("Failed to run the FSI master scan");
@@ -104,7 +104,7 @@
{
doScan(hubScanPath);
}
- catch (std::system_error& e)
+ catch (const std::system_error& e)
{
// If the device driver is ever updated in the future to fail the sysfs
// write call on a scan failure then it should also provide some hints
diff --git a/procedures/p9/cleanup_pcie.cpp b/procedures/p9/cleanup_pcie.cpp
index 316700d..d84b7c9 100644
--- a/procedures/p9/cleanup_pcie.cpp
+++ b/procedures/p9/cleanup_pcie.cpp
@@ -51,7 +51,7 @@
{
writeReg(target, P9_ROOT_CTRL1_CLEAR, 0x00001C00);
}
- catch (std::exception& e)
+ catch (const std::exception& e)
{
// Don't need an error log coming from the power off
// path, just keep trying on the other processors.
@@ -59,7 +59,7 @@
}
}
}
- catch (file_error::Open& e)
+ catch (const file_error::Open& e)
{
// For this procedure we can ignore the ::Open error
}
diff --git a/procedures/phal/check_host_running.cpp b/procedures/phal/check_host_running.cpp
index 2ae3fba..d096193 100644
--- a/procedures/phal/check_host_running.cpp
+++ b/procedures/phal/check_host_running.cpp
@@ -42,7 +42,7 @@
{
phal_init();
}
- catch (std::exception& ex)
+ catch (const std::exception& ex)
{
// This should "never" happen so just throw the exception and let
// our systemd error handling process this
@@ -119,7 +119,7 @@
{
phal_init();
}
- catch (std::exception& ex)
+ catch (const std::exception& ex)
{
// This should "never" happen so just throw the exception and let
// our systemd error handling process this
diff --git a/procedures/phal/import_devtree.cpp b/procedures/phal/import_devtree.cpp
index 6d8adc4..d1cff3e 100644
--- a/procedures/phal/import_devtree.cpp
+++ b/procedures/phal/import_devtree.cpp
@@ -82,7 +82,7 @@
fs::remove_all(path);
}
}
- catch (fs::filesystem_error& e)
+ catch (const fs::filesystem_error& e)
{ // Log message and continue. Data already applied successfully.
log<level::ERR>(fmt::format("File({}) delete failed Error:({})",
DEVTREE_EXP_FILE, e.what())
diff --git a/procedures/phal/start_host.cpp b/procedures/phal/start_host.cpp
index 12eddc3..37a14ef 100644
--- a/procedures/phal/start_host.cpp
+++ b/procedures/phal/start_host.cpp
@@ -179,7 +179,7 @@
phal_init();
ipl_set_type(iplType);
}
- catch (std::exception& ex)
+ catch (const std::exception& ex)
{
log<level::ERR>("Exception raised during init PHAL",
entry("EXCEPTION=%s", ex.what()));
diff --git a/targeting.cpp b/targeting.cpp
index 7b919be..e568bcd 100644
--- a/targeting.cpp
+++ b/targeting.cpp
@@ -92,7 +92,7 @@
}
}
}
- catch (std::filesystem::filesystem_error& e)
+ catch (const std::filesystem::filesystem_error& e)
{
using metadata = xyz::openbmc_project::Common::File::Open;