catch exceptions as const
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: If6aba71f482f75143e6d669763b8853db22318cf
diff --git a/phosphor-power-supply/power_supply.cpp b/phosphor-power-supply/power_supply.cpp
index ed1f9af..96dfaa0 100644
--- a/phosphor-power-supply/power_supply.cpp
+++ b/phosphor-power-supply/power_supply.cpp
@@ -114,7 +114,7 @@
file << bindDevice;
file.close();
}
- catch (std::exception& e)
+ catch (const std::exception& e)
{
auto err = errno;
@@ -156,7 +156,7 @@
present = false;
}
}
- catch (std::exception& e)
+ catch (const std::exception& e)
{
log<level::ERR>(
fmt::format("presenceGPIO read fail: {}", e.what()).c_str());
@@ -261,7 +261,7 @@
vinUVFault = false;
}
}
- catch (ReadFailure& e)
+ catch (const ReadFailure& e)
{
readFail++;
phosphor::logging::commit<ReadFailure>();
@@ -316,7 +316,7 @@
static_cast<void>(
pmbusIntf->read("in1_input", phosphor::pmbus::Type::Hwmon));
}
- catch (ReadFailure& e)
+ catch (const ReadFailure& e)
{
// Since I do not care what the return value is, I really do not
// care much if it gets a ReadFailure either. However, this
@@ -426,7 +426,7 @@
assetProps.emplace(MODEL_PROP, ccin);
modelName = ccin;
}
- catch (ReadFailure& e)
+ catch (const ReadFailure& e)
{
// Ignore the read failure, let pmbus code indicate failure,
// path...
@@ -441,7 +441,7 @@
pn = pmbusIntf->readString(PART_NUMBER, Type::HwmonDeviceDebug);
assetProps.emplace(PN_PROP, pn);
}
- catch (ReadFailure& e)
+ catch (const ReadFailure& e)
{
// Ignore the read failure, let pmbus code indicate failure,
// path...
@@ -451,7 +451,7 @@
{
fn = pmbusIntf->readString(FRU_NUMBER, Type::HwmonDeviceDebug);
}
- catch (ReadFailure& e)
+ catch (const ReadFailure& e)
{
// Ignore the read failure, let pmbus code indicate failure,
// path...
@@ -464,7 +464,7 @@
sn = pmbusIntf->readString(SERIAL_NUMBER, Type::HwmonDeviceDebug);
assetProps.emplace(SN_PROP, sn);
}
- catch (ReadFailure& e)
+ catch (const ReadFailure& e)
{
// Ignore the read failure, let pmbus code indicate failure,
// path...
@@ -476,7 +476,7 @@
pmbusIntf->readString(FW_VERSION, Type::HwmonDeviceDebug);
versionProps.emplace(VERSION_PROP, fwVersion);
}
- catch (ReadFailure& e)
+ catch (const ReadFailure& e)
{
// Ignore the read failure, let pmbus code indicate failure,
// path...
@@ -541,7 +541,7 @@
auto reply = bus.call(method);
}
- catch (std::exception& e)
+ catch (const std::exception& e)
{
log<level::ERR>(
std::string(e.what() + std::string(" PATH=") + inventoryPath)
diff --git a/phosphor-power-supply/psu_manager.cpp b/phosphor-power-supply/psu_manager.cpp
index 603c0ef..ee21a81 100644
--- a/phosphor-power-supply/psu_manager.cpp
+++ b/phosphor-power-supply/psu_manager.cpp
@@ -125,7 +125,7 @@
std::get_if<std::string>(&properties[presLineName]);
}
}
- catch (std::exception& e)
+ catch (const std::exception& e)
{}
}
@@ -221,7 +221,7 @@
supportedConfigs.emplace(*model, sys);
}
- catch (std::exception& e)
+ catch (const std::exception& e)
{}
}
@@ -249,7 +249,7 @@
populateSysProperties(properties);
}
}
- catch (std::exception& e)
+ catch (const std::exception& e)
{
// Interface or property not found. Let the Interfaces Added callback
// process the information once the interfaces are added to D-Bus.
@@ -288,7 +288,7 @@
validateConfig();
}
}
- catch (std::exception& e)
+ catch (const std::exception& e)
{
// Ignore, the property may be of a different type than expected.
}
@@ -350,7 +350,7 @@
auto reply = bus.call(method);
}
- catch (std::exception& e)
+ catch (const std::exception& e)
{
log<level::ERR>(
fmt::format(
diff --git a/phosphor-power-supply/psu_manager.hpp b/phosphor-power-supply/psu_manager.hpp
index 68dd091..d95caa3 100644
--- a/phosphor-power-supply/psu_manager.hpp
+++ b/phosphor-power-supply/psu_manager.hpp
@@ -92,7 +92,7 @@
runValidateConfig = true;
}
}
- catch (std::exception& e)
+ catch (const std::exception& e)
{
log<level::INFO>("Failed to get power state. Assuming it is off.");
powerOn = false;
diff --git a/phosphor-power-supply/util.cpp b/phosphor-power-supply/util.cpp
index 73f86e0..858d1a3 100644
--- a/phosphor-power-supply/util.cpp
+++ b/phosphor-power-supply/util.cpp
@@ -21,7 +21,7 @@
throw std::runtime_error("Line does not exist: " + namedGpio);
}
}
- catch (std::exception& e)
+ catch (const std::exception& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
fmt::format("Failed to find line: {}", e.what()).c_str());
@@ -60,7 +60,7 @@
{
value = line.get_value();
}
- catch (std::exception& e)
+ catch (const std::exception& e)
{
log<level::ERR>(
fmt::format("Failed to get_value of GPIO line: {}", e.what())
@@ -71,7 +71,7 @@
line.release();
}
- catch (std::exception& e)
+ catch (const std::exception& e)
{
log<level::ERR>("Failed to request GPIO line",
entry("MSG=%s", e.what()));