[PATCH] Configure: fix build with -Werror=unused-but-set-variable

Maxim Dounin mdounin at mdounin.ru
Thu Jul 7 13:58:05 UTC 2016


Hello!

On Mon, Jun 27, 2016 at 03:59:19PM -0700, Piotr Sikora wrote:

> # HG changeset patch
> # User Piotr Sikora <piotrsikora at google.com>
> # Date 1467064803 25200
> #      Mon Jun 27 15:00:03 2016 -0700
> # Node ID ad603262a99df74951b05ce30c81ebc381694162
> # Parent  d452cb27639f714bc43b7f3ede417e3e7f8efdd6
> Configure: fix build with -Werror=unused-but-set-variable.
> 
> Signed-off-by: Piotr Sikora <piotrsikora at google.com>
> 
> diff -r d452cb27639f -r ad603262a99d auto/os/linux
> --- a/auto/os/linux
> +++ b/auto/os/linux
> @@ -44,6 +44,7 @@ ngx_feature_test="int efd = 0;
>                    struct epoll_event ee;
>                    ee.events = EPOLLIN|EPOLLOUT|EPOLLET;
>                    ee.data.ptr = NULL;
> +                  (void) ee;
>                    efd = epoll_create(100);
>                    if (efd == -1) return 1;"
>  . auto/feature
> diff -r d452cb27639f -r ad603262a99d auto/unix
> --- a/auto/unix
> +++ b/auto/unix
> @@ -644,7 +644,8 @@ if [ $NGX_IPV6 = YES ]; then
>      ngx_feature_path=
>      ngx_feature_libs=
>      ngx_feature_test="struct sockaddr_in6  sin6;
> -                      sin6.sin6_family = AF_INET6;"
> +                      sin6.sin6_family = AF_INET6;
> +                      (void) sin6"
>      . auto/feature
>  fi
>  

Quick look reveals at least the following additional places where the same
warning is generated:

diff --git a/auto/os/darwin b/auto/os/darwin
--- a/auto/os/darwin
+++ b/auto/os/darwin
@@ -113,6 +113,6 @@ ngx_feature_run=no
 ngx_feature_incs="#include <libkern/OSAtomic.h>"
 ngx_feature_path=
 ngx_feature_libs=
-ngx_feature_test="int32_t  lock, n;
-                  n = OSAtomicCompareAndSwap32Barrier(0, 1, &lock)"
+ngx_feature_test="int32_t  lock = 0;
+                  if (!OSAtomicCompareAndSwap32Barrier(0, 1, &lock)) return 1"
 . auto/feature
diff --git a/auto/os/solaris b/auto/os/solaris
--- a/auto/os/solaris
+++ b/auto/os/solaris
@@ -52,7 +52,7 @@ ngx_feature_run=no
 ngx_feature_incs="#include <port.h>"
 ngx_feature_path=
 ngx_feature_libs=
-ngx_feature_test="int n = port_create()"
+ngx_feature_test="(void) port_create()"
 . auto/feature
 
 if [ $ngx_found = yes ]; then
diff --git a/auto/unix b/auto/unix
--- a/auto/unix
+++ b/auto/unix
@@ -75,7 +75,7 @@ if test -z "$NGX_KQUEUE_CHECKED"; then
     ngx_feature_incs="#include <sys/event.h>"
     ngx_feature_path=
     ngx_feature_libs=
-    ngx_feature_test="int kq; kq = kqueue()"
+    ngx_feature_test="(void) kqueue()"
     . auto/feature
 
     if [ $ngx_found = yes ]; then
@@ -92,7 +92,8 @@ if test -z "$NGX_KQUEUE_CHECKED"; then
         ngx_feature_path=
         ngx_feature_libs=
         ngx_feature_test="struct kevent  kev;
-                          kev.fflags = NOTE_LOWAT;"
+                          kev.fflags = NOTE_LOWAT;
+                          (void) kev"
         . auto/feature
 
 
@@ -492,9 +493,9 @@ if [ $NGX_FILE_AIO = YES ]; then
     ngx_feature_incs="#include <aio.h>"
     ngx_feature_path=
     ngx_feature_libs=
-    ngx_feature_test="int  n; struct aiocb  iocb;
+    ngx_feature_test="struct aiocb  iocb;
                       iocb.aio_sigevent.sigev_notify = SIGEV_KEVENT;
-                      n = aio_read(&iocb)"
+                      (void) aio_read(&iocb)"
     . auto/feature
 
     if [ $ngx_found = yes ]; then
@@ -514,6 +515,7 @@ if [ $NGX_FILE_AIO = YES ]; then
                           iocb.aio_lio_opcode = IOCB_CMD_PREAD;
                           iocb.aio_flags = IOCB_FLAG_RESFD;
                           iocb.aio_resfd = -1;
+                          (void) iocb;
                           (void) eventfd(0, 0)"
         . auto/feature
 
@@ -529,11 +531,12 @@ if [ $NGX_FILE_AIO = YES ]; then
         ngx_feature="Linux AIO support (SYS_eventfd)"
         ngx_feature_incs="#include <linux/aio_abi.h>
                           #include <sys/syscall.h>"
-        ngx_feature_test="int  n = SYS_eventfd;
-                          struct iocb  iocb;
+        ngx_feature_test="struct iocb  iocb;
                           iocb.aio_lio_opcode = IOCB_CMD_PREAD;
                           iocb.aio_flags = IOCB_FLAG_RESFD;
-                          iocb.aio_resfd = -1;"
+                          iocb.aio_resfd = -1;
+                          (void) iocb;
+                          (void) SYS_eventfd"
         . auto/feature
 
         if [ $ngx_found = yes ]; then
@@ -571,7 +574,7 @@ else
 
         ngx_feature="eventfd() (SYS_eventfd)"
         ngx_feature_incs="#include <sys/syscall.h>"
-        ngx_feature_test="int n = SYS_eventfd"
+        ngx_feature_test="(void) SYS_eventfd"
         . auto/feature
     fi
 fi

Likely there are others as well (and I'm a bit sceptical about 
attempts to run configure with -Werror enabled), but probably 
committing this improves things anyway.

Committed with the above additions, thanks.
http://hg.nginx.org/nginx/rev/e393c0bf53d3

-- 
Maxim Dounin
http://nginx.org/



More information about the nginx-devel mailing list