summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Venture <venture@google.com>2018-10-13 10:06:13 -0700
committerPatrick Venture <venture@google.com>2018-10-17 22:45:46 +0000
commitd99148b3a0e72775ec217ff4060e3021c50299c3 (patch)
tree56cd6ea977fdc7877d3beaf2c11b4a9e97898b0b
parent4d1a5dd4a55b8886ce8fc7512578ba3438faf386 (diff)
downloadphosphor-host-ipmid-d99148b3a0e72775ec217ff4060e3021c50299c3.zip
phosphor-host-ipmid-d99148b3a0e72775ec217ff4060e3021c50299c3.tar.gz
cleanup: c-style casting
[ipmisensor.cpp:308]: (style) C-style pointer casting [sensorhandler.cpp:302]: (style) C-style pointer casting [sensorhandler.cpp:376]: (style) C-style pointer casting [sensorhandler.cpp:404]: (style) C-style pointer casting [sensorhandler.cpp:405]: (style) C-style pointer casting [storageaddsel.cpp:157]: (style) C-style pointer casting [storageaddsel.cpp:187]: (style) C-style pointer casting Added missing const in reportSensorEventAssert and reportSensorEventDeassert as the *pTable->func(...) take the const pointer and the casting then was using the proper const casting. Change-Id: I54a591b4e5e678b8ec3cae2633617a5f7aac7a66 Signed-off-by: Patrick Venture <venture@google.com>
-rw-r--r--ipmisensor.cpp6
-rw-r--r--sensorhandler.cpp8
-rw-r--r--storageaddsel.cpp7
3 files changed, 9 insertions, 12 deletions
diff --git a/ipmisensor.cpp b/ipmisensor.cpp
index 9e88987..5a629a8 100644
--- a/ipmisensor.cpp
+++ b/ipmisensor.cpp
@@ -249,12 +249,12 @@ lookup_t g_ipmidbuslookup[] = {
{0xCA, 0x01, set_sensor_dbus_state_simple, "setValue", "Enabled", ""},
{0xFF, 0xFF, NULL, "", "", ""}};
-void reportSensorEventAssert(sensorRES_t* pRec, int index)
+void reportSensorEventAssert(const sensorRES_t* pRec, int index)
{
lookup_t* pTable = &g_ipmidbuslookup[index];
(*pTable->func)(pRec, pTable, pTable->assertion);
}
-void reportSensorEventDeassert(sensorRES_t* pRec, int index)
+void reportSensorEventDeassert(const sensorRES_t* pRec, int index)
{
lookup_t* pTable = &g_ipmidbuslookup[index];
(*pTable->func)(pRec, pTable, pTable->deassertion);
@@ -305,7 +305,7 @@ bool shouldReport(uint8_t sensorType, int offset, int* index)
int updateSensorRecordFromSSRAESC(const void* record)
{
- sensorRES_t* pRec = (sensorRES_t*)record;
+ auto pRec = static_cast<const sensorRES_t*>(record);
uint8_t stype;
int index, i = 0;
diff --git a/sensorhandler.cpp b/sensorhandler.cpp
index eafb5d0..bb06b94 100644
--- a/sensorhandler.cpp
+++ b/sensorhandler.cpp
@@ -299,7 +299,7 @@ ipmi_ret_t ipmi_sen_get_sensor_type(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
ipmi_data_len_t data_len,
ipmi_context_t context)
{
- sensor_data_t* reqptr = (sensor_data_t*)request;
+ auto reqptr = static_cast<sensor_data_t*>(request);
ipmi_ret_t rc = IPMI_CC_OK;
printf("IPMI GET_SENSOR_TYPE [0x%02X]\n", reqptr->sennum);
@@ -373,7 +373,7 @@ ipmi_ret_t ipmi_sen_set_sensor(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
ipmi_request_t request, ipmi_response_t response,
ipmi_data_len_t data_len, ipmi_context_t context)
{
- sensor_data_t* reqptr = (sensor_data_t*)request;
+ auto reqptr = static_cast<sensor_data_t*>(request);
log<level::DEBUG>("IPMI SET_SENSOR",
entry("SENSOR_NUM=0x%02x", reqptr->sennum));
@@ -401,8 +401,8 @@ ipmi_ret_t ipmi_sen_get_sensor_reading(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
ipmi_data_len_t data_len,
ipmi_context_t context)
{
- sensor_data_t* reqptr = (sensor_data_t*)request;
- sensorreadingresp_t* resp = (sensorreadingresp_t*)response;
+ auto reqptr = static_cast<sensor_data_t*>(request);
+ auto resp = static_cast<sensorreadingresp_t*>(response);
ipmi::sensor::GetSensorResponse getResponse{};
static constexpr auto scanningEnabledBit = 6;
diff --git a/storageaddsel.cpp b/storageaddsel.cpp
index 8a0dce5..41f813c 100644
--- a/storageaddsel.cpp
+++ b/storageaddsel.cpp
@@ -151,10 +151,9 @@ Entry::Level create_esel_severity(const uint8_t* buffer)
int create_esel_association(const uint8_t* buffer, std::string& inventoryPath)
{
- ipmi_add_sel_request_t* p;
uint8_t sensor;
- p = (ipmi_add_sel_request_t*)buffer;
+ auto p = reinterpret_cast<const ipmi_add_sel_request_t*>(buffer);
sensor = p->sensornumber;
@@ -179,12 +178,10 @@ int create_esel_association(const uint8_t* buffer, std::string& inventoryPath)
int create_esel_description(const uint8_t* buffer, Entry::Level level,
char** message)
{
-
- ipmi_add_sel_request_t* p;
char* m;
int r;
- p = (ipmi_add_sel_request_t*)buffer;
+ auto p = reinterpret_cast<const ipmi_add_sel_request_t*>(buffer);
find_sensor_type_string(p->sensornumber, &m);
OpenPOWER on IntegriCloud