projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix: utils: unhandled close return value
[lttng-tools.git]
/
src
/
common
/
trace-chunk.cpp
diff --git
a/src/common/trace-chunk.cpp
b/src/common/trace-chunk.cpp
index 2bf1a39623d4ac6700ac48f99bdea254786a1dc1..488d0814620f32e4351913231d7596abff0fbdae 100644
(file)
--- a/
src/common/trace-chunk.cpp
+++ b/
src/common/trace-chunk.cpp
@@
-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);
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;
};
struct chunk_credentials {
bool use_current_user;
struct lttng_credentials user;
};
+} /* namespace */
/*
* NOTE: Make sure to update:
/*
* NOTE: Make sure to update:
@@
-120,6
+122,7
@@
struct lttng_trace_chunk {
struct fd_tracker *fd_tracker;
};
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;
/* 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;
};
/* call_rcu delayed reclaim. */
struct rcu_head rcu_node;
};
+} /* namespace */
struct lttng_trace_chunk_registry {
struct cds_lfht *ht;
};
struct lttng_trace_chunk_registry {
struct cds_lfht *ht;
};
+namespace {
struct fs_handle_untracked {
struct fs_handle parent;
int fd;
struct fs_handle_untracked {
struct fs_handle parent;
int fd;
@@
-143,6
+148,7
@@
struct fs_handle_untracked {
char *path;
} location;
};
char *path;
} location;
};
+} /* namespace */
static
int fs_handle_untracked_get_fd(struct fs_handle *handle);
static
int fs_handle_untracked_get_fd(struct fs_handle *handle);
@@
-203,7
+209,7
@@
struct fs_handle *fs_handle_untracked_create(
goto end;
}
goto end;
}
- handle =
(fs_handle_untracked *) zmalloc(sizeof(typeof(*handle))
);
+ handle =
zmalloc<fs_handle_untracked>(
);
if (!handle) {
PERROR("Failed to allocate untracked filesystem handle");
goto end;
if (!handle) {
PERROR("Failed to allocate untracked filesystem handle");
goto end;
@@
-231,8
+237,8
@@
end:
static
int fs_handle_untracked_get_fd(struct fs_handle *_handle)
{
static
int fs_handle_untracked_get_fd(struct fs_handle *_handle)
{
- struct fs_handle_untracked *handle = container_of(
- _handle,
struct fs_handle_untracked,
parent);
+ struct fs_handle_untracked *handle =
lttng::utils::
container_of(
+ _handle,
&fs_handle_untracked::
parent);
return handle->fd;
}
return handle->fd;
}
@@
-246,8
+252,8
@@
void fs_handle_untracked_put_fd(struct fs_handle *_handle __attribute__((unused)
static
int fs_handle_untracked_unlink(struct fs_handle *_handle)
{
static
int fs_handle_untracked_unlink(struct fs_handle *_handle)
{
- struct fs_handle_untracked *handle = container_of(
- _handle,
struct fs_handle_untracked,
parent);
+ struct fs_handle_untracked *handle =
lttng::utils::
container_of(
+ _handle,
&fs_handle_untracked::
parent);
return lttng_directory_handle_unlink_file(
handle->location.directory_handle,
return lttng_directory_handle_unlink_file(
handle->location.directory_handle,
@@
-265,8
+271,8
@@
void fs_handle_untracked_destroy(struct fs_handle_untracked *handle)
static
int fs_handle_untracked_close(struct fs_handle *_handle)
{
static
int fs_handle_untracked_close(struct fs_handle *_handle)
{
- struct fs_handle_untracked *handle = container_of(
- _handle,
struct fs_handle_untracked,
parent);
+ struct fs_handle_untracked *handle =
lttng::utils::
container_of(
+ _handle,
&fs_handle_untracked::
parent);
int ret = close(handle->fd);
fs_handle_untracked_destroy(handle);
int ret = close(handle->fd);
fs_handle_untracked_destroy(handle);
@@
-346,7
+352,7
@@
char *generate_chunk_name(uint64_t chunk_id, time_t creation_timestamp,
goto error;
}
}
goto error;
}
}
- new_name =
(char *) zmalloc
(GENERATED_CHUNK_NAME_LEN);
+ new_name =
calloc<char>
(GENERATED_CHUNK_NAME_LEN);
if (!new_name) {
ERR("Failed to allocate buffer for automatically-generated trace chunk name");
goto error;
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;
{
struct lttng_trace_chunk *chunk = NULL;
- chunk =
(lttng_trace_chunk *) zmalloc(sizeof(*chunk)
);
+ chunk =
zmalloc<lttng_trace_chunk>(
);
if (!chunk) {
ERR("Failed to allocate trace chunk");
goto end;
if (!chunk) {
ERR("Failed to allocate trace chunk");
goto end;
@@
-1456,8
+1462,8
@@
enum lttng_trace_chunk_status lttng_trace_chunk_open_file(
/*
* Does not close the fd; we just "unbox" it from the fs_handle.
*/
/*
* Does not close the fd; we just "unbox" it from the fs_handle.
*/
- fs_handle_untracked_destroy(container_of(
- fs_handle,
struct fs_handle_untracked,
parent));
+ fs_handle_untracked_destroy(
lttng::utils::
container_of(
+ fs_handle,
&fs_handle_untracked::
parent));
}
return status;
}
return status;
@@
-1855,8
+1861,8
@@
bool lttng_trace_chunk_get(struct lttng_trace_chunk *chunk)
static
void free_lttng_trace_chunk_registry_element(struct rcu_head *node)
{
static
void free_lttng_trace_chunk_registry_element(struct rcu_head *node)
{
- struct lttng_trace_chunk_registry_element *element =
-
container_of(node, typeof(*element),
rcu_node);
+ struct lttng_trace_chunk_registry_element *element =
lttng::utils::container_of(
+
node, <tng_trace_chunk_registry_element::
rcu_node);
free(element);
}
free(element);
}
@@
-1864,8
+1870,7
@@
void free_lttng_trace_chunk_registry_element(struct rcu_head *node)
static
void lttng_trace_chunk_release(struct urcu_ref *ref)
{
static
void lttng_trace_chunk_release(struct urcu_ref *ref)
{
- struct lttng_trace_chunk *chunk = container_of(ref, typeof(*chunk),
- ref);
+ struct lttng_trace_chunk *chunk = lttng::utils::container_of(ref, <tng_trace_chunk::ref);
if (chunk->close_command.is_set) {
chunk_command func = close_command_get_post_release_func(chunk->close_command.value);
if (chunk->close_command.is_set) {
chunk_command func = close_command_get_post_release_func(chunk->close_command.value);
@@
-1897,7
+1902,8
@@
void lttng_trace_chunk_release(struct urcu_ref *ref)
*/
lttng_trace_chunk_fini(chunk);
*/
lttng_trace_chunk_fini(chunk);
- element = container_of(chunk, typeof(*element), chunk);
+ element = lttng::utils::container_of(
+ chunk, <tng_trace_chunk_registry_element::chunk);
if (element->registry) {
rcu_read_lock();
cds_lfht_del(element->registry->ht,
if (element->registry) {
rcu_read_lock();
cds_lfht_del(element->registry->ht,
@@
-1930,7
+1936,7
@@
struct lttng_trace_chunk_registry *lttng_trace_chunk_registry_create(void)
{
struct lttng_trace_chunk_registry *registry;
{
struct lttng_trace_chunk_registry *registry;
- registry =
(lttng_trace_chunk_registry *) zmalloc(sizeof(*registry)
);
+ registry =
zmalloc<lttng_trace_chunk_registry>(
);
if (!registry) {
goto end;
}
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 =
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<lttng_trace_chunk_registry_element>(
);
if (!element) {
goto end;
if (!element) {
goto end;
@@
-2070,9
+2076,8
@@
lttng_trace_chunk_registry_publish_chunk(
* already published and release the reference to the copy we
* created if successful.
*/
* already published and release the reference to the copy we
* created if successful.
*/
- published_element = container_of(published_node,
- typeof(*published_element),
- trace_chunk_registry_ht_node);
+ published_element = lttng::utils::container_of(published_node,
+ <tng_trace_chunk_registry_element::trace_chunk_registry_ht_node);
published_chunk = &published_element->chunk;
if (lttng_trace_chunk_get(published_chunk)) {
lttng_trace_chunk_put(&element->chunk);
published_chunk = &published_element->chunk;
if (lttng_trace_chunk_get(published_chunk)) {
lttng_trace_chunk_put(&element->chunk);
@@
-2130,9
+2135,8
@@
struct lttng_trace_chunk *_lttng_trace_chunk_registry_find_chunk(
goto end;
}
goto end;
}
- published_element = container_of(published_node,
- typeof(*published_element),
- trace_chunk_registry_ht_node);
+ published_element = lttng::utils::container_of(published_node,
+ <tng_trace_chunk_registry_element::trace_chunk_registry_ht_node);
if (lttng_trace_chunk_get(&published_element->chunk)) {
published_chunk = &published_element->chunk;
}
if (lttng_trace_chunk_get(&published_element->chunk)) {
published_chunk = &published_element->chunk;
}
This page took
0.04455 seconds
and
4
git commands to generate.