X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Ftrace-chunk.c;h=f7a4372b42df11140e0d9ced34c15d60ff6534fd;hb=4147107d9646011a1cdb7166a9810065927af99c;hp=fe244ac36594ebbcec7c81f8b9b331d9540f7a59;hpb=c36a763ba5727f861b66b78abb8554f6e49ab69e;p=lttng-tools.git diff --git a/src/common/trace-chunk.c b/src/common/trace-chunk.c index fe244ac36..f7a4372b4 100644 --- a/src/common/trace-chunk.c +++ b/src/common/trace-chunk.c @@ -165,8 +165,9 @@ char *generate_chunk_name(uint64_t chunk_id, time_t creation_timestamp, { 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, @@ -180,7 +181,7 @@ char *generate_chunk_name(uint64_t chunk_id, time_t 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; @@ -1096,7 +1097,7 @@ end: return registry; error: lttng_trace_chunk_registry_destroy(registry); - goto end; + return NULL; } LTTNG_HIDDEN