Clean-up: consumer.hpp: coding style indentation fix
[lttng-tools.git] / src / bin / lttng-sessiond / clear.cpp
index a0817c2daff618c90936cb48a2f0d51fe999b91e..ced9925943b83d543676ce45d191806f6d8472f2 100644 (file)
@@ -6,34 +6,34 @@
  */
 
 #define _LGPL_SOURCE
+#include "clear.hpp"
+#include "cmd.hpp"
+#include "kernel.hpp"
+#include "session.hpp"
+#include "ust-app.hpp"
+
+#include <common/defaults.hpp>
+#include <common/error.hpp>
+#include <common/utils.hpp>
+
 #include <inttypes.h>
 #include <string.h>
 #include <unistd.h>
 
-#include <common/defaults.h>
-#include <common/error.h>
-#include <common/utils.h>
-
-#include "clear.h"
-#include "session.h"
-#include "ust-app.h"
-#include "kernel.h"
-#include "cmd.h"
-
+namespace {
 struct cmd_clear_session_reply_context {
        int reply_sock_fd;
 };
+} /* namespace */
 
-static
-void cmd_clear_session_reply(const struct ltt_session *session,
-               void *_reply_context)
+static void cmd_clear_session_reply(const struct ltt_session *session, void *_reply_context)
 {
        int ret;
        ssize_t comm_ret;
        const struct cmd_clear_session_reply_context *reply_context =
-                       (cmd_clear_session_reply_context *) _reply_context;
+               (cmd_clear_session_reply_context *) _reply_context;
        struct lttcomm_lttng_msg llm = {
-               .cmd_type = LTTNG_CLEAR_SESSION,
+               .cmd_type = LTTCOMM_SESSIOND_COMMAND_CLEAR_SESSION,
                .ret_code = LTTNG_OK,
                .pid = UINT32_MAX,
                .cmd_header_size = 0,
@@ -42,11 +42,9 @@ void cmd_clear_session_reply(const struct ltt_session *session,
        };
 
        DBG("End of clear command: replying to client");
-       comm_ret = lttcomm_send_unix_sock(reply_context->reply_sock_fd,
-                       &llm, sizeof(llm));
+       comm_ret = lttcomm_send_unix_sock(reply_context->reply_sock_fd, &llm, sizeof(llm));
        if (comm_ret != (ssize_t) sizeof(llm)) {
-               ERR("Failed to send result of session \"%s\" clear to client",
-                               session->name);
+               ERR("Failed to send result of session \"%s\" clear to client", session->name);
        }
        ret = close(reply_context->reply_sock_fd);
        if (ret) {
@@ -58,7 +56,7 @@ void cmd_clear_session_reply(const struct ltt_session *session,
 int cmd_clear_session(struct ltt_session *session, int *sock_fd)
 {
        int ret = LTTNG_OK;
-       struct cmd_clear_session_reply_context *reply_context = NULL;
+       struct cmd_clear_session_reply_context *reply_context = nullptr;
        bool session_was_active = false;
        struct ltt_kernel_session *ksession;
        struct ltt_ust_session *usess;
@@ -67,7 +65,7 @@ int cmd_clear_session(struct ltt_session *session, int *sock_fd)
        usess = session->ust_session;
 
        if (sock_fd) {
-               reply_context = (cmd_clear_session_reply_context *) zmalloc(sizeof(*reply_context));
+               reply_context = zmalloc<cmd_clear_session_reply_context>();
                if (!reply_context) {
                        ret = LTTNG_ERR_NOMEM;
                        goto end;
@@ -76,23 +74,22 @@ int cmd_clear_session(struct ltt_session *session, int *sock_fd)
        }
 
        if (!session->has_been_started) {
-                /*
-                 * Nothing to be cleared, this is not an error: there is
-                 * indeed nothing to do, and there is no reason why we
-                 * should return an error to the user.
-                 */
-                goto end;
+               /*
+                * Nothing to be cleared, this is not an error: there is
+                * indeed nothing to do, and there is no reason why we
+                * should return an error to the user.
+                */
+               goto end;
        }
 
        /* Unsupported feature in lttng-relayd before 2.11. */
        if (session->consumer->type == CONSUMER_DST_NET &&
-                       (session->consumer->relay_major_version == 2 &&
-                       session->consumer->relay_minor_version < 12)) {
+           (session->consumer->relay_major_version == 2 &&
+            session->consumer->relay_minor_version < 12)) {
                ret = LTTNG_ERR_CLEAR_NOT_AVAILABLE_RELAY;
                goto end;
        }
-       if (session->consumer->type == CONSUMER_DST_NET &&
-                       !session->consumer->relay_allows_clear) {
+       if (session->consumer->type == CONSUMER_DST_NET && !session->consumer->relay_allows_clear) {
                ret = LTTNG_ERR_CLEAR_NOT_AVAILABLE_RELAY;
                goto end;
        }
@@ -151,9 +148,8 @@ int cmd_clear_session(struct ltt_session *session, int *sock_fd)
                 * Use rotation to delete local and remote stream files.
                 */
                if (reply_context) {
-                       ret = session_add_clear_notifier(session,
-                                       cmd_clear_session_reply,
-                                       (void *) reply_context);
+                       ret = session_add_clear_notifier(
+                               session, cmd_clear_session_reply, (void *) reply_context);
                        if (ret) {
                                ret = LTTNG_ERR_FATAL;
                                goto end;
@@ -162,11 +158,11 @@ int cmd_clear_session(struct ltt_session *session, int *sock_fd)
                         * On success, ownership of reply_context has been
                         * passed to session_add_clear_notifier().
                         */
-                       reply_context = NULL;
+                       reply_context = nullptr;
                        *sock_fd = -1;
                }
-               ret = cmd_rotate_session(session, NULL, true,
-                       LTTNG_TRACE_CHUNK_COMMAND_TYPE_DELETE);
+               ret = cmd_rotate_session(
+                       session, nullptr, true, LTTNG_TRACE_CHUNK_COMMAND_TYPE_DELETE);
                if (ret != LTTNG_OK) {
                        goto end;
                }
@@ -176,9 +172,8 @@ int cmd_clear_session(struct ltt_session *session, int *sock_fd)
        }
        if (session_was_active) {
                /* Kernel tracing */
-               if (ksession != NULL) {
-                       DBG("Start kernel tracing session \"%s\"",
-                                       session->name);
+               if (ksession != nullptr) {
+                       DBG("Start kernel tracing session \"%s\"", session->name);
                        ret = start_kernel_session(ksession);
                        if (ret != LTTNG_OK) {
                                goto end;
This page took 0.024729 seconds and 4 git commands to generate.