X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Ftrace-chunk.cpp;h=beae46ef3110c416bd271aeb8125edef70f33502;hb=f149493493fbd8a3efa4748832c03278c96c38ca;hp=92cbd3c342d6daac671033b49c0262517fd2d28b;hpb=1c9a0b0e83c7e073c4e576c0bed95de335b0e502;p=lttng-tools.git diff --git a/src/common/trace-chunk.cpp b/src/common/trace-chunk.cpp index 92cbd3c34..beae46ef3 100644 --- a/src/common/trace-chunk.cpp +++ b/src/common/trace-chunk.cpp @@ -5,23 +5,23 @@ * */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include @@ -64,10 +64,12 @@ static enum lttng_trace_chunk_status lttng_trace_chunk_rename_path_no_lock( struct lttng_trace_chunk *chunk, const char *path); +namespace { struct chunk_credentials { bool use_current_user; struct lttng_credentials user; }; +} /* namespace */ /* * NOTE: Make sure to update: @@ -120,6 +122,7 @@ struct lttng_trace_chunk { struct fd_tracker *fd_tracker; }; +namespace { /* A trace chunk is uniquely identified by its (session id, chunk id) tuple. */ struct lttng_trace_chunk_registry_element { struct lttng_trace_chunk chunk; @@ -130,11 +133,13 @@ struct lttng_trace_chunk_registry_element { /* call_rcu delayed reclaim. */ struct rcu_head rcu_node; }; +} /* namespace */ struct lttng_trace_chunk_registry { struct cds_lfht *ht; }; +namespace { struct fs_handle_untracked { struct fs_handle parent; int fd; @@ -143,6 +148,7 @@ struct fs_handle_untracked { char *path; } location; }; +} /* namespace */ static int fs_handle_untracked_get_fd(struct fs_handle *handle); @@ -203,7 +209,7 @@ struct fs_handle *fs_handle_untracked_create( goto end; } - handle = (fs_handle_untracked *) zmalloc(sizeof(typeof(*handle))); + handle = zmalloc(); if (!handle) { PERROR("Failed to allocate untracked filesystem handle"); goto end; @@ -346,7 +352,7 @@ char *generate_chunk_name(uint64_t chunk_id, time_t creation_timestamp, goto error; } } - new_name = (char *) zmalloc(GENERATED_CHUNK_NAME_LEN); + new_name = calloc(GENERATED_CHUNK_NAME_LEN); if (!new_name) { ERR("Failed to allocate buffer for automatically-generated trace chunk name"); goto error; @@ -399,7 +405,7 @@ struct lttng_trace_chunk *lttng_trace_chunk_allocate(void) { struct lttng_trace_chunk *chunk = NULL; - chunk = (lttng_trace_chunk *) zmalloc(sizeof(*chunk)); + chunk = zmalloc(); if (!chunk) { ERR("Failed to allocate trace chunk"); goto end; @@ -1930,7 +1936,7 @@ struct lttng_trace_chunk_registry *lttng_trace_chunk_registry_create(void) { struct lttng_trace_chunk_registry *registry; - registry = (lttng_trace_chunk_registry *) zmalloc(sizeof(*registry)); + registry = zmalloc(); if (!registry) { goto end; } @@ -1966,7 +1972,7 @@ lttng_trace_chunk_registry_element_create_from_chunk( struct lttng_trace_chunk *chunk, uint64_t session_id) { struct lttng_trace_chunk_registry_element *element = - (lttng_trace_chunk_registry_element *) zmalloc(sizeof(*element)); + zmalloc(); if (!element) { goto end;