libopenbmc_intf: fix various warnings

Trying to compile with stricter warnings results in numerous
errors, such as ignored results and unsigned/signed comparisons.
Fix these in libopenbmc_intf.

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Ia0b34fdc27b32675082741a0f3c18f0b538be108
diff --git a/libopenbmc_intf/gpio.c b/libopenbmc_intf/gpio.c
index 0226ced..1785e79 100644
--- a/libopenbmc_intf/gpio.c
+++ b/libopenbmc_intf/gpio.c
@@ -88,6 +88,7 @@
 	struct dirent* entry;
 	while ((entry = readdir(dir)) != NULL)
 	{
+
 		/* Look in the gpiochip<X> directories for a file called 'label' */
 		/* that contains '1e780000.gpio', then in that directory read */
 		/* the GPIO base out of the 'base' file. */
@@ -99,9 +100,14 @@
 
 		gboolean is_bmc = FALSE;
 		char* label_name;
-		asprintf(&label_name, "%s/%s/label",
+		int rc = asprintf(&label_name, "%s/%s/label",
 				GPIO_BASE_PATH, entry->d_name);
 
+		if (!rc)
+		{
+			continue;
+		}
+
 		FILE* fd = fopen(label_name, "r");
 		free(label_name);
 
@@ -126,9 +132,14 @@
 		}
 
 		char* base_name;
-		asprintf(&base_name, "%s/%s/base",
+		rc = asprintf(&base_name, "%s/%s/base",
 				GPIO_BASE_PATH, entry->d_name);
 
+		if (!rc)
+		{
+			continue;
+		}
+
 		fd = fopen(base_name, "r");
 		free(base_name);
 
@@ -291,11 +302,12 @@
 		const cJSON* pin = cJSON_GetObjectItem(def, "pin");
 		g_assert(pin != NULL);
 
-		gpio->num = convert_gpio_to_num(pin->valuestring);
-		if (gpio->num < 0)
+		int pin_id = convert_gpio_to_num(pin->valuestring);
+		if (pin_id < 0)
 		{
 			return GPIO_LOOKUP_ERROR;
 		}
+		gpio->num = (size_t) pin_id;
 	}
 	// TODO: For the purposes of skeleton and the projects that use it,
 	// it should be safe to assume this will always be 0. Eventually skeleton
diff --git a/libopenbmc_intf/gpio_configs.c b/libopenbmc_intf/gpio_configs.c
index 93203c1..3cd56cb 100644
--- a/libopenbmc_intf/gpio_configs.c
+++ b/libopenbmc_intf/gpio_configs.c
@@ -95,7 +95,7 @@
 			g_assert(polarity != NULL);
 			gpios->power_gpio.power_up_pols[i] = polarity->valueint;
 
-			g_print("Power GPIO power_up[%d] = %s active %s\n",
+			g_print("Power GPIO power_up[%zd] = %s active %s\n",
 					i, gpios->power_gpio.power_up_outs[i].name,
 					gpios->power_gpio.power_up_pols[i] ? "HIGH" : "LOW");
 			i++;
@@ -129,7 +129,7 @@
 			g_assert(polarity != NULL);
 			gpios->power_gpio.reset_pols[i] = polarity->valueint;
 
-			g_print("Power GPIO reset[%d] = %s active %s\n", i,
+			g_print("Power GPIO reset[%zd] = %s active %s\n", i,
 					gpios->power_gpio.reset_outs[i].name,
 					gpios->power_gpio.reset_pols[i] ? "HIGH" : "LOW");
 			i++;
@@ -174,7 +174,7 @@
 			g_assert(hold != NULL);
 			gpios->power_gpio.pci_reset_holds[i] = polarity->valueint;
 
-			g_print("Power GPIO pci reset[%d] = %s active %s, hold %s\n", i,
+			g_print("Power GPIO pci reset[%zd] = %s active %s, hold %s\n", i,
 					gpios->power_gpio.pci_reset_outs[i].name,
 					gpios->power_gpio.pci_reset_pols[i] ? "HIGH" : "LOW",
 					gpios->power_gpio.pci_reset_holds[i] ? "Yes" : "No");
@@ -201,7 +201,7 @@
 }
 
 void free_gpios(GpioConfigs *gpios) {
-	int i;
+	size_t i;
 	g_free(gpios->power_gpio.latch_out.name);
 	g_free(gpios->power_gpio.power_good_in.name);
 	for(i = 0; i < gpios->power_gpio.num_power_up_outs; i++) {
diff --git a/libopenbmc_intf/gpio_json.c b/libopenbmc_intf/gpio_json.c
index ae13c90..ec85c16 100644
--- a/libopenbmc_intf/gpio_json.c
+++ b/libopenbmc_intf/gpio_json.c
@@ -29,7 +29,7 @@
 	}
 
 	fseek(fd, 0, SEEK_END);
-	long size = ftell(fd);
+	size_t size = (size_t) ftell(fd);
 	rewind(fd);
 
 	char* data = malloc(size + 1);
@@ -39,7 +39,7 @@
 	if (rc != size)
 	{
 		free(data);
-		fprintf(stderr, "Only read %d out of %ld bytes of GPIO file %s\n",
+		fprintf(stderr, "Only read %zd out of %zd bytes of GPIO file %s\n",
 				rc, size, GPIO_FILE);
 		return NULL;
 	}
diff --git a/libopenbmc_intf/openbmc.h b/libopenbmc_intf/openbmc.h
index fe4deef..ef09f09 100644
--- a/libopenbmc_intf/openbmc.h
+++ b/libopenbmc_intf/openbmc.h
@@ -8,13 +8,13 @@
 #define DBUS_TYPE  G_BUS_TYPE_SYSTEM
 
 // Macros
-#define GET_VARIANT(v)         g_variant_get_variant(v) 
+#define GET_VARIANT(v)         g_variant_get_variant(v)
 #define GET_VARIANT_D(v)       g_variant_get_double(g_variant_get_variant(v))
 #define GET_VARIANT_U(v)       g_variant_get_uint32(g_variant_get_variant(v))
 #define GET_VARIANT_B(v)       g_variant_get_byte(g_variant_get_variant(v))
-#define NEW_VARIANT_D(v)       g_variant_new_variant(g_variant_new_double(v)) 
-#define NEW_VARIANT_U(v)       g_variant_new_variant(g_variant_new_uint32(v)) 
-#define NEW_VARIANT_B(v)       g_variant_new_variant(g_variant_new_byte(v)) 
+#define NEW_VARIANT_D(v)       g_variant_new_variant(g_variant_new_double(v))
+#define NEW_VARIANT_U(v)       g_variant_new_variant(g_variant_new_uint32(v))
+#define NEW_VARIANT_B(v)       g_variant_new_variant(g_variant_new_byte(v))
 #define VARIANT_COMPARE(x,y)   g_variant_compare(GET_VARIANT(x),GET_VARIANT(y))
 
 #ifdef __arm__
@@ -36,11 +36,14 @@
  //       write_reg(reg,val);
 //}
 #else
-static inline uint32_t devmem(uint32_t val, uint32_t reg)
+static inline void devmem(uint32_t val, uint32_t reg)
 {
+	(void) val;
+	(void) reg;
 }
 static inline uint32_t devmem_read(void* addr)
 {
+	(void) addr;
 	return 0;
 }
 
@@ -50,7 +53,7 @@
 	gint argc;
 	gchar **argv;
 	GMainLoop *loop;
-	gpointer user_data;	
+	gpointer user_data;
 
 } cmdline;