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 <tomjoseph@in.ibm.com>
diff --git a/sensorhandler.cpp b/sensorhandler.cpp
index 4933afb..1aa5181 100644
--- a/sensorhandler.cpp
+++ b/sensorhandler.cpp
@@ -477,7 +477,7 @@
 {
     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 @@
 
     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;