Fix: test all close/fclose ret val, fix double close
[babeltrace.git] / lib / context.c
index 5c9f4b06401d0dc23592d23c66b8bb3751fcd3f2..a044d1c49f833ff104c51065f8f0e79220d4bd7f 100644 (file)
@@ -67,7 +67,7 @@ int bt_context_add_trace(struct bt_context *ctx, const char *path,
        struct trace_descriptor *td;
        struct format *fmt;
        struct bt_trace_handle *handle;
-       int ret;
+       int ret, closeret;
 
        if (!ctx || !format_name || (!path && !stream_list))
                return -EINVAL;
@@ -137,7 +137,10 @@ int bt_context_add_trace(struct bt_context *ctx, const char *path,
        return handle->id;
 
 error:
-       fmt->close_trace(td);
+       closeret = fmt->close_trace(td);
+       if (closeret) {
+               fprintf(stderr, "Error in close_trace callback\n");
+       }
 end:
        return ret;
 }
@@ -145,6 +148,7 @@ end:
 int bt_context_remove_trace(struct bt_context *ctx, int handle_id)
 {
        struct bt_trace_handle *handle;
+       int ret;
 
        if (!ctx)
                return -EINVAL;
@@ -157,8 +161,11 @@ int bt_context_remove_trace(struct bt_context *ctx, int handle_id)
        /* Remove from containers */
        trace_collection_remove(ctx->tc, handle->td);
        /* Close the trace */
-       handle->format->close_trace(handle->td);
-
+       ret = handle->format->close_trace(handle->td);
+       if (ret) {
+               fprintf(stderr, "Error in close_trace callback\n");
+               return ret;
+       }
        /* Remove and free the handle */
        g_hash_table_remove(ctx->trace_handles,
                        (gpointer) (unsigned long) handle_id);
This page took 0.023419 seconds and 4 git commands to generate.