From 40c35b1c830c8c903c0120b074a3b7bc631a9861 Mon Sep 17 00:00:00 2001 From: Tom Joseph Date: Thu, 7 Sep 2017 02:04:42 +0530 Subject: sensor: Handle the response of find_openbmc_path The sensor path of the inventory items does not include the inventory root, so would fail in the case of find_openbmc_path. If the return code of find_openbmc_path indicates failure, then it is logged and allowed to continue. The call to find_openbmc_path would be eventually removed. Change-Id: I7513bf4ab9b897ff5b64cfb77fd504e6ef4e227a Signed-off-by: Tom Joseph --- sensorhandler.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'sensorhandler.cpp') diff --git a/sensorhandler.cpp b/sensorhandler.cpp index 4933afb..1aa5181 100644 --- a/sensorhandler.cpp +++ b/sensorhandler.cpp @@ -477,7 +477,7 @@ ipmi_ret_t ipmi_sen_get_sensor_reading(ipmi_netfn_t netfn, ipmi_cmd_t cmd, { sensor_data_t *reqptr = (sensor_data_t*)request; ipmi_ret_t rc = IPMI_CC_SENSOR_INVALID; - uint8_t type; + uint8_t type = 0; sensorreadingresp_t *resp = (sensorreadingresp_t*) response; int r; dbus_interface_t a; @@ -489,19 +489,22 @@ ipmi_ret_t ipmi_sen_get_sensor_reading(ipmi_netfn_t netfn, ipmi_cmd_t cmd, r = find_openbmc_path(reqptr->sennum, &a); - if (r < 0) { + if (r < 0) + { fprintf(stderr, "Failed to find Sensor 0x%02x\n", reqptr->sennum); - return IPMI_CC_SENSOR_INVALID; } + else + { + type = get_type_from_interface(a); + if(type == 0) { + fprintf(stderr, "Failed to find Sensor 0x%02x\n", reqptr->sennum); + return IPMI_CC_SENSOR_INVALID; + } - type = get_type_from_interface(a); - if(type == 0) { - fprintf(stderr, "Failed to find Sensor 0x%02x\n", reqptr->sennum); - return IPMI_CC_SENSOR_INVALID; + fprintf(stderr, "Bus: %s, Path: %s, Interface: %s\n", a.bus, a.path, + a.interface); } - fprintf(stderr, "Bus: %s, Path: %s, Interface: %s\n", a.bus, a.path, a.interface); - *data_len=0; int64_t raw_value; -- cgit v1.2.1