From 942003e52b8fe43bfb8f28a1884d3bda7e6d1e0b Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Mon, 7 Mar 2022 15:59:30 -0500 Subject: [PATCH] configure: add '-Wlogical-op' to warning flags MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Change-Id: I0516add62151b22352f96d1e62871a013b8fa6f3 Signed-off-by: Michael Jeanson Signed-off-by: Jérémie Galarneau --- configure.ac | 1 + src/bin/lttng-relayd/main.cpp | 12 ++++++++++++ src/bin/lttng-sessiond/rotation-thread.cpp | 3 +++ src/common/macros.h | 3 +++ src/common/unix.cpp | 12 ++++++++++++ 5 files changed, 31 insertions(+) diff --git a/configure.ac b/configure.ac index 5a63255c4..8ca893f75 100644 --- a/configure.ac +++ b/configure.ac @@ -61,6 +61,7 @@ m4_define([WARN_FLAGS_COMMON_LIST], [ dnl -Wall dnl -Wnull-dereference dnl -Wundef dnl + -Wlogical-op dnl dnl We currently get this warning when building with Clang: dnl dnl /usr/include/setjmp.h:54:12: error: declaration of built-in function '__sigsetjmp' requires the declaration of the 'jmp_buf' type, commonly provided in the header . [-Werror,-Wincomplete-setjmp-declaration] diff --git a/src/bin/lttng-relayd/main.cpp b/src/bin/lttng-relayd/main.cpp index 33684addd..72bf30b7e 100644 --- a/src/bin/lttng-relayd/main.cpp +++ b/src/bin/lttng-relayd/main.cpp @@ -3405,7 +3405,10 @@ static enum relay_connection_status relay_process_control_receive_payload( reception_buffer->data + state->received, state->left_to_receive, MSG_DONTWAIT); if (ret < 0) { + DIAGNOSTIC_PUSH + DIAGNOSTIC_IGNORE_LOGICAL_OP if (errno != EAGAIN && errno != EWOULDBLOCK) { + DIAGNOSTIC_POP PERROR("Unable to receive command payload on sock %d", conn->sock->fd); status = RELAY_CONNECTION_STATUS_ERROR; @@ -3478,7 +3481,10 @@ static enum relay_connection_status relay_process_control_receive_header( reception_buffer->data + state->received, state->left_to_receive, MSG_DONTWAIT); if (ret < 0) { + DIAGNOSTIC_PUSH + DIAGNOSTIC_IGNORE_LOGICAL_OP if (errno != EAGAIN && errno != EWOULDBLOCK) { + DIAGNOSTIC_POP PERROR("Unable to receive control command header on sock %d", conn->sock->fd); status = RELAY_CONNECTION_STATUS_ERROR; @@ -3589,7 +3595,10 @@ static enum relay_connection_status relay_process_data_receive_header( state->header_reception_buffer + state->received, state->left_to_receive, MSG_DONTWAIT); if (ret < 0) { + DIAGNOSTIC_PUSH + DIAGNOSTIC_IGNORE_LOGICAL_OP if (errno != EAGAIN && errno != EWOULDBLOCK) { + DIAGNOSTIC_POP PERROR("Unable to receive data header on sock %d", conn->sock->fd); status = RELAY_CONNECTION_STATUS_ERROR; } @@ -3716,7 +3725,10 @@ static enum relay_connection_status relay_process_data_receive_payload( ret = conn->sock->ops->recvmsg(conn->sock, data_buffer, recv_size, MSG_DONTWAIT); if (ret < 0) { + DIAGNOSTIC_PUSH + DIAGNOSTIC_IGNORE_LOGICAL_OP if (errno != EAGAIN && errno != EWOULDBLOCK) { + DIAGNOSTIC_POP PERROR("Socket %d error", conn->sock->fd); status = RELAY_CONNECTION_STATUS_ERROR; } diff --git a/src/bin/lttng-sessiond/rotation-thread.cpp b/src/bin/lttng-sessiond/rotation-thread.cpp index a2b92a858..473138cf8 100644 --- a/src/bin/lttng-sessiond/rotation-thread.cpp +++ b/src/bin/lttng-sessiond/rotation-thread.cpp @@ -215,7 +215,10 @@ void rotation_thread_enqueue_job(struct rotation_thread_timer_queue *queue, * the job will be processed when the rotation_thread catches * up. */ + DIAGNOSTIC_PUSH + DIAGNOSTIC_IGNORE_LOGICAL_OP if (errno == EAGAIN || errno == EWOULDBLOCK) { + DIAGNOSTIC_POP /* * Not an error, but would be surprising and indicate * that the rotation thread can't keep up with the diff --git a/src/common/macros.h b/src/common/macros.h index 43a4d692b..3e1757350 100644 --- a/src/common/macros.h +++ b/src/common/macros.h @@ -94,12 +94,15 @@ void *zmalloc(size_t len) # define DIAGNOSTIC_IGNORE_SUGGEST_ATTRIBUTE_FORMAT # define DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL \ _Pragma("GCC diagnostic ignored \"-Wformat-nonliteral\"") +# define DIAGNOSTIC_IGNORE_LOGICAL_OP #else /* GCC */ # define DIAGNOSTIC_IGNORE_SUGGEST_ATTRIBUTE_FORMAT \ _Pragma("GCC diagnostic ignored \"-Wsuggest-attribute=format\"") # define DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL \ _Pragma("GCC diagnostic ignored \"-Wformat-nonliteral\"") +# define DIAGNOSTIC_IGNORE_LOGICAL_OP \ + _Pragma("GCC diagnostic ignored \"-Wlogical-op\"") #endif /* Used to make specific C++ functions to C code. */ diff --git a/src/common/unix.cpp b/src/common/unix.cpp index 091587f48..beeb69572 100644 --- a/src/common/unix.cpp +++ b/src/common/unix.cpp @@ -239,8 +239,11 @@ retry: /* * We consider EPIPE and EAGAIN/EWOULDBLOCK as expected. */ + DIAGNOSTIC_PUSH + DIAGNOSTIC_IGNORE_LOGICAL_OP if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EPIPE) { + DIAGNOSTIC_POP /* * Nothing was recv. */ @@ -343,8 +346,11 @@ retry: /* * We consider EPIPE and EAGAIN/EWOULDBLOCK as expected. */ + DIAGNOSTIC_PUSH + DIAGNOSTIC_IGNORE_LOGICAL_OP if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EPIPE) { + DIAGNOSTIC_POP /* * This can happen in non blocking mode. * Nothing was sent. @@ -569,7 +575,10 @@ retry: /* * We consider EPIPE and EAGAIN/EWOULDBLOCK as expected. */ + DIAGNOSTIC_PUSH + DIAGNOSTIC_IGNORE_LOGICAL_OP if (errno == EAGAIN || errno == EWOULDBLOCK) { + DIAGNOSTIC_POP /* * This can happen in non blocking mode. * Nothing was sent. @@ -883,7 +892,10 @@ retry: /* * We consider EPIPE and EAGAIN/EWOULDBLOCK as expected. */ + DIAGNOSTIC_PUSH + DIAGNOSTIC_IGNORE_LOGICAL_OP if (errno == EAGAIN || errno == EWOULDBLOCK) { + DIAGNOSTIC_POP /* * This can happen in non blocking mode. * Nothing was recv. -- 2.34.1