- if (scope) {
- def = lookup_definition(scope, field);
- /*
- * optionally a field can have an underscore prefix, try
- * to lookup the field with this prefix if it failed
- */
- if (!def) {
- field_underscore = g_new(char, strlen(field) + 2);
- field_underscore[0] = '_';
- strcpy(&field_underscore[1], field);
- def = lookup_definition(scope, field_underscore);
- g_free(field_underscore);
- }
- if (bt_ctf_field_type(def) == CTF_TYPE_VARIANT) {
- struct definition_variant *variant_definition;
- variant_definition = container_of(def,
- struct definition_variant, p);
- return variant_definition->current_field;
- }
- return def;
+ if (!ctf_event || !scope || !field)
+ return NULL;
+
+ def = lookup_definition(scope, field);
+ /*
+ * optionally a field can have an underscore prefix, try
+ * to lookup the field with this prefix if it failed
+ */
+ if (!def) {
+ field_underscore = g_new(char, strlen(field) + 2);
+ field_underscore[0] = '_';
+ strcpy(&field_underscore[1], field);
+ def = lookup_definition(scope, field_underscore);
+ g_free(field_underscore);