bitwiseworks / libc

LIBC Next (kLIBC fork)
9 stars 4 forks source link

Use socklen_t in socket function prototypes #63

Closed dmik closed 3 years ago

dmik commented 4 years ago

There is a bunch of socket functions (accept, bind and so on) that take one or more socklen_t arguments per new POSIX standard. Currently, they use int on OS/2 and after #62 there is socklen_t defined as int. This socklen_t should be used instead in all function prototypes. This includes some backend code that deals with socklen_t-like fields (like highmensocket.c).

dmik commented 3 years ago

It's time to do that I think. Because having socklen_t as int breaks the QtNetwork module build in QtBase (after #62). And just changing it to __uin32_t as on FreeBSD makes a bunch of warnings when building libevent like that one (which is expected):

D:/Coding/libevent/master/bufferevent_sock.c: In function 'bufferevent_socket_set_conn_address_fd_':
D:/Coding/libevent/master/bufferevent_sock.c:116:25: warning: pointer targets in passing argument 3 of 'getpeername' differ in signedness [-Wpointer-sign]
  116 |   getpeername(fd, addr, &len);
      |                         ^~~~
      |                         |
      |                         socklen_t * {aka unsigned int *}
In file included from D:/Coding/libevent/master/bufferevent_sock.c:55:
C:/usr/include/sys/socket.h:456:54: note: expected 'int *' but argument is of type 'socklen_t *' {aka 'unsigned int *'}
  456 | int     TCPCALL getpeername (int, struct sockaddr *, int *);
      |                                                      ^~~~~
  CC       evmap.lo
  CC       evthread.lo
  CC       evutil.lo
  CC       evutil_rand.lo
D:/Coding/libevent/master/evutil.c: In function 'evutil_ersatz_socketpair_':
D:/Coding/libevent/master/evutil.c:267:63: warning: pointer targets in passing argument 3 of 'getsockname' differ in signedness [-Wpointer-sign]
  267 |  if (getsockname(listener, (struct sockaddr *) &connect_addr, &size) == -1)
      |                                                               ^~~~~
      |                                                               |
      |                                                               socklen_t * {aka unsigned int *}
In file included from D:/Coding/libevent/master/evutil.c:48: