Cleanup: update ifdef wrapper name
[babeltrace.git] / lib / trace-collection.c
index 0ee3c29f08fcb81ad213f4a349e3d4ec18196ce9..9bc5b1fcc8b0ecc543dd65b7a67734f4c44c8968 100644 (file)
@@ -132,13 +132,18 @@ static void clock_add(gpointer key, gpointer value, gpointer user_data)
 
 /*
  * Whenever we add a trace to the trace collection, check that we can
 
 /*
  * Whenever we add a trace to the trace collection, check that we can
- * correlate this trace with at least one other clock in the trace.
+ * correlate this trace with at least one other clock in the trace and
+ * convert the index from cycles to real time.
  */
 int trace_collection_add(struct trace_collection *tc,
                                struct trace_descriptor *td)
 {
  */
 int trace_collection_add(struct trace_collection *tc,
                                struct trace_descriptor *td)
 {
-       struct ctf_trace *trace = container_of(td, struct ctf_trace, parent);
+       struct ctf_trace *trace;
 
 
+       if (!tc || !td)
+               return -EINVAL;
+
+       trace = container_of(td, struct ctf_trace, parent);
        g_ptr_array_add(tc->array, td);
        trace->collection = tc;
 
        g_ptr_array_add(tc->array, td);
        trace->collection = tc;
 
@@ -157,7 +162,7 @@ int trace_collection_add(struct trace_collection *tc,
                                check_clock_match,
                                &clock_match);
                if (!clock_match.clock_match) {
                                check_clock_match,
                                &clock_match);
                if (!clock_match.clock_match) {
-                       fprintf(stderr, "[error] No clocks can be correlated and multiple traces are added to the collection.\n");
+                       fprintf(stderr, "[error] No clocks can be correlated and multiple traces are added to the collection. If you are certain those traces can be correlated, try using \"--clock-force-correlate\".\n");
                        goto error;
                }
        }
                        goto error;
                }
        }
@@ -177,6 +182,7 @@ int trace_collection_add(struct trace_collection *tc,
                                clock_add,
                                &clock_match);
        }
                                clock_add,
                                &clock_match);
        }
+
        return 0;
 error:
        return -EPERM;
        return 0;
 error:
        return -EPERM;
@@ -185,6 +191,9 @@ error:
 int trace_collection_remove(struct trace_collection *tc,
                            struct trace_descriptor *td)
 {
 int trace_collection_remove(struct trace_collection *tc,
                            struct trace_descriptor *td)
 {
+       if (!tc || !td)
+               return -EINVAL;
+
        if (g_ptr_array_remove(tc->array, td)) {
                return 0;
        } else {
        if (g_ptr_array_remove(tc->array, td)) {
                return 0;
        } else {
@@ -195,6 +204,7 @@ int trace_collection_remove(struct trace_collection *tc,
 
 void init_trace_collection(struct trace_collection *tc)
 {
 
 void init_trace_collection(struct trace_collection *tc)
 {
+       assert(tc);
        tc->array = g_ptr_array_new();
        tc->clocks = g_hash_table_new(g_direct_hash, g_direct_equal);
        tc->single_clock_offset_avg = 0;
        tc->array = g_ptr_array_new();
        tc->clocks = g_hash_table_new(g_direct_hash, g_direct_equal);
        tc->single_clock_offset_avg = 0;
@@ -209,6 +219,7 @@ void init_trace_collection(struct trace_collection *tc)
  */
 void finalize_trace_collection(struct trace_collection *tc)
 {
  */
 void finalize_trace_collection(struct trace_collection *tc)
 {
+       assert(tc);
        g_ptr_array_free(tc->array, TRUE);
        g_hash_table_destroy(tc->clocks);
 }
        g_ptr_array_free(tc->array, TRUE);
        g_hash_table_destroy(tc->clocks);
 }
This page took 0.02315 seconds and 4 git commands to generate.