display proper error message
- bug : https://bugs.launchpad.net/linaro-powerdebug/+bug/1014667
Signed-off-by: Sanjay Singh Rawat <sanjay.rawat@linaro.org>
diff --git a/display.c b/display.c
index 94ff2de..e9f4bf6 100644
--- a/display.c
+++ b/display.c
@@ -598,8 +598,10 @@
{
size_t array_size = sizeof(windata) / sizeof(windata[0]);
- if (win < 0 || win >= array_size)
+ if (win < 0 || win >= array_size) {
+ printf("error: invalid window");
return -1;
+ }
windata[win].ops = ops;
diff --git a/powerdebug.c b/powerdebug.c
index 098c5da..6cf3a1b 100644
--- a/powerdebug.c
+++ b/powerdebug.c
@@ -247,7 +247,7 @@
}
if (regulator_init()) {
- printf("not enough memory to allocate regulators info\n");
+ printf("failed to initialize regulator\n");
options->regulators = false;
}
diff --git a/regulator.c b/regulator.c
index 0da924a..68c686f 100644
--- a/regulator.c
+++ b/regulator.c
@@ -218,8 +218,10 @@
struct regulator_info *reg;
reg = regulator_alloc();
- if (!reg)
+ if (!reg) {
+ printf("error: unable to allocate memory for regulator\n");
return -1;
+ }
t->private = reg;
/* we skip the root node but we set it expanded for its children */
diff --git a/tree.c b/tree.c
index d331c60..686e846 100644
--- a/tree.c
+++ b/tree.c
@@ -121,8 +121,10 @@
int ret = 0;
dir = opendir(tree->path);
- if (!dir)
+ if (!dir) {
+ printf("error: unable to open directory %s\n", tree->path);
return -1;
+ }
while (!readdir_r(dir, &dirent, &direntp)) {