return g_ptr_array_index(trace->streams, stream_id);
}
+static
+struct ctf_event_declaration *stream_event_lookup(struct ctf_stream_declaration *stream, uint64_t event_id)
+{
+ if (stream->events_by_id->len <= event_id)
+ return NULL;
+ return g_ptr_array_index(stream->events_by_id, event_id);
+}
+
static
struct ctf_clock *trace_clock_lookup(struct ctf_trace *trace, GQuark clock_name)
{
ret = get_unary_unsigned(min_align, &min_align_value);
if (ret) {
fprintf(fd, "[error] %s: unexpected unary expression for structure \"align\" attribute\n", __func__);
- ret = -EINVAL;
goto error;
}
}
return NULL;
}
size = right->u.unary_expression.u.unsigned_constant;
+ if (!size) {
+ fprintf(fd, "[error] %s: integer size: expecting non-zero constant\n",
+ __func__);
+ return NULL;
+ }
has_size = 1;
} else if (!strcmp(left->u.unary_expression.u.string, "align")) {
if (right->u.unary_expression.type != UNARY_UNSIGNED_CONSTANT) {
struct ctf_trace *trace)
{
struct ctf_node *expression;
- uint64_t alignment = 1, exp_dig = 0, mant_dig = 0,
- byte_order = trace->byte_order;
- int has_alignment = 0, has_exp_dig = 0, has_mant_dig = 0;
+ uint64_t alignment = 1, exp_dig = 0, mant_dig = 0;
+ int byte_order = trace->byte_order, has_alignment = 0,
+ has_exp_dig = 0, has_mant_dig = 0;
struct declaration_float *float_declaration;
bt_list_for_each_entry(expression, expressions, siblings) {
fprintf(fd, "[error] %s: missing id field in event declaration\n", __func__);
goto error;
}
+ /* Disallow re-using the same event ID in the same stream */
+ if (stream_event_lookup(event->stream, event->id)) {
+ ret = -EPERM;
+ fprintf(fd, "[error] %s: event ID %" PRIu64 " used more than once in stream %" PRIu64 "\n",
+ __func__, event->id, event->stream_id);
+ goto error;
+ }
if (event->stream->events_by_id->len <= event->id)
g_ptr_array_set_size(event->stream->events_by_id, event->id + 1);
g_ptr_array_index(event->stream->events_by_id, event->id) = event;
goto error;
}
clock->absolute = ret;
+ ret = 0;
} else {
fprintf(fd, "[warning] %s: attribute \"%s\" is unknown in clock declaration.\n", __func__, left);
}