X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=src%2Flib%2Flttng-ctl%2Fsnapshot.cpp;h=4e7df2db39c60888c03b86529f1b0351f9093080;hb=cd9adb8b829564212158943a0d279bb35322ab30;hp=2814cc5ee2bca788e2e2412257f98693f127c963;hpb=37a5ef391d8d282fb8c8978e4761413b69d56072;p=lttng-tools.git diff --git a/src/lib/lttng-ctl/snapshot.cpp b/src/lib/lttng-ctl/snapshot.cpp index 2814cc5ee..4e7df2db3 100644 --- a/src/lib/lttng-ctl/snapshot.cpp +++ b/src/lib/lttng-ctl/snapshot.cpp @@ -6,22 +6,22 @@ */ #define _LGPL_SOURCE -#include +#include "lttng-ctl-helper.hpp" #include + #include -#include #include +#include -#include "lttng-ctl-helper.hpp" +#include /* * Add an output object to a session identified by name. * * Return 0 on success or else a negative LTTNG_ERR code. */ -int lttng_snapshot_add_output(const char *session_name, - struct lttng_snapshot_output *output) +int lttng_snapshot_add_output(const char *session_name, struct lttng_snapshot_output *output) { int ret; struct lttcomm_session_msg lsm; @@ -35,15 +35,13 @@ int lttng_snapshot_add_output(const char *session_name, memset(&lsm, 0, sizeof(lsm)); lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_SNAPSHOT_ADD_OUTPUT; - ret = lttng_strncpy(lsm.session.name, session_name, - sizeof(lsm.session.name)); + ret = lttng_strncpy(lsm.session.name, session_name, sizeof(lsm.session.name)); if (ret) { ret = -LTTNG_ERR_INVALID; goto end; } - memcpy(&lsm.u.snapshot_output.output, output, - sizeof(lsm.u.snapshot_output.output)); + memcpy(&lsm.u.snapshot_output.output, output, sizeof(lsm.u.snapshot_output.output)); ret = lttng_ctl_ask_sessiond(&lsm, (void **) &reply); if (ret < 0) { @@ -62,8 +60,7 @@ end: * * Return 0 on success or else a negative LTTNG_ERR code. */ -int lttng_snapshot_del_output(const char *session_name, - struct lttng_snapshot_output *output) +int lttng_snapshot_del_output(const char *session_name, struct lttng_snapshot_output *output) { int ret; struct lttcomm_session_msg lsm; @@ -76,17 +73,15 @@ int lttng_snapshot_del_output(const char *session_name, memset(&lsm, 0, sizeof(lsm)); lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_SNAPSHOT_DEL_OUTPUT; - ret = lttng_strncpy(lsm.session.name, session_name, - sizeof(lsm.session.name)); + ret = lttng_strncpy(lsm.session.name, session_name, sizeof(lsm.session.name)); if (ret) { ret = -LTTNG_ERR_INVALID; goto end; } - memcpy(&lsm.u.snapshot_output.output, output, - sizeof(lsm.u.snapshot_output.output)); + memcpy(&lsm.u.snapshot_output.output, output, sizeof(lsm.u.snapshot_output.output)); - ret = lttng_ctl_ask_sessiond(&lsm, NULL); + ret = lttng_ctl_ask_sessiond(&lsm, nullptr); end: return ret; } @@ -98,12 +93,11 @@ end: * Return 0 on success or else a negative LTTNG_ERR code and the list pointer * is untouched. */ -int lttng_snapshot_list_output(const char *session_name, - struct lttng_snapshot_output_list **list) +int lttng_snapshot_list_output(const char *session_name, struct lttng_snapshot_output_list **list) { int ret; struct lttcomm_session_msg lsm; - struct lttng_snapshot_output_list *new_list = NULL; + struct lttng_snapshot_output_list *new_list = nullptr; if (!session_name || !list) { ret = -LTTNG_ERR_INVALID; @@ -113,8 +107,7 @@ int lttng_snapshot_list_output(const char *session_name, memset(&lsm, 0, sizeof(lsm)); lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_SNAPSHOT_LIST_OUTPUT; - ret = lttng_strncpy(lsm.session.name, session_name, - sizeof(lsm.session.name)); + ret = lttng_strncpy(lsm.session.name, session_name, sizeof(lsm.session.name)); if (ret) { ret = -LTTNG_ERR_INVALID; goto error; @@ -148,10 +141,10 @@ error: * Return the next object on success or else NULL indicating the end of the * list. */ -struct lttng_snapshot_output *lttng_snapshot_output_list_get_next( - struct lttng_snapshot_output_list *list) +struct lttng_snapshot_output * +lttng_snapshot_output_list_get_next(struct lttng_snapshot_output_list *list) { - struct lttng_snapshot_output *output = NULL; + struct lttng_snapshot_output *output = nullptr; if (!list) { goto error; @@ -196,8 +189,8 @@ void lttng_snapshot_output_list_destroy(struct lttng_snapshot_output_list *list) * Return 0 on success or else a negative LTTNG_ERR value. */ int lttng_snapshot_record(const char *session_name, - struct lttng_snapshot_output *output, - int wait __attribute__((unused))) + struct lttng_snapshot_output *output, + int wait __attribute__((unused))) { int ret; struct lttcomm_session_msg lsm; @@ -210,8 +203,7 @@ int lttng_snapshot_record(const char *session_name, memset(&lsm, 0, sizeof(lsm)); lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_SNAPSHOT_RECORD; - ret = lttng_strncpy(lsm.session.name, session_name, - sizeof(lsm.session.name)); + ret = lttng_strncpy(lsm.session.name, session_name, sizeof(lsm.session.name)); if (ret) { ret = -LTTNG_ERR_INVALID; goto end; @@ -223,12 +215,11 @@ int lttng_snapshot_record(const char *session_name, * record. */ if (output) { - memcpy(&lsm.u.snapshot_record.output, output, - sizeof(lsm.u.snapshot_record.output)); + memcpy(&lsm.u.snapshot_record.output, output, sizeof(lsm.u.snapshot_record.output)); } /* The wait param is ignored. */ - ret = lttng_ctl_ask_sessiond(&lsm, NULL); + ret = lttng_ctl_ask_sessiond(&lsm, nullptr); end: return ret; } @@ -270,8 +261,7 @@ uint32_t lttng_snapshot_output_get_id(const struct lttng_snapshot_output *output return output->id; } -const char *lttng_snapshot_output_get_name( - const struct lttng_snapshot_output *output) +const char *lttng_snapshot_output_get_name(const struct lttng_snapshot_output *output) { return output->name; } @@ -286,8 +276,7 @@ const char *lttng_snapshot_output_get_ctrl_url(const struct lttng_snapshot_outpu return output->ctrl_url; } -uint64_t lttng_snapshot_output_get_maxsize( - const struct lttng_snapshot_output *output) +uint64_t lttng_snapshot_output_get_maxsize(const struct lttng_snapshot_output *output) { return output->max_size; } @@ -296,8 +285,7 @@ uint64_t lttng_snapshot_output_get_maxsize( * Setter family functions for snapshot output. */ -int lttng_snapshot_output_set_id(uint32_t id, - struct lttng_snapshot_output *output) +int lttng_snapshot_output_set_id(uint32_t id, struct lttng_snapshot_output *output) { if (!output || id == 0) { return -LTTNG_ERR_INVALID; @@ -307,8 +295,7 @@ int lttng_snapshot_output_set_id(uint32_t id, return 0; } -int lttng_snapshot_output_set_size(uint64_t size, - struct lttng_snapshot_output *output) +int lttng_snapshot_output_set_size(uint64_t size, struct lttng_snapshot_output *output) { if (!output) { return -LTTNG_ERR_INVALID; @@ -318,8 +305,7 @@ int lttng_snapshot_output_set_size(uint64_t size, return 0; } -int lttng_snapshot_output_set_name(const char *name, - struct lttng_snapshot_output *output) +int lttng_snapshot_output_set_name(const char *name, struct lttng_snapshot_output *output) { int ret; @@ -338,8 +324,7 @@ end: return ret; } -int lttng_snapshot_output_set_ctrl_url(const char *url, - struct lttng_snapshot_output *output) +int lttng_snapshot_output_set_ctrl_url(const char *url, struct lttng_snapshot_output *output) { int ret; @@ -358,8 +343,7 @@ end: return ret; } -int lttng_snapshot_output_set_data_url(const char *url, - struct lttng_snapshot_output *output) +int lttng_snapshot_output_set_data_url(const char *url, struct lttng_snapshot_output *output) { int ret; @@ -378,11 +362,10 @@ end: return ret; } -int lttng_snapshot_output_set_local_path(const char *path, - struct lttng_snapshot_output *output) +int lttng_snapshot_output_set_local_path(const char *path, struct lttng_snapshot_output *output) { int ret; - struct lttng_uri *uris = NULL; + struct lttng_uri *uris = nullptr; ssize_t num_uris; if (!path || !output) { @@ -390,7 +373,7 @@ int lttng_snapshot_output_set_local_path(const char *path, goto end; } - num_uris = uri_parse_str_urls(path, NULL, &uris); + num_uris = uri_parse_str_urls(path, nullptr, &uris); if (num_uris != 1) { ret = -LTTNG_ERR_INVALID; goto end; @@ -412,11 +395,10 @@ end: return ret; } -int lttng_snapshot_output_set_network_url(const char *url, - struct lttng_snapshot_output *output) +int lttng_snapshot_output_set_network_url(const char *url, struct lttng_snapshot_output *output) { int ret; - struct lttng_uri *uris = NULL; + struct lttng_uri *uris = nullptr; ssize_t num_uris; if (!url || !output) { @@ -424,20 +406,18 @@ int lttng_snapshot_output_set_network_url(const char *url, goto end; } - num_uris = uri_parse_str_urls(url, NULL, &uris); + num_uris = uri_parse_str_urls(url, nullptr, &uris); if (num_uris != 2) { ret = -LTTNG_ERR_INVALID; goto end; } - if (uris[0].dtype != LTTNG_DST_IPV4 && - uris[0].dtype != LTTNG_DST_IPV6) { + if (uris[0].dtype != LTTNG_DST_IPV4 && uris[0].dtype != LTTNG_DST_IPV6) { ret = -LTTNG_ERR_INVALID; goto end; } - if (uris[1].dtype != LTTNG_DST_IPV4 && - uris[1].dtype != LTTNG_DST_IPV6) { + if (uris[1].dtype != LTTNG_DST_IPV4 && uris[1].dtype != LTTNG_DST_IPV6) { ret = -LTTNG_ERR_INVALID; goto end; } @@ -453,12 +433,12 @@ end: return ret; } -int lttng_snapshot_output_set_network_urls( - const char *ctrl_url, const char *data_url, - struct lttng_snapshot_output *output) +int lttng_snapshot_output_set_network_urls(const char *ctrl_url, + const char *data_url, + struct lttng_snapshot_output *output) { int ret; - struct lttng_uri *uris = NULL; + struct lttng_uri *uris = nullptr; ssize_t num_uris; if (!ctrl_url || !data_url || !output) { @@ -472,14 +452,12 @@ int lttng_snapshot_output_set_network_urls( goto end; } - if (uris[0].dtype != LTTNG_DST_IPV4 && - uris[0].dtype != LTTNG_DST_IPV6) { + if (uris[0].dtype != LTTNG_DST_IPV4 && uris[0].dtype != LTTNG_DST_IPV6) { ret = -LTTNG_ERR_INVALID; goto end; } - if (uris[1].dtype != LTTNG_DST_IPV4 && - uris[1].dtype != LTTNG_DST_IPV6) { + if (uris[1].dtype != LTTNG_DST_IPV4 && uris[1].dtype != LTTNG_DST_IPV6) { ret = -LTTNG_ERR_INVALID; goto end; }