X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=src%2Fplugins%2Fctf%2Fcommon%2Fmetadata%2Fdecoder-packetized-file-stream-to-buf.c;h=ac067d2b250b048231997c501e6efd8d031f4a88;hp=29986fabd8789f17f331288c5ccd3e3a961f2b74;hb=0235b0db7de5bcacdb3650c92461f2ce5eb2143d;hpb=3c8252a5b96d617770863d3f54398b58d4c3315a diff --git a/src/plugins/ctf/common/metadata/decoder-packetized-file-stream-to-buf.c b/src/plugins/ctf/common/metadata/decoder-packetized-file-stream-to-buf.c index 29986fab..ac067d2b 100644 --- a/src/plugins/ctf/common/metadata/decoder-packetized-file-stream-to-buf.c +++ b/src/plugins/ctf/common/metadata/decoder-packetized-file-stream-to-buf.c @@ -1,21 +1,15 @@ /* - * Copyright 2016-2017 - Philippe Proulx + * SPDX-License-Identifier: MIT * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * Copyright 2016-2017 Philippe Proulx */ #define BT_COMP_LOG_SELF_COMP self_comp #define BT_LOG_OUTPUT_LEVEL log_level #define BT_LOG_TAG "PLUGIN/CTF/META/DECODER-DECODE-PACKET" -#include "plugins/comp-logging.h" +#include "logging/comp-logging.h" + +#include "decoder-packetized-file-stream-to-buf.h" #include #include @@ -23,7 +17,7 @@ #include #include #include "common/assert.h" -#include "compat/uuid.h" +#include "common/uuid.h" #include "compat/memstream.h" #include #include @@ -36,12 +30,9 @@ #define TSDL_MAGIC 0x75d11d57 -extern -int yydebug; - struct ctf_metadata_decoder { struct ctf_visitor_generate_ir *visitor; - uint8_t uuid[16]; + bt_uuid_t uuid; bool is_uuid_set; int bo; struct ctf_metadata_decoder_config config; @@ -49,7 +40,7 @@ struct ctf_metadata_decoder { struct packet_header { uint32_t magic; - uint8_t uuid[16]; + bt_uuid_t uuid; uint32_t checksum; uint32_t content_size; uint32_t packet_size; @@ -127,45 +118,15 @@ int decode_packet(FILE *in_fp, FILE *out_fp, /* Set expected trace UUID if not set; otherwise validate it */ if (is_uuid_set) { if (!*is_uuid_set) { - memcpy(uuid, header.uuid, sizeof(header.uuid)); + bt_uuid_copy(uuid, header.uuid); *is_uuid_set = true; } else if (bt_uuid_compare(header.uuid, uuid)) { BT_COMP_LOGE("Metadata UUID mismatch between packets of the same stream: " - "packet-uuid=\"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\", " - "expected-uuid=\"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\", " + "packet-uuid=\"" BT_UUID_FMT "\", " + "expected-uuid=\"" BT_UUID_FMT "\", " "offset=%ld", - (unsigned int) header.uuid[0], - (unsigned int) header.uuid[1], - (unsigned int) header.uuid[2], - (unsigned int) header.uuid[3], - (unsigned int) header.uuid[4], - (unsigned int) header.uuid[5], - (unsigned int) header.uuid[6], - (unsigned int) header.uuid[7], - (unsigned int) header.uuid[8], - (unsigned int) header.uuid[9], - (unsigned int) header.uuid[10], - (unsigned int) header.uuid[11], - (unsigned int) header.uuid[12], - (unsigned int) header.uuid[13], - (unsigned int) header.uuid[14], - (unsigned int) header.uuid[15], - (unsigned int) uuid[0], - (unsigned int) uuid[1], - (unsigned int) uuid[2], - (unsigned int) uuid[3], - (unsigned int) uuid[4], - (unsigned int) uuid[5], - (unsigned int) uuid[6], - (unsigned int) uuid[7], - (unsigned int) uuid[8], - (unsigned int) uuid[9], - (unsigned int) uuid[10], - (unsigned int) uuid[11], - (unsigned int) uuid[12], - (unsigned int) uuid[13], - (unsigned int) uuid[14], - (unsigned int) uuid[15], + BT_UUID_FMT_VALUES(header.uuid), + BT_UUID_FMT_VALUES(uuid), offset); goto error; } @@ -242,7 +203,7 @@ int ctf_metadata_decoder_packetized_file_stream_to_buf(FILE *fp, size_t packet_index = 0; out_fp = bt_open_memstream(buf, &size); - if (out_fp == NULL) { + if (!out_fp) { BT_COMP_LOGE("Cannot open memory stream: %s.", strerror(errno)); goto error;