X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Ftrace-chunk.c;h=fb4d1672490d49b889e98646ecee7bc6bcea788a;hb=606846ba9588920704ccaa53d1127ecc1dcdaa80;hp=40e612800a5c8e6dd31442593d27e94eea81fbbc;hpb=f7399c50a8c8c65ecb53107e63a5e8f13424c63a;p=lttng-tools.git diff --git a/src/common/trace-chunk.c b/src/common/trace-chunk.c index 40e612800..fb4d16724 100644 --- a/src/common/trace-chunk.c +++ b/src/common/trace-chunk.c @@ -91,8 +91,8 @@ struct lttng_trace_chunk { /* A trace chunk is uniquely identified by its (session id, chunk id) tuple. */ struct lttng_trace_chunk_registry_element { - uint64_t session_id; struct lttng_trace_chunk chunk; + uint64_t session_id; /* Weak and only set when added. */ struct lttng_trace_chunk_registry *registry; struct cds_lfht_node trace_chunk_registry_ht_node; @@ -104,11 +104,13 @@ struct lttng_trace_chunk_registry { struct cds_lfht *ht; }; -const char *close_command_names[] = { +static const +char *close_command_names[] = { [LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED] = "move to completed chunk folder", }; +static const chunk_close_command close_command_funcs[] = { [LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED] = lttng_trace_chunk_move_to_completed, @@ -165,8 +167,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 +183,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; @@ -656,7 +659,7 @@ int add_top_level_directory_unique(struct lttng_trace_chunk *chunk, } 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)"); @@ -988,7 +991,7 @@ enum lttng_trace_chunk_status lttng_trace_chunk_set_close_command( if (close_command < LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED || close_command >= LTTNG_TRACE_CHUNK_COMMAND_TYPE_MAX) { status = LTTNG_TRACE_CHUNK_STATUS_INVALID_ARGUMENT; - goto end_unlock; + goto end; } pthread_mutex_lock(&chunk->lock); @@ -1002,7 +1005,7 @@ enum lttng_trace_chunk_status lttng_trace_chunk_set_close_command( } LTTNG_OPTIONAL_SET(&chunk->close_command, close_command); pthread_mutex_unlock(&chunk->lock); -end_unlock: +end: return status; } @@ -1096,7 +1099,7 @@ end: return registry; error: lttng_trace_chunk_registry_destroy(registry); - goto end; + return NULL; } LTTNG_HIDDEN