Prepare for '-Wunused-parameter'
[lttng-tools.git] / src / bin / lttng-sessiond / client.cpp
index 16f1b1bcd2eae31b0c8e2c09adacef30acb73948..4c1f6954b952ae1c4d553c5e52a71d48569ffc79 100644 (file)
@@ -583,7 +583,8 @@ error_create:
 /*
  * Count number of session permitted by uid/gid.
  */
-static unsigned int lttng_sessions_count(uid_t uid, gid_t gid)
+static unsigned int lttng_sessions_count(uid_t uid,
+               gid_t gid __attribute__((unused)))
 {
        unsigned int i = 0;
        struct ltt_session *session;
@@ -763,6 +764,10 @@ static enum lttng_error_code receive_lttng_event(struct command_ctx *cmd_ctx,
        ssize_t sock_recv_len;
        enum lttng_error_code ret_code;
        struct lttng_payload event_payload;
+       struct lttng_event *local_event = NULL;
+       char *local_filter_expression = NULL;
+       struct lttng_bytecode *local_bytecode = NULL;
+       struct lttng_event_exclusion *local_exclusion = NULL;
 
        lttng_payload_init(&event_payload);
        if (cmd_ctx->lsm.cmd_type == LTTNG_ENABLE_EVENT) {
@@ -810,23 +815,45 @@ static enum lttng_error_code receive_lttng_event(struct command_ctx *cmd_ctx,
 
        /* Deserialize event. */
        {
+               ssize_t len;
                struct lttng_payload_view event_view =
                                lttng_payload_view_from_payload(
                                                &event_payload, 0, -1);
 
-               if (lttng_event_create_from_payload(&event_view, out_event,
-                                   out_exclusion, out_filter_expression,
-                                   out_bytecode) != event_len) {
-                       ERR("Invalid event received as part of command payload");
+               len = lttng_event_create_from_payload(&event_view, &local_event,
+                                   &local_exclusion, &local_filter_expression,
+                                   &local_bytecode);
+
+               if (len < 0) {
+                       ERR("Failed to create an event from the received buffer");
+                       ret_code = LTTNG_ERR_INVALID_PROTOCOL;
+                       goto end;
+               }
+
+               if (len != event_len) {
+                       ERR("Userspace probe location from the received buffer is not the advertised length: header length = %zu" PRIu32 ", payload length = %zd", event_len, len);
                        ret_code = LTTNG_ERR_INVALID_PROTOCOL;
                        goto end;
                }
        }
 
+       *out_event = local_event;
+       *out_exclusion = local_exclusion;
+       *out_filter_expression = local_filter_expression;
+       *out_bytecode = local_bytecode;
+       local_event = NULL;
+       local_exclusion = NULL;
+       local_filter_expression = NULL;
+       local_bytecode = NULL;
+
        ret_code = LTTNG_OK;
 
 end:
        lttng_payload_reset(&event_payload);
+       lttng_event_destroy(local_event);
+       free(local_filter_expression);
+       free(local_bytecode);
+       free(local_exclusion);
        return ret_code;
 }
 
@@ -842,6 +869,7 @@ static enum lttng_error_code receive_lttng_event_context(
        ssize_t sock_recv_len;
        enum lttng_error_code ret_code;
        struct lttng_payload event_context_payload;
+       struct lttng_event_context *context = NULL;
 
        lttng_payload_init(&event_context_payload);
 
@@ -864,22 +892,33 @@ static enum lttng_error_code receive_lttng_event_context(
 
        /* Deserialize event. */
        {
+               ssize_t len;
                struct lttng_payload_view event_context_view =
                                lttng_payload_view_from_payload(
                                                &event_context_payload, 0, -1);
 
-               if (lttng_event_context_create_from_payload(
-                               &event_context_view, out_event_context) !=
-                               event_context_len) {
-                       ERR("Invalid event context received as part of command payload");
+               len = lttng_event_context_create_from_payload(
+                               &event_context_view, &context);
+
+               if (len < 0) {
+                       ERR("Failed to create a event context from the received buffer");
+                       ret_code = LTTNG_ERR_INVALID_PROTOCOL;
+                       goto end;
+               }
+
+               if (len != event_context_len) {
+                       ERR("Event context from the received buffer is not the advertised length: expected length = %zu, payload length = %zd", event_context_len, len);
                        ret_code = LTTNG_ERR_INVALID_PROTOCOL;
                        goto end;
                }
        }
 
+       *out_event_context = context;
+       context = NULL;
        ret_code = LTTNG_OK;
 
 end:
+       lttng_event_context_destroy(context);
        lttng_payload_reset(&event_context_payload);
        return ret_code;
 }
@@ -1353,7 +1392,7 @@ skip_domain:
        switch (cmd_ctx->lsm.cmd_type) {
        case LTTNG_ADD_CONTEXT:
        {
-               struct lttng_event_context *event_context;
+               struct lttng_event_context *event_context = NULL;
                const enum lttng_error_code ret_code =
                        receive_lttng_event_context(
                                cmd_ctx, *sock, sock_error, &event_context);
@@ -1654,7 +1693,6 @@ skip_domain:
                }
 
                original_payload_size = cmd_ctx->reply_payload.buffer.size;
-               ERR("original payload size = %i", (int) original_payload_size);
 
                session_lock_list();
                ret_code = cmd_list_tracepoint_fields(
@@ -1667,7 +1705,6 @@ skip_domain:
 
                payload_size = cmd_ctx->reply_payload.buffer.size -
                                command_header_size - original_payload_size;
-               ERR("payload size = %i", (int) payload_size);
                update_lttng_msg(cmd_ctx, command_header_size, payload_size);
 
                ret = LTTNG_OK;
@@ -2005,8 +2042,7 @@ skip_domain:
        {
                lttng_snapshot_output output = cmd_ctx->lsm.u.snapshot_record.output;
                ret = cmd_snapshot_record(cmd_ctx->session,
-                               &output,
-                               cmd_ctx->lsm.u.snapshot_record.wait);
+                               &output, 0); // RFC: set to zero since it's ignored by cmd_snapshot_record
                break;
        }
        case LTTNG_CREATE_SESSION_EXT:
@@ -2399,7 +2435,7 @@ static void cleanup_client_thread(void *data)
        lttng_pipe_destroy(quit_pipe);
 }
 
-static void thread_init_cleanup(void *data)
+static void thread_init_cleanup(void *data __attribute__((unused)))
 {
        set_thread_status(false);
 }
This page took 0.024759 seconds and 4 git commands to generate.