diff mbox

[powerdebug] display proper error message

Message ID 1366019209-18330-1-git-send-email-sanjay.rawat@linaro.org
State New
Headers show

Commit Message

Sanjay Singh Rawat April 15, 2013, 9:46 a.m. UTC
- bug : https://bugs.launchpad.net/linaro-powerdebug/+bug/1014667

Signed-off-by: Sanjay Singh Rawat <sanjay.rawat@linaro.org>
---
 display.c    |    4 +++-
 powerdebug.c |    2 +-
 regulator.c  |    4 +++-
 tree.c       |    4 +++-
 4 files changed, 10 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/display.c b/display.c
index f06387c..39a8e71 100644
--- a/display.c
+++ b/display.c
@@ -593,8 +593,10 @@  int display_register(int win, struct display_ops *ops)
 {
 	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 073fd42..ca04fab 100644
--- a/powerdebug.c
+++ b/powerdebug.c
@@ -243,7 +243,7 @@  int main(int argc, char **argv)
 	}
 
 	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 @@  static int fill_regulator_cb(struct tree *t, void *data)
 	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 @@  static int tree_scan(struct tree *tree, tree_filter_t filter, bool follow)
 	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)) {