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