-static
-int try_set_trace_class_name(struct ctx *ctx)
-{
- GString *name = NULL;
- int ret = 0;
- struct ctf_trace_class_env_entry *env_entry;
-
- if (ctx->ctf_tc->name->len > 0) {
- /* Already set */
- goto end;
- }
-
- name = g_string_new(NULL);
- if (!name) {
- BT_LOGE_STR("Failed to allocate a GString.");
- ret = -1;
- goto end;
- }
-
- /*
- * Check if we have a trace environment string value named `hostname`.
- * If so, use it as the trace name's prefix.
- */
- env_entry = ctf_trace_class_borrow_env_entry_by_name(ctx->ctf_tc,
- "hostname");
- if (env_entry &&
- env_entry->type == CTF_TRACE_CLASS_ENV_ENTRY_TYPE_STR) {
- g_string_append(name, env_entry->value.str->str);
-
- if (ctx->trace_class_name_suffix) {
- g_string_append_c(name, G_DIR_SEPARATOR);
- }
- }
-
- if (ctx->trace_class_name_suffix) {
- g_string_append(name, ctx->trace_class_name_suffix);
- }
-
- g_string_assign(ctx->ctf_tc->name, name->str);
- goto end;
-
-end:
- if (name) {
- g_string_free(name, TRUE);
- }
-
- return ret;
-}
-