Fix: fix compilation errors when using--disable-epoll
diff mbox series

Message ID 20190527162838.11675-1-simon.marchi@efficios.com
State New
Headers show
Series
  • Fix: fix compilation errors when using--disable-epoll
Related show

Commit Message

Simon Marchi May 27, 2019, 4:28 p.m. UTC
I get this error:

      CC       compat-poll.lo
    /home/smarchi/src/lttng-tools/src/common/compat/compat-poll.c: In function ?compat_poll_wait?:
    /home/smarchi/src/lttng-tools/src/common/compat/compat-poll.c:353:7: error: ?ipfd? undeclared (first use in this function)
       if (ipfd->revents != 0) {
           ^~~~

which just seems like a typo.

A second error occurs later:

  CC       test_utils_compat_poll.o
/home/smarchi/src/lttng-tools/tests/unit/test_utils_compat_poll.c: In function ?test_mod_wait?:
/home/smarchi/src/lttng-tools/tests/unit/test_utils_compat_poll.c:138:24: error: ?MAGIC_VALUE? undeclared (first use in this function)
  char rbuf = 0, tbuf = MAGIC_VALUE;
                        ^~~~~~~~~~~

The problem is that MAGIC_VALUE is defined inside an #ifdef HAVE_EPOLL,
but is used even if !HAVE_EPOLL.  Move it outside the ifdef, and adjust
the spelling and grammatical errors in the comments.

Note that compat-poll.c is only compiled if epoll is not available or
disabled, which you can do with --disable-epoll.  In my case,
I ended up using compat-poll.c because the AX_HAVE_EPOLL macro does not
work correctly when configuring with "-Wall -Werror".  I'll tackle this
issue separately.

I only built-tested the proposed change, and I don't know anything about
this code, so please check carefully that it is right.

Signed-off-by: Simon Marchi <simon.marchi at efficios.com>
---
 src/common/compat/compat-poll.c     |  2 +-
 tests/unit/test_utils_compat_poll.c | 12 +++++++-----
 2 files changed, 8 insertions(+), 6 deletions(-)

Comments

Simon Marchi Aug. 20, 2019, 1:47 a.m. UTC | #1
On 2019-05-27 12:28 p.m., Simon Marchi wrote:
> I get this error:
> 
>       CC       compat-poll.lo
>     /home/smarchi/src/lttng-tools/src/common/compat/compat-poll.c: In function ?compat_poll_wait?:
>     /home/smarchi/src/lttng-tools/src/common/compat/compat-poll.c:353:7: error: ?ipfd? undeclared (first use in this function)
>        if (ipfd->revents != 0) {
>            ^~~~
> 
> which just seems like a typo.
> 
> A second error occurs later:
> 
>   CC       test_utils_compat_poll.o
> /home/smarchi/src/lttng-tools/tests/unit/test_utils_compat_poll.c: In function ?test_mod_wait?:
> /home/smarchi/src/lttng-tools/tests/unit/test_utils_compat_poll.c:138:24: error: ?MAGIC_VALUE? undeclared (first use in this function)
>   char rbuf = 0, tbuf = MAGIC_VALUE;
>                         ^~~~~~~~~~~
> 
> The problem is that MAGIC_VALUE is defined inside an #ifdef HAVE_EPOLL,
> but is used even if !HAVE_EPOLL.  Move it outside the ifdef, and adjust
> the spelling and grammatical errors in the comments.
> 
> Note that compat-poll.c is only compiled if epoll is not available or
> disabled, which you can do with --disable-epoll.  In my case,
> I ended up using compat-poll.c because the AX_HAVE_EPOLL macro does not
> work correctly when configuring with "-Wall -Werror".  I'll tackle this
> issue separately.
> 
> I only built-tested the proposed change, and I don't know anything about
> this code, so please check carefully that it is right.
> 
> Signed-off-by: Simon Marchi <simon.marchi at efficios.com>
> ---
>  src/common/compat/compat-poll.c     |  2 +-
>  tests/unit/test_utils_compat_poll.c | 12 +++++++-----
>  2 files changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/src/common/compat/compat-poll.c b/src/common/compat/compat-poll.c
> index 0220b27854ab..254ce271e71c 100644
> --- a/src/common/compat/compat-poll.c
> +++ b/src/common/compat/compat-poll.c
> @@ -350,7 +350,7 @@ int compat_poll_wait(struct lttng_poll_event *events, int timeout)
>  		struct pollfd *idle_pfd = &events->wait.events[idle_pfd_index];
>  		struct pollfd *current_pfd = &events->wait.events[i];
>  
> -		if (ipfd->revents != 0) {
> +		if (idle_pfd->revents != 0) {
>  			swap_pfd = *current_pfd;
>  			*current_pfd = *idle_pfd;
>  			*idle_pfd = swap_pfd;
> diff --git a/tests/unit/test_utils_compat_poll.c b/tests/unit/test_utils_compat_poll.c
> index 1eb327a6a708..c8cac544d531 100644
> --- a/tests/unit/test_utils_compat_poll.c
> +++ b/tests/unit/test_utils_compat_poll.c
> @@ -47,6 +47,13 @@ int lttng_opt_mi;
>  #define NUM_TESTS 45
>  #endif
>  
> +/*
> + * Non-zero 8-bits arbitrary value below 0x7f to ensure no sign extension
> + * occurs.  It is used to verify that the value is properly propagated through
> + * the pipe.
> + */
> +#define MAGIC_VALUE ((char)0x5A)
> +
>  #ifdef HAVE_EPOLL
>  #if defined(HAVE_EPOLL_CREATE1) && defined(EPOLL_CLOEXEC)
>  #define CLOE_VALUE EPOLL_CLOEXEC
> @@ -54,11 +61,6 @@ int lttng_opt_mi;
>  #define CLOE_VALUE FD_CLOEXEC
>  #endif
>  
> -/* Non-zero 8-bits arbitrary value below 0x7f to ensure no sign extension
> - * used to verify that the value is properly propagated throught the pipe.
> - */
> -#define MAGIC_VALUE ((char)0x5A)
> -
>  void test_epoll_compat(void)
>  {
>  	/*
> 

Ping.

Patch
diff mbox series

diff --git a/src/common/compat/compat-poll.c b/src/common/compat/compat-poll.c
index 0220b27854ab..254ce271e71c 100644
--- a/src/common/compat/compat-poll.c
+++ b/src/common/compat/compat-poll.c
@@ -350,7 +350,7 @@  int compat_poll_wait(struct lttng_poll_event *events, int timeout)
 		struct pollfd *idle_pfd = &events->wait.events[idle_pfd_index];
 		struct pollfd *current_pfd = &events->wait.events[i];
 
-		if (ipfd->revents != 0) {
+		if (idle_pfd->revents != 0) {
 			swap_pfd = *current_pfd;
 			*current_pfd = *idle_pfd;
 			*idle_pfd = swap_pfd;
diff --git a/tests/unit/test_utils_compat_poll.c b/tests/unit/test_utils_compat_poll.c
index 1eb327a6a708..c8cac544d531 100644
--- a/tests/unit/test_utils_compat_poll.c
+++ b/tests/unit/test_utils_compat_poll.c
@@ -47,6 +47,13 @@  int lttng_opt_mi;
 #define NUM_TESTS 45
 #endif
 
+/*
+ * Non-zero 8-bits arbitrary value below 0x7f to ensure no sign extension
+ * occurs.  It is used to verify that the value is properly propagated through
+ * the pipe.
+ */
+#define MAGIC_VALUE ((char)0x5A)
+
 #ifdef HAVE_EPOLL
 #if defined(HAVE_EPOLL_CREATE1) && defined(EPOLL_CLOEXEC)
 #define CLOE_VALUE EPOLL_CLOEXEC
@@ -54,11 +61,6 @@  int lttng_opt_mi;
 #define CLOE_VALUE FD_CLOEXEC
 #endif
 
-/* Non-zero 8-bits arbitrary value below 0x7f to ensure no sign extension
- * used to verify that the value is properly propagated throught the pipe.
- */
-#define MAGIC_VALUE ((char)0x5A)
-
 void test_epoll_compat(void)
 {
 	/*