mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-10 13:04:23 -04:00
Renamed sin to saddr due to name conflict
During building on MSVC 2013 I got a compiler error by a type conflict for sin: test-fdleak.c(60) : error C2365: 'sin' : redefinition; previous definition was 'function' test-fdleak.c(134) : error C2070: 'double (__cdecl *)()': illegal sizeof operand test-fdleak.c(134) : error C2198: 'evconnlistener_new_bind' : too few arguments for call test-fdleak.c(148) : error C2070: 'double (__cdecl *)()': illegal sizeof operand test-fdleak.c(148) : error C2168: 'memcpy' : too few actual parameters for intrinsic function test-fdleak.c(149) : error C2224: left of '.sin_family' must have struct/union type test-fdleak.c(212) : error C2070: 'double (__cdecl *)()': illegal sizeof operand test-fdleak.c(212) : error C2198: 'bufferevent_socket_connect' : too few arguments for call test-fdleak.c(239) : error C2070: 'double (__cdecl *)()': illegal sizeof operand test-fdleak.c(239) : error C2168: 'memset' : too few actual parameters for intrinsic function test-fdleak.c(240) : error C2224: left of '.sin_family' must have struct/union type test-fdleak.c(241) : error C2224: left of '.sin_addr' must have struct/union type test-fdleak.c(242) : error C2224: left of '.sin_port' must have struct/union type The simplest solution to this problem would be to rename the variable.
This commit is contained in:
parent
6a1c4d501b
commit
dc82c8d372
@ -57,7 +57,7 @@
|
||||
#endif
|
||||
|
||||
/* Provide storage for the address, both for the server & the clients */
|
||||
static struct sockaddr_in sin;
|
||||
static struct sockaddr_in saddr;
|
||||
|
||||
/* Number of sucessful requests so far */
|
||||
static int num_requests;
|
||||
@ -131,7 +131,7 @@ start_loop(void)
|
||||
|
||||
listener = evconnlistener_new_bind(base, listener_accept_cb, NULL,
|
||||
LEV_OPT_CLOSE_ON_FREE|LEV_OPT_REUSEABLE,
|
||||
-1, (struct sockaddr *)&sin, sizeof(sin));
|
||||
-1, (struct sockaddr *)&saddr, sizeof(saddr));
|
||||
if (listener == NULL) {
|
||||
my_perror("Could not create listener!");
|
||||
exit(1);
|
||||
@ -145,8 +145,8 @@ start_loop(void)
|
||||
my_perror("getsockname()");
|
||||
exit(1);
|
||||
}
|
||||
memcpy(&sin, &ss, sizeof(sin));
|
||||
if (sin.sin_family != AF_INET) {
|
||||
memcpy(&saddr, &ss, sizeof(saddr));
|
||||
if (saddr.sin_family != AF_INET) {
|
||||
puts("AF mismatch from getsockname().");
|
||||
exit(1);
|
||||
}
|
||||
@ -208,8 +208,8 @@ start_client(struct event_base *base)
|
||||
BEV_OPT_CLOSE_ON_FREE);
|
||||
bufferevent_setcb(bev, client_read_cb, NULL, client_event_cb, NULL);
|
||||
|
||||
if (bufferevent_socket_connect(bev, (struct sockaddr *)&sin,
|
||||
sizeof(sin)) < 0) {
|
||||
if (bufferevent_socket_connect(bev, (struct sockaddr *)&saddr,
|
||||
sizeof(saddr)) < 0) {
|
||||
my_perror("Could not connect!");
|
||||
bufferevent_free(bev);
|
||||
exit(2);
|
||||
@ -236,10 +236,10 @@ main(int argc, char **argv)
|
||||
#endif
|
||||
|
||||
/* Set up an address, used by both client & server. */
|
||||
memset(&sin, 0, sizeof(sin));
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_addr.s_addr = htonl(0x7f000001);
|
||||
sin.sin_port = 0; /* Tell the implementation to pick a port. */
|
||||
memset(&saddr, 0, sizeof(saddr));
|
||||
saddr.sin_family = AF_INET;
|
||||
saddr.sin_addr.s_addr = htonl(0x7f000001);
|
||||
saddr.sin_port = 0; /* Tell the implementation to pick a port. */
|
||||
|
||||
start_loop();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user