Ticket #389 (new wishlist)

Opened 8 years ago

Last modified 8 years ago

incompatible argument in src/libsrc/util/socket_ew_common.c

Reported by: baker Owned by: somebody
Priority: minor Milestone: All Platforms
Component: ALL modules Version: 7.8
Keywords: util socket_ew_common.c Cc:

Description

The Intel C compiler has several complaints about incompatible arguments in socket_ew_common.c:

icc -c -c -D_REENTRANT -m32 -Dlinux -D__i386 -D_LINUX -D_INTEL -D_USE_SCHED  -D_USE_PTHREADS -D_USE_TERMIOS -I/opt/earthworm/earthworm-7.6-5825/include      -g -O0 -Wcheck -Wformat -check=stack,uninit -traceback -g socket_ew_common.c

socket_ew_common.c(264): warning #167: argument of type "int *" is incompatible with parameter of type "socklen_t={__socklen_t={unsigned int}} *__restrict__"
       rc  = getsockopt(s, SOL_SOCKET, SO_ERROR, (char *)&error, &len);
                                                                 ^

socket_ew_common.c(417): warning #167: argument of type "int *" is incompatible with parameter of type "socklen_t={__socklen_t={unsigned int}} *__restrict__"
    newSocket=accept(s,addr,addrlen);
                            ^

socket_ew_common.c(464): warning #167: argument of type "int *" is incompatible with parameter of type "socklen_t={__socklen_t={unsigned int}} *__restrict__"
        newSocket=accept(s,addr,addrlen);
                                ^

socket_ew_common.c(786): warning #167: argument of type "int *" is incompatible with parameter of type "socklen_t={__socklen_t={unsigned int}} *__restrict__"
    retVal = recvfrom(s,buf,len,flags,from,&flen);
                                           ^

socket_ew_common.c(826): warning #167: argument of type "int *" is incompatible with parameter of type "socklen_t={__socklen_t={unsigned int}} *__restrict__"
      retVal = recvfrom(s,buf,len,flags,from,&flen);
                                             ^

socket_ew_common.c(909): warning #167: argument of type "int *" is incompatible with parameter of type "socklen_t={__socklen_t={unsigned int}} *__restrict__"
      ret = getsockopt(s, SOL_SOCKET, SO_ERROR, errval, &errlen);
                                                        ^

These are due to the use of int's instead of socklen_t's.

Here is the fix:

--- src/libsrc/util/socket_ew_common.c
+++ src/libsrc/util/socket_ew_common.c  
@@ -260,3 +260,4 @@
     */
-     int error, len, rc;
+     int error, rc;
+     socklen_t len;
      error = 0;
@@ -370,3 +371,3 @@

-SOCKET accept_ew(SOCKET s, struct sockaddr FAR* addr, int FAR* addrlen,
+SOCKET accept_ew(SOCKET s, struct sockaddr FAR* addr, socklen_t FAR* addrlen,
                 int timeout_msec)
@@ -748,3 +749,3 @@
 int recvfrom_ew (SOCKET s, char FAR* buf, int len, int flags,
-                         struct sockaddr FAR* from, int FAR* fromlen,
+                         struct sockaddr FAR* from, socklen_t FAR* fromlen,
                          int timeout_msec)
@@ -764,3 +765,4 @@
   long lOnOff;
-  int sel, flen;
+  int sel;
+  socklen_t flen;

@@ -876,3 +878,4 @@
   int sel;
-  int errval[10], errlen, ret;
+  int errval[10], ret;
+  socklen_t errlen;

--- include/socket_ew.h
+++ include/socket_ew.h 
@@ -121,3 +121,3 @@

-SOCKET accept_ew (SOCKET s, struct sockaddr FAR* addr, int FAR* addrlen,
+SOCKET accept_ew (SOCKET s, struct sockaddr FAR* addr, socklen_t FAR* addrlen,
                           int timeout);
@@ -213,3 +213,3 @@
 int recvfrom_ew (SOCKET s, char FAR* buf, int len, int flags,
-                         struct sockaddr FAR* from, int FAR* fromlen,
+                         struct sockaddr FAR* from, socklen_t FAR* fromlen,
                          int timeout);

This might cascade into more warnings because of the change in the parameter types for accept_ew() and recvfrom_ew(). I will leave this as a wishlist until it can be verified the change in parameter types is benign.

Change History

comment:1 Changed 8 years ago by paulf

As nice as these changes would be, they will not work on Windows so that is why they are int's for now....we would need to have #ifdef's for UNIX vs WIN so the fix is not as easy as socklen_t

Maybe later. Keeping it open for now, but its not a big deal.

Note: See TracTickets for help on using tickets.