bin: compile lttng-consumerd as a C++
[lttng-tools.git] / src / lib / lttng-ctl / clear.c
index 82f6e28045787205cbe61dbeb528c1c0ae49218d..3face64de83ed1f0f1902cacbc5f2a4991d0a8cb 100644 (file)
@@ -7,7 +7,6 @@
  */
 
 #define _LGPL_SOURCE
-#include <assert.h>
 #include <string.h>
 
 #include <lttng/lttng-error.h>
@@ -54,8 +53,8 @@ void lttng_clear_handle_destroy(struct lttng_clear_handle *handle)
                if (ret) {
                        PERROR("Failed to close lttng-sessiond command socket");
                }
-        }
-        lttng_poll_clean(&handle->communication.events);
+       }
+       lttng_poll_clean(&handle->communication.events);
        lttng_dynamic_buffer_reset(&handle->communication.buffer);
        free(handle);
 }
@@ -78,9 +77,9 @@ struct lttng_clear_handle *lttng_clear_handle_create(int sessiond_socket)
 
        ret = lttng_poll_add(&handle->communication.events, sessiond_socket,
                        LPOLLIN | LPOLLHUP | LPOLLRDHUP | LPOLLERR);
-        if (ret) {
+       if (ret) {
                goto error;
-        }
+       }
 
        handle->communication.bytes_left_to_receive =
                        sizeof(struct lttcomm_lttng_msg);
@@ -97,7 +96,7 @@ int handle_state_transition(struct lttng_clear_handle *handle)
 {
        int ret = 0;
 
-       assert(handle->communication.bytes_left_to_receive == 0);
+       LTTNG_ASSERT(handle->communication.bytes_left_to_receive == 0);
 
        switch (handle->communication.state) {
        case COMMUNICATION_STATE_RECEIVE_LTTNG_MSG:
@@ -121,7 +120,7 @@ int handle_state_transition(struct lttng_clear_handle *handle)
                LTTNG_OPTIONAL_SET(&handle->communication.data_size, 0);
                ret = lttng_dynamic_buffer_set_size(
                                &handle->communication.buffer, 0);
-               assert(!ret);
+               LTTNG_ASSERT(!ret);
                break;
        }
        default:
@@ -173,38 +172,37 @@ extern enum lttng_clear_handle_status
        lttng_clear_handle_wait_for_completion(
                struct lttng_clear_handle *handle, int timeout_ms)
 {
-       int ret;
        enum lttng_clear_handle_status status;
        unsigned long time_left_ms = 0;
        const bool has_timeout = timeout_ms > 0;
        struct timespec initial_time;
 
-        if (handle->communication.state == COMMUNICATION_STATE_ERROR) {
+       if (handle->communication.state == COMMUNICATION_STATE_ERROR) {
                status = LTTNG_CLEAR_HANDLE_STATUS_ERROR;
                goto end;
        } else if (handle->communication.state == COMMUNICATION_STATE_END) {
                status = LTTNG_CLEAR_HANDLE_STATUS_COMPLETED;
                goto end;
        }
-        if (has_timeout) {
-               ret = lttng_clock_gettime(CLOCK_MONOTONIC, &initial_time);
+       if (has_timeout) {
+               int ret = lttng_clock_gettime(CLOCK_MONOTONIC, &initial_time);
                if (ret) {
                        status = LTTNG_CLEAR_HANDLE_STATUS_ERROR;
                        goto end;
                }
                time_left_ms = (unsigned long) timeout_ms;
-        }
+       }
 
-        while (handle->communication.state != COMMUNICATION_STATE_END &&
+       while (handle->communication.state != COMMUNICATION_STATE_END &&
                        (time_left_ms || !has_timeout)) {
                int ret;
                uint32_t revents;
-                struct timespec current_time, diff;
+               struct timespec current_time, diff;
                unsigned long diff_ms;
 
-                ret = lttng_poll_wait(&handle->communication.events,
+               ret = lttng_poll_wait(&handle->communication.events,
                                has_timeout ? time_left_ms : -1);
-                if (ret == 0) {
+               if (ret == 0) {
                        /* timeout */
                        break;
                } else if (ret < 0) {
This page took 0.024498 seconds and 4 git commands to generate.