{
int ret = 0;
char *new_name= NULL;
- char start_datetime[sizeof("YYYYmmddTHHMMSS+HHMM")] = {};
- char end_datetime_suffix[sizeof("-YYYYmmddTHHMMSS+HHMM")] = {};
+ char start_datetime[ISO8601_STR_LEN] = {};
+ /* Add 1 for a '-' prefix. */
+ char end_datetime_suffix[ISO8601_STR_LEN + 1] = {};
ret = time_to_iso8601_str(
creation_timestamp,
ret = time_to_iso8601_str(
*close_timestamp,
end_datetime_suffix + 1,
- sizeof(end_datetime_suffix));
+ sizeof(end_datetime_suffix) - 1);
if (ret) {
ERR("Failed to format trace chunk end date time");
goto error;
goto end;
}
LTTNG_OPTIONAL_SET(&chunk->timestamp_close, close_ts);
- free(chunk->name);
- chunk->name = generate_chunk_name(LTTNG_OPTIONAL_GET(chunk->id),
- LTTNG_OPTIONAL_GET(chunk->timestamp_creation),
- &close_ts);
- if (!chunk->name) {
- status = LTTNG_TRACE_CHUNK_STATUS_ERROR;
+ if (!chunk->name_overridden) {
+ free(chunk->name);
+ chunk->name = generate_chunk_name(LTTNG_OPTIONAL_GET(chunk->id),
+ LTTNG_OPTIONAL_GET(chunk->timestamp_creation),
+ &close_ts);
+ if (!chunk->name) {
+ status = LTTNG_TRACE_CHUNK_STATUS_ERROR;
+ }
}
end:
pthread_mutex_unlock(&chunk->lock);
return false;
}
- len = strnlen(name, LTTNG_NAME_MAX);
+ len = lttng_strnlen(name, LTTNG_NAME_MAX);
if (len == 0 || len == LTTNG_NAME_MAX) {
return false;
}
}
if (!found) {
- char *copy = strndup(new_path, new_path_top_level_len);
+ char *copy = lttng_strndup(new_path, new_path_top_level_len);
DBG("Adding new top-level directory \"%s\" to trace chunk \"%s\"",
new_path, chunk->name ? : "(unnamed)");
return registry;
error:
lttng_trace_chunk_registry_destroy(registry);
- goto end;
+ return NULL;
}
LTTNG_HIDDEN