From bcfb49d4472da31c570008b3ab36eef08a3f7276 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Tue, 15 Nov 2016 15:30:29 -0500 Subject: [PATCH] Add logging to validation and serialization failure paths MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- formats/ctf/ir/fields.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/formats/ctf/ir/fields.c b/formats/ctf/ir/fields.c index 55af6d0a..04fba5cf 100644 --- a/formats/ctf/ir/fields.c +++ b/formats/ctf/ir/fields.c @@ -1641,6 +1641,7 @@ int bt_ctf_field_array_validate(struct bt_ctf_field *field) for (i = 0; i < array->elements->len; i++) { ret = bt_ctf_field_validate(array->elements->pdata[i]); if (ret) { + fprintf(stderr, "Failed to validate sequence field #%zu\n", i); goto end; } } @@ -1664,7 +1665,7 @@ int bt_ctf_field_sequence_validate(struct bt_ctf_field *field) for (i = 0; i < sequence->elements->len; i++) { ret = bt_ctf_field_validate(sequence->elements->pdata[i]); if (ret) { - fprintf(stderr, "Failed to validate sequence field %zu\n", i); + fprintf(stderr, "Failed to validate sequence field #%zu\n", i); goto end; } } @@ -1940,6 +1941,15 @@ int bt_ctf_field_structure_serialize(struct bt_ctf_field *field, ret = bt_ctf_field_serialize(field, pos); if (ret) { + const char *name; + struct bt_ctf_field_type *field_type = + bt_ctf_field_get_type(field); + + (void) bt_ctf_field_type_structure_get_field(field_type, + &name, NULL, i); + fprintf(stderr, "Field %s failed to serialize\n", + name ? name : "NULL"); + bt_put(field_type); break; } } @@ -1970,6 +1980,7 @@ int bt_ctf_field_array_serialize(struct bt_ctf_field *field, ret = bt_ctf_field_serialize( g_ptr_array_index(array->elements, i), pos); if (ret) { + fprintf(stderr, "Failed to serialize array element #%zu\n", i); goto end; } } @@ -1990,6 +2001,7 @@ int bt_ctf_field_sequence_serialize(struct bt_ctf_field *field, ret = bt_ctf_field_serialize( g_ptr_array_index(sequence->elements, i), pos); if (ret) { + fprintf(stderr, "Failed to serialize sequence element #%zu\n", i); goto end; } } -- 2.34.1