From: Amit Kucheria <amit.kuche...@linaro.org> Useful for tracking down why the following command fails: sudo ./idlestat -o /tmp/newfile
where, newfile doesn't already exist Signed-off-by: Amit Kucheria <amit.kuche...@linaro.org> --- idlestat.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/idlestat.c b/idlestat.c index 9d88ee9..998f62d 100644 --- a/idlestat.c +++ b/idlestat.c @@ -749,8 +749,10 @@ static struct cpuidle_datas *idlestat_load(const char *path) int ret; f = fopen(path, "r"); - if (!f) - return ptrerror("fopen"); + if (!f) { + fprintf(stderr, "%s: failed to open '%s': %m\n", __func__, path); + return NULL; + } /* version line */ fgets(buffer, BUFSIZE, f); @@ -1055,7 +1057,7 @@ static int idlestat_file_for_each_line(const char *path, void *data, f = fopen(path, "r"); if (!f) { - fprintf(stderr, "failed to open '%s': %m\n", path); + fprintf(stderr, "%s: failed to open '%s': %m\n", __func__, path); return -1; } @@ -1080,8 +1082,9 @@ static int idlestat_store(const char *path) return -1; f = fopen(path, "w+"); + if (!f) { - fprintf(f, "failed to open '%s': %m\n", path); + fprintf(f, "%s: failed to open '%s': %m\n", __func__, path); return -1; } -- 1.9.1 _______________________________________________ linaro-dev mailing list linaro-dev@lists.linaro.org http://lists.linaro.org/mailman/listinfo/linaro-dev