catch exceptions as const
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Ia9932efb6a9335e80b3f2376d2d62e1b65866f44
diff --git a/include/biosxml.hpp b/include/biosxml.hpp
index 39af77c..cfe555b 100644
--- a/include/biosxml.hpp
+++ b/include/biosxml.hpp
@@ -614,7 +614,7 @@
{
value = std::stoi(word);
}
- catch (std::exception& ex)
+ catch (const std::exception& ex)
{
phosphor::logging::log<
phosphor::logging::level::ERR>(ex.what());
@@ -790,7 +790,7 @@
{
currentVal = std::stoi(currentValStr);
}
- catch (std::exception& ex)
+ catch (const std::exception& ex)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
ex.what());
diff --git a/include/sdrutils.hpp b/include/sdrutils.hpp
index 697dad3..e48c628 100644
--- a/include/sdrutils.hpp
+++ b/include/sdrutils.hpp
@@ -265,7 +265,7 @@
auto mapperReply = dbus.call(mapperCall);
mapperReply.read(*sensorTreePtr);
}
- catch (sdbusplus::exception_t& e)
+ catch (const sdbusplus::exception_t& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(e.what());
return sensorUpdatedIndex;
@@ -411,7 +411,7 @@
{
return sensorNumMapPtr->right.at(path);
}
- catch (std::out_of_range& e)
+ catch (const std::out_of_range& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(e.what());
return invalidSensorNumber;
@@ -437,7 +437,7 @@
{
return sensorNumMapPtr->left.at(sensorNum);
}
- catch (std::out_of_range& e)
+ catch (const std::out_of_range& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(e.what());
return std::string();
diff --git a/src/biosconfigcommands.cpp b/src/biosconfigcommands.cpp
index 31c1425..a1ada8e 100644
--- a/src/biosconfigcommands.cpp
+++ b/src/biosconfigcommands.cpp
@@ -203,7 +203,7 @@
"org.freedesktop.DBus.Properties", "Get",
"xyz.openbmc_project.BIOSConfig.Manager", "PendingAttributes");
}
- catch (std::exception& ex)
+ catch (const std::exception& ex)
{
phosphor::logging::log<phosphor::logging::level::ERR>(ex.what());
return false;
@@ -417,7 +417,7 @@
return true;
}
- catch (std::exception& ex)
+ catch (const std::exception& ex)
{
phosphor::logging::log<phosphor::logging::level::ERR>(ex.what());
}
@@ -532,7 +532,7 @@
"Failed to get bios base table");
}
}
- catch (std::exception& ex)
+ catch (const std::exception& ex)
{
phosphor::logging::log<phosphor::logging::level::ERR>(ex.what());
return false;
@@ -645,7 +645,7 @@
{
getChannelInfo(ctx->channel, chInfo);
}
- catch (sdbusplus::exception_t& e)
+ catch (const sdbusplus::exception_t& e)
{
return false;
}
diff --git a/src/bmccontrolservices.cpp b/src/bmccontrolservices.cpp
index 0d2e7a0..a08a270 100644
--- a/src/bmccontrolservices.cpp
+++ b/src/bmccontrolservices.cpp
@@ -157,7 +157,7 @@
}
}
}
- catch (sdbusplus::exception::exception& e)
+ catch (const sdbusplus::exception::exception& e)
{
return ipmi::responseUnspecifiedError();
}
@@ -190,7 +190,7 @@
}
}
}
- catch (sdbusplus::exception::exception& e)
+ catch (const sdbusplus::exception::exception& e)
{
return ipmi::responseUnspecifiedError();
}
diff --git a/src/bridgingcommands.cpp b/src/bridgingcommands.cpp
index 0157f42..916ba15 100644
--- a/src/bridgingcommands.cpp
+++ b/src/bridgingcommands.cpp
@@ -477,7 +477,7 @@
{
getChannelInfo(ctx->channel, chInfo);
}
- catch (sdbusplus::exception_t& e)
+ catch (const sdbusplus::exception_t& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"ipmiAppGetMessage: Failed to get Channel Info",
@@ -544,7 +544,7 @@
{
getChannelInfo(ctx->channel, chInfo);
}
- catch (sdbusplus::exception_t& e)
+ catch (const sdbusplus::exception_t& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"ipmiAppGetMessageFlags: Failed to get Channel Info",
@@ -592,7 +592,7 @@
getMsgFlagsRes.set(getMsgFlagWatchdogPreTimeOutBit);
}
}
- catch (sdbusplus::exception::exception& e)
+ catch (const sdbusplus::exception::exception& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"ipmiAppGetMessageFlags, dbus call exception");
@@ -627,7 +627,7 @@
{
getChannelInfo(ctx->channel, chInfo);
}
- catch (sdbusplus::exception_t& e)
+ catch (const sdbusplus::exception_t& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"ipmiAppClearMessageFlags: Failed to get Channel Info",
@@ -716,7 +716,7 @@
{
getChannelInfo(ctx->channel, chInfo);
}
- catch (sdbusplus::exception_t& e)
+ catch (const sdbusplus::exception_t& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"ipmiAppReadEventMessageBuffer: Failed to get Channel Info",
diff --git a/src/chassiscommands.cpp b/src/chassiscommands.cpp
index 94bd6a3..a6df1ac 100644
--- a/src/chassiscommands.cpp
+++ b/src/chassiscommands.cpp
@@ -101,7 +101,7 @@
getDbusProperty(*bus, service, objName, ledInterface, ledProp);
state = std::get<bool>(enabled);
}
- catch (sdbusplus::exception::exception& e)
+ catch (const sdbusplus::exception::exception& e)
{
log<level::ERR>("Fail to get property", entry("PATH=%s", objName),
entry("ERROR=%s", e.what()));
@@ -339,7 +339,7 @@
*busp, service, buttonPath, buttonIntf, "ButtonMasked");
buttonDisabled = std::get<bool>(disabled);
}
- catch (sdbusplus::exception::exception& e)
+ catch (const sdbusplus::exception::exception& e)
{
log<level::ERR>("Fail to get button disabled property",
entry("PATH=%s", buttonPath.c_str()),
@@ -357,7 +357,7 @@
ipmi::setDbusProperty(*getSdBus(), service, buttonPath, buttonIntf,
"ButtonMasked", disabled);
}
- catch (std::exception& e)
+ catch (const std::exception& e)
{
log<level::ERR>("Failed to set button disabled",
entry("EXCEPTION=%s, REQUEST=%x", e.what(), disabled));
diff --git a/src/firmware-update.cpp b/src/firmware-update.cpp
index 1cd1161..3f17dac 100644
--- a/src/firmware-update.cpp
+++ b/src/firmware-update.cpp
@@ -1550,7 +1550,7 @@
xferHashCheck =
std::make_unique<TransferHashCheck>(*integrityCheckVal);
}
- catch (std::exception& ex)
+ catch (const std::exception& ex)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
ex.what());
diff --git a/src/manufacturingcommands.cpp b/src/manufacturingcommands.cpp
index 2417955..7ed7506 100644
--- a/src/manufacturingcommands.cpp
+++ b/src/manufacturingcommands.cpp
@@ -145,7 +145,7 @@
*getSdBus(), callbackMgrService, callbackMgrObjPath,
callbackMgrIntf, retriggerLedUpdate);
}
- catch (sdbusplus::exception_t& e)
+ catch (const sdbusplus::exception_t& e)
{
return IPMI_CC_UNSPECIFIED_ERROR;
}
diff --git a/src/oemcommands.cpp b/src/oemcommands.cpp
index 89269cd..deecca7 100644
--- a/src/oemcommands.cpp
+++ b/src/oemcommands.cpp
@@ -156,7 +156,7 @@
serial = result;
return 0;
}
- catch (std::bad_variant_access& e)
+ catch (const std::bad_variant_access& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(e.what());
return -1;
@@ -244,7 +244,7 @@
bmcResetDisablesIntf, "ResetOnSMI",
!disableResetOnSMI);
}
- catch (std::exception& e)
+ catch (const std::exception& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"Failed to set BMC reset disables",
@@ -272,7 +272,7 @@
bmcResetDisablesIntf, "ResetOnSMI");
disableResetOnSMI = !std::get<bool>(variant);
}
- catch (std::exception& e)
+ catch (const std::exception& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"Failed to get BMC reset disables",
@@ -412,7 +412,7 @@
(readBuf.begin()));
return ipmi::responseSuccess(readBuf);
}
- catch (std::bad_variant_access& e)
+ catch (const std::bad_variant_access& e)
{
return ipmi::responseUnspecifiedError();
}
@@ -838,7 +838,7 @@
static_cast<uint8_t>(0));
}
}
- catch (std::exception& e)
+ catch (const std::exception& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"Failed to set processor error config",
@@ -903,7 +903,7 @@
// policy is only supported on node 3/4
resp->policySupport = shutdownPolicySupported;
}
- catch (sdbusplus::exception_t& e)
+ catch (const sdbusplus::exception_t& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(e.description());
return IPMI_CC_UNSPECIFIED_ERROR;
@@ -963,7 +963,7 @@
oemShutdownPolicyObjPathProp,
sdbusplus::com::intel::Control::server::convertForMessage(policy));
}
- catch (sdbusplus::exception_t& e)
+ catch (const sdbusplus::exception_t& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(e.description());
return IPMI_CC_UNSPECIFIED_ERROR;
@@ -1001,7 +1001,7 @@
return false;
}
}
- catch (sdbusplus::exception_t& e)
+ catch (const sdbusplus::exception_t& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(e.description());
return true;
@@ -1038,7 +1038,7 @@
return false;
}
}
- catch (sdbusplus::exception_t& e)
+ catch (const sdbusplus::exception_t& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(e.description());
return true;
@@ -1067,7 +1067,7 @@
{
getChannelInfo(channel, chInfo);
}
- catch (sdbusplus::exception_t& e)
+ catch (const sdbusplus::exception_t& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"ipmiOEMSetUser2Activation: Failed to get Channel Info",
@@ -1216,7 +1216,7 @@
{
getChannelInfo(ctx->channel, chInfo);
}
- catch (sdbusplus::exception_t& e)
+ catch (const sdbusplus::exception_t& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"ipmiOEMSetSpecialUserPassword: Failed to get Channel Info",
@@ -1315,7 +1315,7 @@
sdbusplus::xyz::openbmc_project::Led::server::Physical::
convertActionFromString(strState));
}
- catch (sdbusplus::exception::exception& e)
+ catch (const sdbusplus::exception::exception& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(e.what());
return -1;
@@ -1490,7 +1490,7 @@
auto data = bus.call(call);
data.read(resp);
}
- catch (sdbusplus::exception_t& e)
+ catch (const sdbusplus::exception_t& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"getFanProfileInterface: can't get thermal mode!",
@@ -1581,7 +1581,7 @@
setDbusProperty(*dbus, settingsBusName, thermalModePath,
thermalModeInterface, "Current", mode);
}
- catch (sdbusplus::exception_t& e)
+ catch (const sdbusplus::exception_t& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"ipmiOEMSetFanConfig: can't set thermal mode!",
@@ -1672,7 +1672,7 @@
auto reply = dbus->call(method);
reply.read(resp);
}
- catch (sdbusplus::exception_t&)
+ catch (const sdbusplus::exception_t&)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"ipmiOEMGetFscParameter: mapper error");
@@ -1706,7 +1706,7 @@
auto reply = dbus->call(method);
reply.read(resp);
}
- catch (sdbusplus::exception_t&)
+ catch (const sdbusplus::exception_t&)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"getFanConfigPaths: mapper error");
@@ -1724,7 +1724,7 @@
getAllDbusProperties(*dbus, objects[0].first, path,
pidConfigurationIface));
}
- catch (sdbusplus::exception_t& e)
+ catch (const sdbusplus::exception_t& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"getPidConfigs: can't get DbusProperties!",
@@ -1881,7 +1881,7 @@
cfmLimitIface, "Limit",
static_cast<double>(cfm));
}
- catch (sdbusplus::exception_t& e)
+ catch (const sdbusplus::exception_t& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"ipmiOEMSetFscParameter: can't set cfm setting!",
@@ -2070,7 +2070,7 @@
*dbus, "xyz.openbmc_project.ExitAirTempSensor",
"/xyz/openbmc_project/control/MaxCFM", cfmLimitIface, "Limit");
}
- catch (sdbusplus::exception_t& e)
+ catch (const sdbusplus::exception_t& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"ipmiOEMGetFscParameter: can't get cfm setting!",
@@ -2152,7 +2152,7 @@
"/xyz/openbmc_project/control/power_supply_redundancy",
"xyz.openbmc_project.Control.PowerSupplyRedundancy", "PSUNumber");
}
- catch (sdbusplus::exception_t& e)
+ catch (const sdbusplus::exception_t& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"Failed to get PSUNumber property from dbus interface");
@@ -2693,7 +2693,7 @@
: gpiod::line_request::FLAG_ACTIVE_LOW});
line.set_value(ledStateBits[i + group * groupSize]);
}
- catch (std::system_error&)
+ catch (const std::system_error&)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"Error write Led Gpio Device!",
@@ -2736,7 +2736,7 @@
"ProductId");
prodId = static_cast<uint8_t>(std::get<uint64_t>(propValue));
}
- catch (std::exception& e)
+ catch (const std::exception& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"ipmiOEMReadBoardProductId: Product ID read failed!",
@@ -3017,7 +3017,7 @@
return ipmi::responseResponseError();
}
}
- catch (sdbusplus::exception::exception& e)
+ catch (const sdbusplus::exception::exception& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(e.what());
return ipmi::responseResponseError();
@@ -3085,7 +3085,7 @@
static_cast<bool>(true));
}
}
- catch (sdbusplus::exception_t& e)
+ catch (const sdbusplus::exception_t& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(e.what());
return ipmi::responseResponseError();
@@ -3179,7 +3179,7 @@
{
bus->call(call);
}
- catch (sdbusplus::exception_t& e)
+ catch (const sdbusplus::exception_t& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"ipmiOEMSetDimmOffset: can't set dimm offsets!",
@@ -3365,7 +3365,7 @@
return ipmi::responseSuccess(setParmVersion, parameter, oneTime,
bootOption);
}
- catch (sdbusplus::exception_t& e)
+ catch (const sdbusplus::exception_t& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(e.what());
return ipmi::responseResponseError();
@@ -3462,7 +3462,7 @@
setDbusProperty(*dbus, service, bootObjPath, bootSourceIntf,
bootSourceProp, bootSource);
}
- catch (sdbusplus::exception_t& e)
+ catch (const sdbusplus::exception_t& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(e.what());
return ipmi::responseResponseError();
diff --git a/src/sensorcommands.cpp b/src/sensorcommands.cpp
index d605ca5..3927ef2 100644
--- a/src/sensorcommands.cpp
+++ b/src/sensorcommands.cpp
@@ -341,7 +341,7 @@
{
dbus->call(setHealth);
}
- catch (sdbusplus::exception_t&)
+ catch (const sdbusplus::exception_t&)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"Failed to set ME Health");
@@ -854,7 +854,7 @@
{
thresholdData = getIPMIThresholds(sensorMap);
}
- catch (std::exception&)
+ catch (const std::exception&)
{
return ipmi::responseResponseError();
}
@@ -1447,7 +1447,7 @@
{
thresholdData = getIPMIThresholds(sensorMap);
}
- catch (std::exception&)
+ catch (const std::exception&)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"getSensorDataRecord: getIPMIThresholds error");
diff --git a/src/smbiosmdrv2handler.cpp b/src/smbiosmdrv2handler.cpp
index 55cd79a..e782d7c 100644
--- a/src/smbiosmdrv2handler.cpp
+++ b/src/smbiosmdrv2handler.cpp
@@ -75,7 +75,7 @@
sdbusplus::message::message reply = bus->call(method);
reply.read(value);
}
- catch (sdbusplus::exception_t& e)
+ catch (const sdbusplus::exception_t& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"Error get property, sdbusplus call failed",
@@ -101,7 +101,7 @@
sdbusplus::message::message reply = bus->call(method);
reply.read(commonData);
}
- catch (sdbusplus::exception_t& e)
+ catch (const sdbusplus::exception_t& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"Error sync dir common data with service",
@@ -147,7 +147,7 @@
sdbusplus::message::message reply = bus->call(method);
reply.read(idIndex);
}
- catch (sdbusplus::exception_t& e)
+ catch (const sdbusplus::exception_t& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"Error find id index",
@@ -320,7 +320,7 @@
sdbusplus::message::message reply = bus->call(method);
reply.read(dataOut);
}
- catch (sdbusplus::exception_t& e)
+ catch (const sdbusplus::exception_t& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"Error get dir", phosphor::logging::entry("ERROR=%s", e.what()),
@@ -407,7 +407,7 @@
sdbusplus::message::message reply = bus->call(method);
reply.read(terminate);
}
- catch (sdbusplus::exception_t& e)
+ catch (const sdbusplus::exception_t& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"Error send dir", phosphor::logging::entry("ERROR=%s", e.what()),
@@ -473,7 +473,7 @@
sdbusplus::message::message reply = bus->call(method);
reply.read(res);
}
- catch (sdbusplus::exception_t& e)
+ catch (const sdbusplus::exception_t& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"Error get data info",
@@ -526,7 +526,7 @@
sdbusplus::message::message reply = bus->call(method);
reply.read(dataOut);
}
- catch (sdbusplus::exception_t& e)
+ catch (const sdbusplus::exception_t& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"Error send data info offer",
@@ -607,7 +607,7 @@
sdbusplus::message::message reply = bus->call(method);
reply.read(entryChanged);
}
- catch (sdbusplus::exception_t& e)
+ catch (const sdbusplus::exception_t& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"Error send data info",
@@ -827,7 +827,7 @@
sizeof(MDRSMBIOSHeader));
smbiosFile.write(reinterpret_cast<char*>(data), mdrHdr->dataSize);
}
- catch (std::ofstream::failure& e)
+ catch (const std::ofstream::failure& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"Write data from flash error - write data error",
@@ -1244,7 +1244,7 @@
sdbusplus::message::message reply = bus->call(method);
reply.read(status);
}
- catch (sdbusplus::exception_t& e)
+ catch (const sdbusplus::exception_t& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"Error Sync data with service",
diff --git a/src/storagecommands.cpp b/src/storagecommands.cpp
index e9dc344..de57901 100644
--- a/src/storagecommands.cpp
+++ b/src/storagecommands.cpp
@@ -143,7 +143,7 @@
{
sdbusplus::message::message writeFruResp = dbus->call(writeFru);
}
- catch (sdbusplus::exception_t&)
+ catch (const sdbusplus::exception_t&)
{
// todo: log sel?
phosphor::logging::log<phosphor::logging::level::ERR>(
@@ -315,7 +315,7 @@
{
message.read(path, object);
}
- catch (sdbusplus::exception_t&)
+ catch (const sdbusplus::exception_t&)
{
return;
}
@@ -341,7 +341,7 @@
{
message.read(path, interfaces);
}
- catch (sdbusplus::exception_t&)
+ catch (const sdbusplus::exception_t&)
{
return;
}
@@ -838,12 +838,12 @@
data.push_back(static_cast<uint8_t>(
std::stoul(hexStr.substr(i, 2), nullptr, 16)));
}
- catch (std::invalid_argument& e)
+ catch (const std::invalid_argument& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(e.what());
return -1;
}
- catch (std::out_of_range& e)
+ catch (const std::out_of_range& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(e.what());
return -1;
@@ -1188,7 +1188,7 @@
{
sdbusplus::message::message reloadResponse = dbus->call(rsyslogReload);
}
- catch (sdbusplus::exception_t& e)
+ catch (const sdbusplus::exception_t& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(e.what());
}