DBG2("Receiving code from consumer err_sock");
- /* Getting status code from kconsumerd */
- ret = lttcomm_recv_unix_sock(sock, &code, sizeof(enum lttcomm_return_code));
+ /* Getting status code from consumerd */
+ {
+ std::int32_t comm_code = 0;
+
+ ret = lttcomm_recv_unix_sock(sock, &comm_code, sizeof(comm_code));
+ code = static_cast<decltype(code)>(comm_code);
+ }
if (ret <= 0) {
mark_thread_intialization_as_failed(notifiers);
goto error;
goto error;
}
health_code_update();
- /* Wait for any kconsumerd error */
- ret = lttcomm_recv_unix_sock(
- sock, &code, sizeof(enum lttcomm_return_code));
+ /* Wait for any consumerd error */
+ {
+ std::int32_t comm_code = 0;
+
+ ret = lttcomm_recv_unix_sock(
+ sock, &comm_code, sizeof(comm_code));
+ code = static_cast<decltype(code)>(comm_code);
+ }
if (ret <= 0) {
ERR("consumer closed the command socket");
goto error;
#include <sys/mman.h>
#include <sys/socket.h>
#include <sys/types.h>
+#include <type_traits>
#include <unistd.h>
lttng_consumer_global_data the_consumer_data;
* Send return code to the session daemon.
* If the socket is not defined, we return 0, it is not a fatal error
*/
-int lttng_consumer_send_error(struct lttng_consumer_local_data *ctx, int cmd)
+int lttng_consumer_send_error(struct lttng_consumer_local_data *ctx,
+ enum lttcomm_return_code error_code)
{
if (ctx->consumer_error_socket > 0) {
+ const std::int32_t comm_code = std::int32_t(error_code);
+
+ static_assert(
+ sizeof(comm_code) >= sizeof(std::underlying_type<lttcomm_return_code>),
+ "Fixed-size communication type too small to accomodate lttcomm_return_code");
return lttcomm_send_unix_sock(
- ctx->consumer_error_socket, &cmd, sizeof(enum lttcomm_sessiond_command));
+ ctx->consumer_error_socket, &comm_code, sizeof(comm_code));
}
return 0;
* Returns the return code of sendmsg : the number of bytes transmitted or -1
* on error.
*/
-int lttng_consumer_send_error(struct lttng_consumer_local_data *ctx, int cmd);
+int lttng_consumer_send_error(struct lttng_consumer_local_data *ctx,
+ enum lttcomm_return_code error_code);
/*
* Called from signal handler to ensure a clean exit.