X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=liblttng-ust%2Flttng-context-ip.c;fp=liblttng-ust%2Flttng-context-ip.c;h=4b32dc3983eea987fd8b9fd8929d7ee6a9c6fd1f;hb=a084756d092167324ee09d3f819cc45407b58233;hp=20c6fef34b8efbf5aa56dea460a4e8e72d6ed4f7;hpb=35c1f459092b630dd2825450014e27c84b31ddee;p=lttng-ust.git diff --git a/liblttng-ust/lttng-context-ip.c b/liblttng-ust/lttng-context-ip.c index 20c6fef3..4b32dc39 100644 --- a/liblttng-ust/lttng-context-ip.c +++ b/liblttng-ust/lttng-context-ip.c @@ -41,24 +41,39 @@ void ip_record(struct lttng_ust_ctx_field *field, int lttng_add_ip_to_ctx(struct lttng_ust_ctx **ctx) { struct lttng_ust_ctx_field *field; + struct lttng_ust_type_common *type; + int ret; - field = lttng_append_context(ctx); - if (!field) + type = lttng_ust_create_type_integer(sizeof(void *) * CHAR_BIT, + lttng_alignof(void *) * CHAR_BIT, + lttng_is_signed_type(void *), + BYTE_ORDER, 16); + if (!type) return -ENOMEM; + field = lttng_append_context(ctx); + if (!field) { + ret = -ENOMEM; + goto error_context; + } if (lttng_find_context(*ctx, "ip")) { - lttng_remove_context_field(ctx, field); - return -EEXIST; + ret = -EEXIST; + goto error_find_context; } - field->event_field->name = "ip"; - field->event_field->type.atype = atype_integer; - field->event_field->type.u.integer.size = sizeof(void *) * CHAR_BIT; - field->event_field->type.u.integer.alignment = lttng_alignof(void *) * CHAR_BIT; - field->event_field->type.u.integer.signedness = lttng_is_signed_type(void *); - field->event_field->type.u.integer.reverse_byte_order = 0; - field->event_field->type.u.integer.base = 16; - field->event_field->type.u.integer.encoding = lttng_encode_none; + field->event_field->name = strdup("ip"); + if (!field->event_field->name) { + ret = -ENOMEM; + goto error_name; + } + field->event_field->type = type; field->get_size = ip_get_size; field->record = ip_record; lttng_context_update(*ctx); return 0; + +error_name: +error_find_context: + lttng_remove_context_field(ctx, field); +error_context: + lttng_ust_destroy_type(type); + return ret; }