Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use socklen_t in socket function prototypes #63

Closed
dmik opened this issue Feb 19, 2020 · 1 comment
Closed

Use socklen_t in socket function prototypes #63

dmik opened this issue Feb 19, 2020 · 1 comment
Assignees

Comments

@dmik
Copy link
Contributor

dmik commented Feb 19, 2020

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
Copy link
Contributor Author

dmik commented Oct 30, 2020

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:

@dmik dmik self-assigned this Oct 30, 2020
@dmik dmik closed this as completed in 5e68874 Dec 30, 2020
dmik added a commit that referenced this issue Dec 31, 2020
This is a POSIX requirement.

Note that this commit also adds ssize_t as a return value in some functions
(also according to POSIX) as well as size_t instead of int for input buffer
(non-socket) length parameters.

Closes #63.
dmik added a commit to bitwiseworks/qtbase-os2 that referenced this issue Mar 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant