X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=formats%2Fctf%2Fir%2Fevent-class.c;h=03f20a7e0c506c64cf9016eeabc0ef8986dc7b63;hb=835b2d10c5c80ebad6427ba3794d712dd44ef145;hp=fa5756d65930d1cc90276b97d3b7009b9dd76752;hpb=9531634fc191fc3b0c3f9f0a840f95396914ba66;p=babeltrace.git diff --git a/formats/ctf/ir/event-class.c b/formats/ctf/ir/event-class.c index fa5756d6..03f20a7e 100644 --- a/formats/ctf/ir/event-class.c +++ b/formats/ctf/ir/event-class.c @@ -355,16 +355,19 @@ int bt_ctf_event_class_set_payload_type(struct bt_ctf_event_class *event_class, { int ret = 0; - if (!event_class || !payload || - bt_ctf_field_type_get_type_id(payload) != - BT_CTF_TYPE_ID_STRUCT) { + if (!event_class) { + ret = -1; + goto end; + } + + if (payload && bt_ctf_field_type_get_type_id(payload) != + BT_CTF_TYPE_ID_STRUCT) { ret = -1; goto end; } - bt_get(payload); bt_put(event_class->fields); - event_class->fields = payload; + event_class->fields = bt_get(payload); end: return ret; } @@ -488,19 +491,19 @@ int bt_ctf_event_class_set_context_type( { int ret = 0; - if (!event_class || !context || event_class->frozen) { + if (!event_class || event_class->frozen) { ret = -1; goto end; } - if (bt_ctf_field_type_get_type_id(context) != BT_CTF_TYPE_ID_STRUCT) { + if (context && bt_ctf_field_type_get_type_id(context) != + BT_CTF_TYPE_ID_STRUCT) { ret = -1; goto end; } - bt_get(context); bt_put(event_class->context); - event_class->context = context; + event_class->context = bt_get(context); end: return ret;