Merge pull request #45 from shenki/warning-fixes

Warning fixes
diff --git a/Makefile b/Makefile
index 1851c9f..57ad6fe 100644
--- a/Makefile
+++ b/Makefile
@@ -27,6 +27,9 @@
 INSTALLED_LIBS += $(LIB_APP)
 INSTALLED_HEADERS = ipmid-api.h
 
+CXXFLAGS += -Wall -Wno-unused-result
+CFLAGS += -Wall -Wno-unused-result
+
 INC_FLAG += $(shell pkg-config --cflags --libs libsystemd) -I. -O2
 LIB_FLAG += $(shell pkg-config  --libs libsystemd) -rdynamic
 IPMID_PATH ?= -DHOST_IPMI_LIB_PATH=\"/usr/lib/host-ipmid/\"
diff --git a/apphandler.C b/apphandler.C
index d3df330..2c9ce6b 100644
--- a/apphandler.C
+++ b/apphandler.C
@@ -184,8 +184,7 @@
 
         for(i = 0; i < tmp_size; i++)
         {
-            char tmp_array[3]; // Holder of the 2 chars that will become a byte
-            tmp_array[3] = '\0';
+            char tmp_array[3] = {0}; // Holder of the 2 chars that will become a byte
             strncpy(tmp_array, id_octet, 2); // 2 chars at a time
 
             int resp_byte = strtoul(tmp_array, NULL, 16); // Convert to hex byte
diff --git a/host-services.c b/host-services.c
index 89f0b6c..ab9cfcc 100644
--- a/host-services.c
+++ b/host-services.c
@@ -3,6 +3,8 @@
 #include <errno.h>
 #include <systemd/sd-bus.h>
 
+#include "ipmid-api.h"
+
 // OpenBMC Host IPMI dbus framework
 const char  *bus_name      =  "org.openbmc.HostIpmi";
 const char  *object_name   =  "/org/openbmc/HostIpmi/1";
@@ -38,7 +40,7 @@
     sd_bus_error bus_error = SD_BUS_ERROR_NULL;
 
 	// Gets a hook onto either a SYSTEM or SESSION bus
-	sd_bus *bus = (sd_bus *)ipmid_get_sd_bus_connection();
+	sd_bus *bus = ipmid_get_sd_bus_connection();
 
 	rc = sd_bus_call_method(bus,        // On the System Bus
 							bus_name,        // Service to contact
diff --git a/ipmid-api.h b/ipmid-api.h
index 2d58961..4f4b9de 100644
--- a/ipmid-api.h
+++ b/ipmid-api.h
@@ -3,6 +3,10 @@
 #include <stdlib.h>
 #include <systemd/sd-bus.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 // length of Completion Code and its ALWAYS _1_
 #define IPMI_CC_LEN 1
 
@@ -51,9 +55,7 @@
 // This is the constructor function that is called into by each plugin handlers.
 // When ipmi sets up the callback handlers, a call is made to this with
 // information of netfn, cmd, callback handler pointer and context data.
-// Making this a extern "C" so that plugin libraries written in C can also use
-// it.
-extern "C" void ipmi_register_callback(ipmi_netfn_t, ipmi_cmd_t,
+void ipmi_register_callback(ipmi_netfn_t, ipmi_cmd_t,
                                        ipmi_context_t, ipmid_callback_t);
 
 // These are the command network functions, the response
@@ -94,5 +96,10 @@
     IPMI_CC_UNSPECIFIED_ERROR = 0xFF,
 };
 
-extern "C" sd_bus *ipmid_get_sd_bus_connection(void);
+sd_bus *ipmid_get_sd_bus_connection(void);
+
+#ifdef __cplusplus
+}
+#endif
+
 #endif
diff --git a/ipmid.C b/ipmid.C
index 440705c..f1f938c 100644
--- a/ipmid.C
+++ b/ipmid.C
@@ -233,7 +233,6 @@
 static int handle_ipmi_command(sd_bus_message *m, void *user_data, sd_bus_error
                          *ret_error) {
     int r = 0;
-    const char *msg = NULL;
     unsigned char sequence, netfn, lun, cmd;
     const void *request;
     size_t sz;
@@ -375,7 +374,6 @@
 {
     sd_bus_slot *slot = NULL;
     int r;
-    char *mode = NULL;
     unsigned long tvalue;
     int c;
 
@@ -458,7 +456,7 @@
 // step for mapping IPMI
 int find_interface_property_fru_type(dbus_interface_t *interface, const char *property_name, char *property_value) {
 
-    char  *str1, *str2, *str3;
+    char  *str1;
     sd_bus_error error = SD_BUS_ERROR_NULL;
     sd_bus_message *reply = NULL, *m=NULL;
 
@@ -604,7 +602,7 @@
     dbus_interface_t a;
     int r;
     sd_bus_error error = SD_BUS_ERROR_NULL;
-    sd_bus_message *reply = NULL, *m=NULL;
+    sd_bus_message *m=NULL;
 
     fprintf(ipmidbus, "Attempting to set a dbus Variant Sensor 0x%02x via %s with a value of %s\n",
         number, method, value);
diff --git a/sensorhandler.C b/sensorhandler.C
index cd57dd4..dd83152 100644
--- a/sensorhandler.C
+++ b/sensorhandler.C
@@ -145,9 +145,6 @@
 {
     sensor_data_t *reqptr = (sensor_data_t*)request;
     ipmi_ret_t rc = IPMI_CC_OK;
-    unsigned short rlen;
-
-    rlen = (unsigned short) *data_len;
 
     printf("IPMI SET_SENSOR [0x%02x]\n",reqptr->sennum);
 
diff --git a/storageaddsel.C b/storageaddsel.C
index 64b0e6a..345dfd5 100644
--- a/storageaddsel.C
+++ b/storageaddsel.C
@@ -136,7 +136,6 @@
 
 
 	ipmi_add_sel_request_t *p;
-	int r;
 	char *m;
 
 	p =  ( ipmi_add_sel_request_t *) buffer;
@@ -197,7 +196,6 @@
         r = *pty;
     }
 
-finish:
     sd_bus_error_free(&error);
     sd_bus_message_unref(m);
     sd_bus_message_unref(reply);
@@ -207,7 +205,7 @@
 
 
 void send_esel(uint16_t recordid) {
-	char *desc, *assoc, *ascii;
+	char *desc, *assoc;
 	const char *sev;
 	uint8_t *buffer = NULL;
 	char *path, *pathsent;
diff --git a/transporthandler.C b/transporthandler.C
index ca8522d..0f7a730 100644
--- a/transporthandler.C
+++ b/transporthandler.C
@@ -31,8 +31,6 @@
 {
     ipmi_ret_t rc = IPMI_CC_OK;
     *data_len = 0;
-
-    int i = 0;
     char syscmd[128];
 
     printf("IPMI SET_LAN\n");