-#ifndef BABELTRACE_CTF_WRITER_FIELDS_INTERNAL_H
-#define BABELTRACE_CTF_WRITER_FIELDS_INTERNAL_H
-
/*
- * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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:
+ * SPDX-License-Identifier: MIT
*
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* The Common Trace Format (CTF) Specification is available at
* http://www.efficios.com/ctf
*/
+#ifndef BABELTRACE_CTF_WRITER_FIELDS_INTERNAL_H
+#define BABELTRACE_CTF_WRITER_FIELDS_INTERNAL_H
+
#include <glib.h>
#include <inttypes.h>
#include <stdbool.h>
# define bt_ctf_field_common_set(_field, _val)
#endif
-BT_ASSERT_FUNC
+BT_ASSERT_DBG_FUNC
static inline bool field_type_common_has_known_id(
struct bt_ctf_field_type_common *ft)
{
- return (int) ft->id > BT_CTF_FIELD_TYPE_ID_UNKNOWN ||
+ return (int) ft->id > BT_CTF_FIELD_TYPE_ID_UNKNOWN &&
(int) ft->id < BT_CTF_FIELD_TYPE_ID_NR;
}
goto end;
}
- BT_ASSERT(field_type_common_has_known_id(field->type));
+ BT_ASSERT_DBG(field_type_common_has_known_id(field->type));
if (field->methods->validate) {
ret = field->methods->validate(field);
static inline
void _bt_ctf_field_common_reset_recursive(struct bt_ctf_field_common *field)
{
- BT_ASSERT(field);
- BT_ASSERT(field->methods->reset);
+ BT_ASSERT_DBG(field);
+ BT_ASSERT_DBG(field->methods->reset);
field->methods->reset(field);
}
static inline
void _bt_ctf_field_common_set(struct bt_ctf_field_common *field, bool value)
{
- BT_ASSERT(field);
+ BT_ASSERT_DBG(field);
field->payload_set = value;
}
goto end;
}
- BT_ASSERT(field_type_common_has_known_id(field->type));
- BT_ASSERT(field->methods->is_set);
+ BT_ASSERT_DBG(field_type_common_has_known_id(field->type));
+ BT_ASSERT_DBG(field->methods->is_set);
is_set = field->methods->is_set(field);
end:
bt_ctf_object_release_func release_func,
struct bt_ctf_field_common_methods *methods)
{
- BT_ASSERT(field);
- BT_ASSERT(ft);
+ BT_ASSERT_DBG(field);
+ BT_ASSERT_DBG(ft);
bt_ctf_object_init(&field->base, is_shared, release_func);
field->methods = methods;
field->type = (void *) bt_ctf_object_get_ref(ft);
goto end;
}
- BT_ASSERT(!sequence->elements->pdata[i]);
+ BT_ASSERT_DBG(!sequence->elements->pdata[i]);
sequence->elements->pdata[i] = elem_field;
}
}
}
ret = structure->fields->pdata[index];
- BT_ASSERT(ret);
+ BT_ASSERT_DBG(ret);
error:
return ret;
}
/* Select corresponding field */
- BT_ASSERT(choice_index < variant->fields->len);
+ BT_ASSERT_DBG(choice_index < variant->fields->len);
variant->current_field = variant->fields->pdata[choice_index];
variant->tag_value.u = tag_uval;
BT_CTF_FIELD_TYPE_ID_STRING, "Field");
/* Make sure no null bytes are appended */
- BT_CTF_ASSERT_PRE(memchr(value, '\0', length) == NULL,
+ BT_CTF_ASSERT_PRE(!memchr(value, '\0', length),
"String value to append contains a null character: "
"partial-value=\"%.32s\", length=%u", value, length);
static inline
void bt_ctf_field_common_finalize(struct bt_ctf_field_common *field)
{
- BT_ASSERT(field);
+ BT_ASSERT_DBG(field);
BT_LOGD_STR("Putting field's type.");
bt_ctf_object_put_ref(field->type);
}
static inline
void bt_ctf_field_common_integer_finalize(struct bt_ctf_field_common *field)
{
- BT_ASSERT(field);
+ BT_ASSERT_DBG(field);
BT_LOGD("Finalizing common integer field object: addr=%p", field);
bt_ctf_field_common_finalize(field);
}
static inline
void bt_ctf_field_common_floating_point_finalize(struct bt_ctf_field_common *field)
{
- BT_ASSERT(field);
+ BT_ASSERT_DBG(field);
BT_LOGD("Finalizing common floating point number field object: addr=%p", field);
bt_ctf_field_common_finalize(field);
}
{
struct bt_ctf_field_common_structure *structure = BT_CTF_FROM_COMMON(field);
- BT_ASSERT(field);
+ BT_ASSERT_DBG(field);
BT_LOGD("Finalizing common structure field object: addr=%p", field);
bt_ctf_field_common_finalize(field);
{
struct bt_ctf_field_common_variant *variant = BT_CTF_FROM_COMMON(field);
- BT_ASSERT(field);
+ BT_ASSERT_DBG(field);
BT_LOGD("Finalizing common variant field object: addr=%p", field);
bt_ctf_field_common_finalize(field);
{
struct bt_ctf_field_common_array *array = BT_CTF_FROM_COMMON(field);
- BT_ASSERT(field);
+ BT_ASSERT_DBG(field);
BT_LOGD("Finalizing common array field object: addr=%p", field);
bt_ctf_field_common_finalize(field);
{
struct bt_ctf_field_common_sequence *sequence = BT_CTF_FROM_COMMON(field);
- BT_ASSERT(field);
+ BT_ASSERT_DBG(field);
BT_LOGD("Finalizing common sequence field object: addr=%p", field);
bt_ctf_field_common_finalize(field);
{
struct bt_ctf_field_common_string *string = BT_CTF_FROM_COMMON(field);
- BT_ASSERT(field);
+ BT_ASSERT_DBG(field);
BT_LOGD("Finalizing common string field object: addr=%p", field);
bt_ctf_field_common_finalize(field);