fix minor errors and warnings

Signed-off-by: Sanjay Singh Rawat <sanjay.rawat@linaro.org>
diff --git a/gpio.c b/gpio.c
index ea97278..4a42cb7 100644
--- a/gpio.c
+++ b/gpio.c
@@ -323,21 +323,19 @@
 void export_gpios(void)
 {
 	FILE *fgpio, *fgpio_export;
-	int ret = 0, gpio[256], num = 0;
-	char *line;
+	int gpio[256], num = 0;
+	char *line = NULL;
 	ssize_t read, len;
 
 	fgpio = fopen("/sys/kernel/debug/gpio", "r");
 	if (!fgpio) {
 		printf("failed to read debugfs gpio file\n");
-		ret = -1;
 		goto out;
 	}
 
 	fgpio_export = fopen("/sys/class/gpio/export", "w");
 	if (!fgpio_export) {
 		printf("failed to write open gpio-export file\n");
-		ret = -1;
 		goto out;
 	}
 
@@ -364,7 +362,7 @@
 	int ret = 0;
 
 	ret = display_register(GPIO, &gpio_ops);
-	if (!ret)
+	if (ret)
 		printf("error: gpio display register failed");
 
 	if (access(SYSFS_GPIO, F_OK))
diff --git a/regulator.c b/regulator.c
index 27d75b6..0e1c2c6 100644
--- a/regulator.c
+++ b/regulator.c
@@ -28,6 +28,8 @@
 #include <dirent.h>
 #include <string.h>
 #include <stdlib.h>
+#include <unistd.h>
+
 #include "display.h"
 #include "powerdebug.h"
 #include "tree.h"
@@ -265,7 +267,7 @@
 	int ret = 0;
 
 	ret = display_register(REGULATOR, &regulator_ops);
-	if (!ret)
+	if (ret)
 		printf("error: regulator display register failed");
 
 	if (access(SYSFS_REGULATOR, F_OK))
diff --git a/sensor.c b/sensor.c
index bf67277..b8c0452 100644
--- a/sensor.c
+++ b/sensor.c
@@ -21,6 +21,7 @@
 #include <dirent.h>
 #include <string.h>
 #include <stdlib.h>
+#include <unistd.h>
 
 #include "powerdebug.h"
 #include "display.h"
@@ -294,7 +295,7 @@
 	int ret = 0;
 
 	ret = display_register(SENSOR, &sensor_ops);
-	if (!ret)
+	if (ret)
 		printf("error: sensor display register failed");
 
 	if (access(SYSFS_SENSOR, F_OK))