Cleanup: add bt_ctf_value_type stringifying function
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Tue, 18 Dec 2018 18:23:32 +0000 (13:23 -0500)
committerFrancis Deslauriers <francis.deslauriers@efficios.com>
Thu, 2 May 2019 20:50:15 +0000 (20:50 +0000)
This fixes the following Clang warning:
  trace.c:270:5: error: implicit conversion from enumeration type 'enum
  bt_ctf_value_type' to different enumeration type 'enum bt_value_type'
  [-Werror,-Wenum-conversion]

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
include/babeltrace/ctf-writer/values-internal.h
lib/ctf-writer/trace.c

index 332626f2e557044ed25babdf40f1c73e1f1f280a..ca87255a327073cfea3e035fc08e7b3841b6ffc8 100644 (file)
@@ -331,4 +331,27 @@ BT_HIDDEN
 enum bt_ctf_value_status bt_ctf_private_value_map_insert_empty_map_entry(
                struct bt_ctf_private_value *map_obj, const char *key);
 
+static inline
+const char *bt_ctf_value_type_string(enum bt_ctf_value_type type)
+{
+       switch (type) {
+       case BT_CTF_VALUE_TYPE_NULL:
+               return "BT_CTF_VALUE_TYPE_NULL";
+       case BT_CTF_VALUE_TYPE_BOOL:
+               return "BT_CTF_VALUE_TYPE_BOOL";
+       case BT_CTF_VALUE_TYPE_INTEGER:
+               return "BT_CTF_VALUE_TYPE_INTEGER";
+       case BT_CTF_VALUE_TYPE_REAL:
+               return "BT_CTF_VALUE_TYPE_REAL";
+       case BT_CTF_VALUE_TYPE_STRING:
+               return "BT_CTF_VALUE_TYPE_STRING";
+       case BT_CTF_VALUE_TYPE_ARRAY:
+               return "BT_CTF_VALUE_TYPE_ARRAY";
+       case BT_CTF_VALUE_TYPE_MAP:
+               return "BT_CTF_VALUE_TYPE_MAP";
+       default:
+               return "(unknown)";
+       }
+};
+
 #endif /* BABELTRACE_CTF_WRITER_VALUES_INTERNAL_H */
index 2ef0d8e56f51ef3457dbb75f61d5155a14537322..5957c1e893f494a9d3cd3843d40ec59ff152f048 100644 (file)
@@ -266,7 +266,7 @@ int bt_ctf_trace_common_set_environment_field(struct bt_ctf_trace_common *trace,
                        "trace-addr=%p, trace-name=\"%s\", "
                        "env-name=\"%s\", env-value-type=%s",
                        trace, bt_ctf_trace_common_get_name(trace), name,
-                       bt_common_value_type_string(
+                       bt_ctf_value_type_string(
                                bt_ctf_value_get_type(
                                        bt_ctf_private_value_as_value(value))));
                ret = -1;
This page took 0.026556 seconds and 4 git commands to generate.