ir: support optional parameters in bt_ctf_field_type_variant_get_field
[babeltrace.git] / formats / ctf / ir / event-types.c
index c03f0b7758f578b81e3c300118f94a9c7c96b34f..fabaea51ca769c23dcebea2bd5baaef5df684ae3 100644 (file)
@@ -1487,8 +1487,7 @@ int bt_ctf_field_type_variant_get_field(struct bt_ctf_field_type *type,
        struct structure_field *field;
        int ret = 0;
 
-       if (!type || index < 0 || !field_name || !field_type ||
-               (type->declaration->id != CTF_TYPE_VARIANT)) {
+       if (!type || index < 0 || (type->declaration->id != CTF_TYPE_VARIANT)) {
                ret = -1;
                goto end;
        }
@@ -1501,9 +1500,13 @@ int bt_ctf_field_type_variant_get_field(struct bt_ctf_field_type *type,
        }
 
        field = g_ptr_array_index(variant->fields, index);
-       *field_type = field->type;
-       bt_ctf_field_type_get(field->type);
-       *field_name = g_quark_to_string(field->name);
+       if (field_type) {
+               *field_type = field->type;
+               bt_ctf_field_type_get(field->type);
+       }
+       if (field_name) {
+               *field_name = g_quark_to_string(field->name);
+       }
 end:
        return ret;
 }
This page took 0.022847 seconds and 4 git commands to generate.