bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: FD_ISSET replacement


From: Bruno Haible
Subject: Re: FD_ISSET replacement
Date: Thu, 23 Oct 2008 03:09:36 +0200
User-agent: KMail/1.5.4

Simon Josefsson wrote:
> The sys_socket module generates this warning:
> 
> ../lgl/sys/socket.h: In function 'rpl_fd_isset':
> ../lgl/sys/socket.h:158: warning: comparison between signed and unsigned
> ../lgl/sys/socket.h:159: warning: comparison between signed and unsigned
> 
> I pushed the patch below.
> 
> However, is the code really appropriate?  I'm thinking of this comment:
> 
>  /* Re-define FD_ISSET to avoid a WSA call while we are not using
>     network sockets.  */

This comments means IMO that when someone is using select() on pipes and
console handles, he should not make ws2_32 calls.

>  static inline int
> -rpl_fd_isset (int fd, fd_set * set)
> +rpl_fd_isset (SOCKET fd, fd_set * set)
>  {
> -  int i;
> +  u_int i;
>    if (set == NULL)
>      return 0;

I agree with the signature change, because this FD_ISSET replacement is
called by winsock-select.c. For the type of 'i', better use a portable type,
such as 'unsigned int'. 'u_int' is not a portable type - it may be present in
mingw and absent in MSVC's headers, who knows. Proposed patch below.

Bruno


--- lib/sys_socket.in.h.orig    2008-10-23 03:08:52.000000000 +0200
+++ lib/sys_socket.in.h 2008-10-23 03:08:42.000000000 +0200
@@ -122,7 +122,8 @@
 static inline int
 rpl_fd_isset (SOCKET fd, fd_set * set)
 {
-  u_int i;
+  unsigned int i;
+
   if (set == NULL)
     return 0;
 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]