static
int lttng_validate_datetime(const char *datetime)
{
- GTimeZone *default_tz;
- GDateTime *gdatetime = NULL;
+ GTimeVal tv;
int ret = -1;
- default_tz = g_time_zone_new_utc();
- if (!default_tz) {
- BT_LOGD("Failed to allocate timezone");
- goto end;
- }
-
- gdatetime = g_date_time_new_from_iso8601(datetime, default_tz);
- if (!gdatetime) {
+ /*
+ * We are using g_time_val_from_iso8601, as the safer/more modern
+ * alternative, g_date_time_new_from_iso8601, is only available in
+ * glib >= 2.56, and this is sufficient for our use case of validating
+ * the format.
+ */
+ if (!g_time_val_from_iso8601(datetime, &tv)) {
BT_LOGD("Couldn't parse datetime as iso8601: date=\"%s\"", datetime);
goto end;
}
ret = 0;
end:
- if (default_tz) {
- g_time_zone_unref(default_tz);
- default_tz = NULL;
- }
-
- if (gdatetime) {
- g_date_time_unref(gdatetime);
- gdatetime = NULL;
- }
-
return ret;
}
int ret;
v = bt_trace_class_borrow_environment_entry_value_by_name_const(tc, "tracer_buffering_id");
- if (!v || !bt_value_is_integer(v)) {
+ if (!v || !bt_value_is_signed_integer(v)) {
BT_LOGD_STR("Couldn't get environment value: name=\"tracer_buffering_id\"");
goto error;
}
- g_string_append_printf(path, G_DIR_SEPARATOR_S "%" PRId64, bt_value_integer_get(v));
+ g_string_append_printf(path, G_DIR_SEPARATOR_S "%" PRId64,
+ bt_value_signed_integer_get(v));
v = bt_trace_class_borrow_environment_entry_value_by_name_const(tc, "isa_length");
- if (!v || !bt_value_is_integer(v)) {
+ if (!v || !bt_value_is_signed_integer(v)) {
BT_LOGD_STR("Couldn't get environment value: name=\"isa_length\"");
goto error;
}
- g_string_append_printf(path, G_DIR_SEPARATOR_S "%" PRIu64 "-bit", bt_value_integer_get(v));
+ g_string_append_printf(path, G_DIR_SEPARATOR_S "%" PRIu64 "-bit",
+ bt_value_signed_integer_get(v));
ret = 0;
goto end;
g_string_append_printf(path, G_DIR_SEPARATOR_S "%s", bt_value_string_get(v));
v = bt_trace_class_borrow_environment_entry_value_by_name_const(tc, "vpid");
- if (!v || !bt_value_is_integer(v)) {
+ if (!v || !bt_value_is_signed_integer(v)) {
BT_LOGD_STR("Couldn't get environment value: name=\"vpid\"");
goto error;
}
- g_string_append_printf(path, "-%" PRId64, bt_value_integer_get(v));
+ g_string_append_printf(path, "-%" PRId64, bt_value_signed_integer_get(v));
v = bt_trace_class_borrow_environment_entry_value_by_name_const(tc, "vpid_datetime");
if (!v || !bt_value_is_string(v)) {
}
v = bt_trace_class_borrow_environment_entry_value_by_name_const(tc, "tracer_major");
- if (!v || !bt_value_is_integer(v)) {
+ if (!v || !bt_value_is_signed_integer(v)) {
BT_LOGD_STR("Couldn't get environment value: name=\"tracer_major\"");
goto error;
}
- tracer_major = bt_value_integer_get(v);
+ tracer_major = bt_value_signed_integer_get(v);
v = bt_trace_class_borrow_environment_entry_value_by_name_const(tc, "tracer_minor");
- if (!v || !bt_value_is_integer(v)) {
+ if (!v || !bt_value_is_signed_integer(v)) {
BT_LOGD_STR("Couldn't get environment value: name=\"tracer_minor\"");
goto error;
}
- tracer_minor = bt_value_integer_get(v);
+ tracer_minor = bt_value_signed_integer_get(v);
if (!(tracer_major >= 3 || (tracer_major == 2 && tracer_minor >= 11))) {
BT_LOGD("Unsupported LTTng version for automatic trace path: major=%" PRId64 ", minor=%" PRId64,
tsdl = g_string_new(NULL);
BT_ASSERT(tsdl);
translate_trace_class_ctf_ir_to_tsdl(trace->tc, tsdl);
+
+ BT_ASSERT(trace->metadata_path);
fh = fopen(trace->metadata_path->str, "wb");
if (!fh) {
BT_LOGF_ERRNO("In trace destruction listener: "
trace->path = NULL;
}
- if (trace->metadata_path) {
- g_string_free(trace->metadata_path, TRUE);
- trace->metadata_path = NULL;
- }
+ g_string_free(trace->metadata_path, TRUE);
+ trace->metadata_path = NULL;
fs_sink_ctf_trace_class_destroy(trace->tc);
trace->tc = NULL;