Fix bt_context_add_traces_recursive error code
authorJulien Desfossez <julien.desfossez@efficios.com>
Fri, 27 Apr 2012 20:02:58 +0000 (16:02 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 27 Apr 2012 20:02:58 +0000 (16:02 -0400)
When an empty directory readable by the user was passed to this
function, the error was not set appropriately, this patch fixes this
problem.

Signed-off-by: Julien Desfossez <julien.desfossez@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
converter/babeltrace.c

index c377935edb4eee708113d50dd86ac5e6c54edb1a..56772674a8d8b629764a5b01e0ccdef49d295ad9 100644 (file)
@@ -355,6 +355,7 @@ int bt_context_add_traces_recursive(struct bt_context *ctx, const char *path,
 
        while ((node = fts_read(tree))) {
                int dirfd, metafd;
+               int closeret;
 
                if (!(node->fts_info & FTS_D))
                        continue;
@@ -368,11 +369,13 @@ int bt_context_add_traces_recursive(struct bt_context *ctx, const char *path,
                }
                metafd = openat(dirfd, "metadata", O_RDONLY);
                if (metafd < 0) {
-                       ret = close(dirfd);
-                       if (ret < 0) {
+                       closeret = close(dirfd);
+                       if (closeret < 0) {
                                perror("close");
                                goto error;
                        }
+                       ret = -1;
+                       continue;
                } else {
                        int trace_id;
 
This page took 0.03412 seconds and 4 git commands to generate.