Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
return ret;
len_index = struct_declaration_lookup_field_index(file_stream->parent.trace_packet_header->declaration, g_quark_from_static_string("magic"));
if (len_index >= 0) {
return ret;
len_index = struct_declaration_lookup_field_index(file_stream->parent.trace_packet_header->declaration, g_quark_from_static_string("magic"));
if (len_index >= 0) {
- struct definition_integer *defint;
struct definition *field;
struct definition *field;
field = struct_definition_get_field_from_index(file_stream->parent.trace_packet_header, len_index);
field = struct_definition_get_field_from_index(file_stream->parent.trace_packet_header, len_index);
- assert(field->declaration->id == CTF_TYPE_INTEGER);
- defint = container_of(field, struct definition_integer, p);
- assert(defint->declaration->signedness == FALSE);
- if (defint->value._unsigned != CTF_MAGIC) {
+ magic = get_unsigned_int(field);
+ if (magic != CTF_MAGIC) {
fprintf(stdout, "[error] Invalid magic number 0x%" PRIX64 " at packet %u (file offset %zd).\n",
fprintf(stdout, "[error] Invalid magic number 0x%" PRIX64 " at packet %u (file offset %zd).\n",
- defint->value._unsigned,
file_stream->pos.packet_index->len,
(ssize_t) pos->mmap_offset);
return -EINVAL;
file_stream->pos.packet_index->len,
(ssize_t) pos->mmap_offset);
return -EINVAL;
assert(field->declaration->id == CTF_TYPE_ARRAY);
defarray = container_of(field, struct definition_array, p);
assert(array_len(defarray) == UUID_LEN);
assert(field->declaration->id == CTF_TYPE_ARRAY);
defarray = container_of(field, struct definition_array, p);
assert(array_len(defarray) == UUID_LEN);
- assert(defarray->declaration->elem->id == CTF_TYPE_INTEGER);
for (i = 0; i < UUID_LEN; i++) {
struct definition *elem;
for (i = 0; i < UUID_LEN; i++) {
struct definition *elem;
- struct definition_integer *defint;
elem = array_index(defarray, i);
elem = array_index(defarray, i);
- assert(elem);
- defint = container_of(elem, struct definition_integer, p);
- uuidval[i] = defint->value._unsigned;
+ uuidval[i] = get_unsigned_int(elem);
}
ret = uuid_compare(td->uuid, uuidval);
if (ret) {
}
ret = uuid_compare(td->uuid, uuidval);
if (ret) {
len_index = struct_declaration_lookup_field_index(file_stream->parent.trace_packet_header->declaration, g_quark_from_static_string("stream_id"));
if (len_index >= 0) {
len_index = struct_declaration_lookup_field_index(file_stream->parent.trace_packet_header->declaration, g_quark_from_static_string("stream_id"));
if (len_index >= 0) {
- struct definition_integer *defint;
struct definition *field;
field = struct_definition_get_field_from_index(file_stream->parent.trace_packet_header, len_index);
struct definition *field;
field = struct_definition_get_field_from_index(file_stream->parent.trace_packet_header, len_index);
- assert(field->declaration->id == CTF_TYPE_INTEGER);
- defint = container_of(field, struct definition_integer, p);
- assert(defint->declaration->signedness == FALSE);
- stream_id = defint->value._unsigned;
+ stream_id = get_unsigned_int(field);
/* read content size from header */
len_index = struct_declaration_lookup_field_index(file_stream->parent.stream_packet_context->declaration, g_quark_from_static_string("content_size"));
if (len_index >= 0) {
/* read content size from header */
len_index = struct_declaration_lookup_field_index(file_stream->parent.stream_packet_context->declaration, g_quark_from_static_string("content_size"));
if (len_index >= 0) {
- struct definition_integer *defint;
struct definition *field;
field = struct_definition_get_field_from_index(file_stream->parent.stream_packet_context, len_index);
struct definition *field;
field = struct_definition_get_field_from_index(file_stream->parent.stream_packet_context, len_index);
- assert(field->declaration->id == CTF_TYPE_INTEGER);
- defint = container_of(field, struct definition_integer, p);
- assert(defint->declaration->signedness == FALSE);
- packet_index.content_size = defint->value._unsigned;
+ packet_index.content_size = get_unsigned_int(field);
} else {
/* Use file size for packet size */
packet_index.content_size = filestats.st_size * CHAR_BIT;
} else {
/* Use file size for packet size */
packet_index.content_size = filestats.st_size * CHAR_BIT;
/* read packet size from header */
len_index = struct_declaration_lookup_field_index(file_stream->parent.stream_packet_context->declaration, g_quark_from_static_string("packet_size"));
if (len_index >= 0) {
/* read packet size from header */
len_index = struct_declaration_lookup_field_index(file_stream->parent.stream_packet_context->declaration, g_quark_from_static_string("packet_size"));
if (len_index >= 0) {
- struct definition_integer *defint;
struct definition *field;
field = struct_definition_get_field_from_index(file_stream->parent.stream_packet_context, len_index);
struct definition *field;
field = struct_definition_get_field_from_index(file_stream->parent.stream_packet_context, len_index);
- assert(field->declaration->id == CTF_TYPE_INTEGER);
- defint = container_of(field, struct definition_integer, p);
- assert(defint->declaration->signedness == FALSE);
- packet_index.packet_size = defint->value._unsigned;
+ packet_index.packet_size = get_unsigned_int(field);
} else {
/* Use content size if non-zero, else file size */
packet_index.packet_size = packet_index.content_size ? : filestats.st_size * CHAR_BIT;
} else {
/* Use content size if non-zero, else file size */
packet_index.packet_size = packet_index.content_size ? : filestats.st_size * CHAR_BIT;
/* read timestamp begin from header */
len_index = struct_declaration_lookup_field_index(file_stream->parent.stream_packet_context->declaration, g_quark_from_static_string("timestamp_begin"));
if (len_index >= 0) {
/* read timestamp begin from header */
len_index = struct_declaration_lookup_field_index(file_stream->parent.stream_packet_context->declaration, g_quark_from_static_string("timestamp_begin"));
if (len_index >= 0) {
- struct definition_integer *defint;
struct definition *field;
field = struct_definition_get_field_from_index(file_stream->parent.stream_packet_context, len_index);
struct definition *field;
field = struct_definition_get_field_from_index(file_stream->parent.stream_packet_context, len_index);
- assert(field->declaration->id == CTF_TYPE_INTEGER);
- defint = container_of(field, struct definition_integer, p);
- assert(defint->declaration->signedness == FALSE);
- packet_index.timestamp_begin = defint->value._unsigned;
+ packet_index.timestamp_begin = get_unsigned_int(field);
}
/* read timestamp end from header */
len_index = struct_declaration_lookup_field_index(file_stream->parent.stream_packet_context->declaration, g_quark_from_static_string("timestamp_end"));
if (len_index >= 0) {
}
/* read timestamp end from header */
len_index = struct_declaration_lookup_field_index(file_stream->parent.stream_packet_context->declaration, g_quark_from_static_string("timestamp_end"));
if (len_index >= 0) {
- struct definition_integer *defint;
struct definition *field;
field = struct_definition_get_field_from_index(file_stream->parent.stream_packet_context, len_index);
struct definition *field;
field = struct_definition_get_field_from_index(file_stream->parent.stream_packet_context, len_index);
- assert(field->declaration->id == CTF_TYPE_INTEGER);
- defint = container_of(field, struct definition_integer, p);
- assert(defint->declaration->signedness == FALSE);
- packet_index.timestamp_end = defint->value._unsigned;
+ packet_index.timestamp_end = get_unsigned_int(field);
}
} else {
/* Use file size for packet size */
}
} else {
/* Use file size for packet size */