You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by "Roy T. Fielding" <fi...@apache.org> on 2002/08/10 05:06:27 UTC

[PATCH] fix a bogus warning in poll.c

The warning is simply because gcc can't follow conditionals, but
this should be a safe fix if nobody minds.

....Roy

Index: poll.c
===================================================================
RCS file: /home/cvs/apr/poll/unix/poll.c,v
retrieving revision 1.28
diff -u -r1.28 poll.c
--- poll.c      7 Aug 2002 00:06:12 -0000       1.28
+++ poll.c      10 Aug 2002 03:03:13 -0000
@@ -212,7 +212,7 @@
      FD_ZERO(&exceptset);

      for (i = 0; i < num; i++) {
-        apr_os_sock_t fd;
+        apr_os_sock_t fd = 0;

          if (aprset[i].desc_type == APR_POLL_SOCKET) {
  #ifdef NETWARE


Re: [PATCH] fix a bogus warning in poll.c

Posted by Brian Pane <br...@apache.org>.
Roy T. Fielding wrote:

> The warning is simply because gcc can't follow conditionals, but
> this should be a safe fix if nobody minds. 


I think an even safer fix would be to turn that last
"else if" into an "else."  If we just initialize the
value to zero, we might end up polling fd 0 if a
caller passes in an array full of invalid desc_type
values (such that none of the current if-conditions
are true).

I just noticed that we also need to avoid changing
"num" in that last else-if, because the malloc/free
version of the ifdefs depends on the original value.
I'll commit a fix this afternoon.

Brian
 

> ....Roy
>
> Index: poll.c
> ===================================================================
> RCS file: /home/cvs/apr/poll/unix/poll.c,v
> retrieving revision 1.28
> diff -u -r1.28 poll.c
> --- poll.c      7 Aug 2002 00:06:12 -0000       1.28
> +++ poll.c      10 Aug 2002 03:03:13 -0000
> @@ -212,7 +212,7 @@
>      FD_ZERO(&exceptset);
>
>      for (i = 0; i < num; i++) {
> -        apr_os_sock_t fd;
> +        apr_os_sock_t fd = 0;
>
>          if (aprset[i].desc_type == APR_POLL_SOCKET) {
>  #ifdef NETWARE