From: Philippe Proulx Date: Mon, 11 Jun 2018 20:00:21 +0000 (-0400) Subject: Fix: freeze field type unconditionally X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=5ea30b28acfde37adf65e73964b81896e2cc75fd;p=deliverable%2Fbabeltrace.git Fix: freeze field type unconditionally Issue ===== Field types should always be frozen (in both developer or production modes) because they are metadata objects. Currently, they are only frozen in developer mode. Solution ======== Make the bt_field_type_common_freeze() and bt_field_type_freeze() functions always called, not through a macro which is only enabled in developer mode. Known drawbacks =============== Very small performance impact because we're trying to freeze a field type every time bt_field_create() is called, but bt_field_create() is not called often anyway due to field object pooling. The impact could become noticeable eventually if we limit the sizes of object pools. Signed-off-by: Philippe Proulx --- diff --git a/include/babeltrace/ctf-ir/field-types-internal.h b/include/babeltrace/ctf-ir/field-types-internal.h index a15b9c0a1..3940b1d49 100644 --- a/include/babeltrace/ctf-ir/field-types-internal.h +++ b/include/babeltrace/ctf-ir/field-types-internal.h @@ -274,14 +274,6 @@ struct bt_field_type_common_string { enum bt_string_encoding encoding; }; -#ifdef BT_DEV_MODE -# define bt_field_type_freeze _bt_field_type_freeze -# define bt_field_type_common_freeze _bt_field_type_common_freeze -#else -# define bt_field_type_freeze(_ft) -# define bt_field_type_common_freeze(_ft) -#endif - typedef struct bt_field_common *(* bt_field_common_create_func)( struct bt_field_type_common *); @@ -620,10 +612,10 @@ enum bt_field_type_id bt_field_type_common_get_type_id( struct bt_field_type_common *ft); BT_HIDDEN -void _bt_field_type_common_freeze(struct bt_field_type_common *ft); +void bt_field_type_common_freeze(struct bt_field_type_common *ft); BT_HIDDEN -void _bt_field_type_freeze(struct bt_field_type *ft); +void bt_field_type_freeze(struct bt_field_type *ft); BT_HIDDEN struct bt_field_type_common * diff --git a/lib/ctf-ir/field-types.c b/lib/ctf-ir/field-types.c index 11764121f..a8a41b572 100644 --- a/lib/ctf-ir/field-types.c +++ b/lib/ctf-ir/field-types.c @@ -3431,7 +3431,7 @@ int bt_field_type_is_variant(struct bt_field_type *type) } BT_HIDDEN -void _bt_field_type_common_freeze(struct bt_field_type_common *ft) +void bt_field_type_common_freeze(struct bt_field_type_common *ft) { if (!ft || ft->frozen) { return; @@ -3442,9 +3442,9 @@ void _bt_field_type_common_freeze(struct bt_field_type_common *ft) } BT_HIDDEN -void _bt_field_type_freeze(struct bt_field_type *ft) +void bt_field_type_freeze(struct bt_field_type *ft) { - _bt_field_type_common_freeze((void *) ft); + bt_field_type_common_freeze((void *) ft); } BT_HIDDEN