diff options
| author | Diego Nehab <diego@impa.br> | 2012-12-11 17:43:49 -0200 |
|---|---|---|
| committer | Diego Nehab <diego@impa.br> | 2012-12-11 17:43:49 -0200 |
| commit | 72a5347f97b3f158431d4181109db3086a8a2953 (patch) | |
| tree | 530f7ab086627154fc8693c939145c6d815de6df /src | |
| parent | 618ce43ee3950b80aca1fde0a5b12e6e13627f1b (diff) | |
| download | luasocket-72a5347f97b3f158431d4181109db3086a8a2953.tar.gz luasocket-72a5347f97b3f158431d4181109db3086a8a2953.tar.bz2 luasocket-72a5347f97b3f158431d4181109db3086a8a2953.zip | |
Remove warnings and fix makefile for Win32.
Diffstat (limited to 'src')
| -rw-r--r-- | src/buffer.c | 12 | ||||
| -rw-r--r-- | src/inet.c | 12 | ||||
| -rw-r--r-- | src/makefile | 11 | ||||
| -rw-r--r-- | src/mime.c | 8 | ||||
| -rw-r--r-- | src/select.c | 10 | ||||
| -rw-r--r-- | src/tcp.c | 2 | ||||
| -rw-r--r-- | src/udp.c | 4 | ||||
| -rw-r--r-- | src/wsocket.c | 7 |
8 files changed, 30 insertions, 36 deletions
diff --git a/src/buffer.c b/src/buffer.c index d8facd2..4ef4e8e 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -51,8 +51,8 @@ void buffer_init(p_buffer buf, p_io io, p_timeout tm) { | |||
| 51 | * object:getstats() interface | 51 | * object:getstats() interface |
| 52 | \*-------------------------------------------------------------------------*/ | 52 | \*-------------------------------------------------------------------------*/ |
| 53 | int buffer_meth_getstats(lua_State *L, p_buffer buf) { | 53 | int buffer_meth_getstats(lua_State *L, p_buffer buf) { |
| 54 | lua_pushnumber(L, buf->received); | 54 | lua_pushnumber(L, (lua_Number) buf->received); |
| 55 | lua_pushnumber(L, buf->sent); | 55 | lua_pushnumber(L, (lua_Number) buf->sent); |
| 56 | lua_pushnumber(L, timeout_gettime() - buf->birthday); | 56 | lua_pushnumber(L, timeout_gettime() - buf->birthday); |
| 57 | return 3; | 57 | return 3; |
| 58 | } | 58 | } |
| @@ -61,8 +61,8 @@ int buffer_meth_getstats(lua_State *L, p_buffer buf) { | |||
| 61 | * object:setstats() interface | 61 | * object:setstats() interface |
| 62 | \*-------------------------------------------------------------------------*/ | 62 | \*-------------------------------------------------------------------------*/ |
| 63 | int buffer_meth_setstats(lua_State *L, p_buffer buf) { | 63 | int buffer_meth_setstats(lua_State *L, p_buffer buf) { |
| 64 | buf->received = (long) luaL_optnumber(L, 2, buf->received); | 64 | buf->received = (long) luaL_optnumber(L, 2, (lua_Number) buf->received); |
| 65 | buf->sent = (long) luaL_optnumber(L, 3, buf->sent); | 65 | buf->sent = (long) luaL_optnumber(L, 3, (lua_Number) buf->sent); |
| 66 | if (lua_isnumber(L, 4)) buf->birthday = timeout_gettime() - lua_tonumber(L, 4); | 66 | if (lua_isnumber(L, 4)) buf->birthday = timeout_gettime() - lua_tonumber(L, 4); |
| 67 | lua_pushnumber(L, 1); | 67 | lua_pushnumber(L, 1); |
| 68 | return 1; | 68 | return 1; |
| @@ -90,9 +90,9 @@ int buffer_meth_send(lua_State *L, p_buffer buf) { | |||
| 90 | if (err != IO_DONE) { | 90 | if (err != IO_DONE) { |
| 91 | lua_pushnil(L); | 91 | lua_pushnil(L); |
| 92 | lua_pushstring(L, buf->io->error(buf->io->ctx, err)); | 92 | lua_pushstring(L, buf->io->error(buf->io->ctx, err)); |
| 93 | lua_pushnumber(L, sent+start-1); | 93 | lua_pushnumber(L, (lua_Number) (sent+start-1)); |
| 94 | } else { | 94 | } else { |
| 95 | lua_pushnumber(L, sent+start-1); | 95 | lua_pushnumber(L, (lua_Number) (sent+start-1)); |
| 96 | lua_pushnil(L); | 96 | lua_pushnil(L); |
| 97 | lua_pushnil(L); | 97 | lua_pushnil(L); |
| 98 | } | 98 | } |
| @@ -105,8 +105,8 @@ static int inet_global_getnameinfo(lua_State *L) { | |||
| 105 | 105 | ||
| 106 | lua_newtable(L); | 106 | lua_newtable(L); |
| 107 | for (i = 1, iter = resolved; iter; i++, iter = iter->ai_next) { | 107 | for (i = 1, iter = resolved; iter; i++, iter = iter->ai_next) { |
| 108 | getnameinfo(iter->ai_addr, iter->ai_addrlen, host, | 108 | getnameinfo(iter->ai_addr, (socklen_t) iter->ai_addrlen, host, |
| 109 | node ? sizeof(host) : 0, serv, service ? sizeof(serv) : 0, 0); | 109 | node ? (socklen_t) sizeof(host) : 0, serv, service ? (socklen_t) sizeof(serv) : 0, 0); |
| 110 | 110 | ||
| 111 | if (node) { | 111 | if (node) { |
| 112 | lua_pushnumber(L, i); | 112 | lua_pushnumber(L, i); |
| @@ -177,8 +177,8 @@ static int inet_global_getaddrinfo(lua_State *L) | |||
| 177 | lua_newtable(L); | 177 | lua_newtable(L); |
| 178 | for (iterator = resolved; iterator; iterator = iterator->ai_next) { | 178 | for (iterator = resolved; iterator; iterator = iterator->ai_next) { |
| 179 | char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV]; | 179 | char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV]; |
| 180 | getnameinfo(iterator->ai_addr, iterator->ai_addrlen, hbuf, | 180 | getnameinfo(iterator->ai_addr, (socklen_t) iterator->ai_addrlen, hbuf, |
| 181 | sizeof(hbuf), sbuf, 0, NI_NUMERICHOST); | 181 | (socklen_t) sizeof(hbuf), sbuf, 0, NI_NUMERICHOST); |
| 182 | lua_pushnumber(L, i); | 182 | lua_pushnumber(L, i); |
| 183 | lua_newtable(L); | 183 | lua_newtable(L); |
| 184 | switch (iterator->ai_family) { | 184 | switch (iterator->ai_family) { |
| @@ -413,7 +413,7 @@ const char *inet_tryconnect(p_socket ps, const char *address, | |||
| 413 | timeout_markstart(tm); | 413 | timeout_markstart(tm); |
| 414 | /* try connecting to remote address */ | 414 | /* try connecting to remote address */ |
| 415 | err = socket_strerror(socket_connect(ps, (SA *) iterator->ai_addr, | 415 | err = socket_strerror(socket_connect(ps, (SA *) iterator->ai_addr, |
| 416 | iterator->ai_addrlen, tm)); | 416 | (socklen_t) iterator->ai_addrlen, tm)); |
| 417 | /* if success, break out of loop */ | 417 | /* if success, break out of loop */ |
| 418 | if (err == NULL) break; | 418 | if (err == NULL) break; |
| 419 | } | 419 | } |
| @@ -463,7 +463,7 @@ const char *inet_trybind(p_socket ps, const char *address, const char *serv, | |||
| 463 | /* try binding to local address */ | 463 | /* try binding to local address */ |
| 464 | err = socket_strerror(socket_bind(&sock, | 464 | err = socket_strerror(socket_bind(&sock, |
| 465 | (SA *) iterator->ai_addr, | 465 | (SA *) iterator->ai_addr, |
| 466 | iterator->ai_addrlen)); | 466 | (socklen_t) iterator->ai_addrlen)); |
| 467 | 467 | ||
| 468 | /* keep trying unless bind succeeded */ | 468 | /* keep trying unless bind succeeded */ |
| 469 | if (err) { | 469 | if (err) { |
diff --git a/src/makefile b/src/makefile index 42b745e..a75d5a6 100644 --- a/src/makefile +++ b/src/makefile | |||
| @@ -114,7 +114,7 @@ SOCKET_macosx=usocket.o | |||
| 114 | SO_linux=so | 114 | SO_linux=so |
| 115 | O_linux=o | 115 | O_linux=o |
| 116 | CC_linux=gcc | 116 | CC_linux=gcc |
| 117 | DEF_linux=-DLUASOCKET_$(DEBUG) \ | 117 | DEF_linux=-DLUASOCKET_$(DEBUG) -DLUA_COMPAT_MODULE \ |
| 118 | -DLUASOCKET_API='__attribute__((visibility("default")))' \ | 118 | -DLUASOCKET_API='__attribute__((visibility("default")))' \ |
| 119 | -DMIME_API='__attribute__((visibility("default")))' | 119 | -DMIME_API='__attribute__((visibility("default")))' |
| 120 | CFLAGS_linux= -I$(LUAINC) $(DEF) -pedantic -Wall -Wshadow -Wextra -Wimplicit -O2 -ggdb3 -fpic \ | 120 | CFLAGS_linux= -I$(LUAINC) $(DEF) -pedantic -Wall -Wshadow -Wextra -Wimplicit -O2 -ggdb3 -fpic \ |
| @@ -130,11 +130,12 @@ SO_win32=dll | |||
| 130 | O_win32=obj | 130 | O_win32=obj |
| 131 | CC_win32=cl | 131 | CC_win32=cl |
| 132 | DEF_win32= /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" \ | 132 | DEF_win32= /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" \ |
| 133 | /D "LUASOCKET_API=__declspec(dllexport)" /D "LUASOCKET_$(DEBUG)" \ | 133 | /D "LUASOCKET_API=__declspec(dllexport)" /D "_CRT_SECURE_NO_WARNINGS" \ |
| 134 | /D "_CRT_SECURE_NO_WARNINGS" /D "_WINDLL" | 134 | /D "_WINDLL" /D "LUA_COMPAT_MODULE" /D "MIME_API=__declspec(dllexport)" \ |
| 135 | CFLAGS_win32=/I$(LUAINC) $(DEF) /O2 /Ot /MD /W3 /nologo | 135 | /D "LUASOCKET_$(DEBUG)" |
| 136 | CFLAGS_win32=/I "$(LUAINC)" $(DEF) /O2 /Ot /MD /W3 /nologo | ||
| 136 | LDFLAGS_win32= /nologo /link /NOLOGO /DLL /INCREMENTAL:NO \ | 137 | LDFLAGS_win32= /nologo /link /NOLOGO /DLL /INCREMENTAL:NO \ |
| 137 | /LIBPATH:$(LUALIB) \ | 138 | /LIBPATH:"$(LUALIB)" \ |
| 138 | /MANIFEST \ | 139 | /MANIFEST \ |
| 139 | /MANIFESTFILE:"intermediate.manifest" \ | 140 | /MANIFESTFILE:"intermediate.manifest" \ |
| 140 | /MANIFESTUAC:"level='asInvoker' uiAccess='false'" \ | 141 | /MANIFESTUAC:"level='asInvoker' uiAccess='false'" \ |
| @@ -504,7 +504,7 @@ static size_t qpdecode(UC c, UC *input, size_t size, luaL_Buffer *buffer) { | |||
| 504 | c = qpunbase[input[1]]; d = qpunbase[input[2]]; | 504 | c = qpunbase[input[1]]; d = qpunbase[input[2]]; |
| 505 | /* if it is an invalid, do not decode */ | 505 | /* if it is an invalid, do not decode */ |
| 506 | if (c > 15 || d > 15) luaL_addlstring(buffer, (char *)input, 3); | 506 | if (c > 15 || d > 15) luaL_addlstring(buffer, (char *)input, 3); |
| 507 | else luaL_addchar(buffer, (c << 4) + d); | 507 | else luaL_addchar(buffer, (char) ((c << 4) + d)); |
| 508 | return 0; | 508 | return 0; |
| 509 | case '\r': | 509 | case '\r': |
| 510 | if (size < 2) return size; | 510 | if (size < 2) return size; |
| @@ -642,7 +642,7 @@ static int eolprocess(int c, int last, const char *marker, | |||
| 642 | return c; | 642 | return c; |
| 643 | } | 643 | } |
| 644 | } else { | 644 | } else { |
| 645 | luaL_addchar(buffer, c); | 645 | luaL_addchar(buffer, (char) c); |
| 646 | return 0; | 646 | return 0; |
| 647 | } | 647 | } |
| 648 | } | 648 | } |
| @@ -682,7 +682,7 @@ static int mime_global_eol(lua_State *L) | |||
| 682 | \*-------------------------------------------------------------------------*/ | 682 | \*-------------------------------------------------------------------------*/ |
| 683 | static size_t dot(int c, size_t state, luaL_Buffer *buffer) | 683 | static size_t dot(int c, size_t state, luaL_Buffer *buffer) |
| 684 | { | 684 | { |
| 685 | luaL_addchar(buffer, c); | 685 | luaL_addchar(buffer, (char) c); |
| 686 | switch (c) { | 686 | switch (c) { |
| 687 | case '\r': | 687 | case '\r': |
| 688 | return 1; | 688 | return 1; |
| @@ -717,7 +717,7 @@ static int mime_global_dot(lua_State *L) | |||
| 717 | while (input < last) | 717 | while (input < last) |
| 718 | state = dot(*input++, state, &buffer); | 718 | state = dot(*input++, state, &buffer); |
| 719 | luaL_pushresult(&buffer); | 719 | luaL_pushresult(&buffer); |
| 720 | lua_pushnumber(L, state); | 720 | lua_pushnumber(L, (lua_Number) state); |
| 721 | return 2; | 721 | return 2; |
| 722 | } | 722 | } |
| 723 | 723 | ||
diff --git a/src/select.c b/src/select.c index b870545..51fb198 100644 --- a/src/select.c +++ b/src/select.c | |||
| @@ -122,7 +122,7 @@ static void collect_fd(lua_State *L, int tab, int itab, | |||
| 122 | if (lua_isnil(L, tab)) return; | 122 | if (lua_isnil(L, tab)) return; |
| 123 | /* otherwise we need it to be a table */ | 123 | /* otherwise we need it to be a table */ |
| 124 | luaL_checktype(L, tab, LUA_TTABLE); | 124 | luaL_checktype(L, tab, LUA_TTABLE); |
| 125 | while (1) { | 125 | for ( ;; ) { |
| 126 | t_socket fd; | 126 | t_socket fd; |
| 127 | lua_pushnumber(L, i); | 127 | lua_pushnumber(L, i); |
| 128 | lua_gettable(L, tab); | 128 | lua_gettable(L, tab); |
| @@ -147,7 +147,7 @@ static void collect_fd(lua_State *L, int tab, int itab, | |||
| 147 | if (*max_fd == SOCKET_INVALID || *max_fd < fd) | 147 | if (*max_fd == SOCKET_INVALID || *max_fd < fd) |
| 148 | *max_fd = fd; | 148 | *max_fd = fd; |
| 149 | /* make sure we can map back from descriptor to the object */ | 149 | /* make sure we can map back from descriptor to the object */ |
| 150 | lua_pushnumber(L, fd); | 150 | lua_pushnumber(L, (lua_Number) fd); |
| 151 | lua_pushvalue(L, -2); | 151 | lua_pushvalue(L, -2); |
| 152 | lua_settable(L, itab); | 152 | lua_settable(L, itab); |
| 153 | } | 153 | } |
| @@ -160,7 +160,7 @@ static int check_dirty(lua_State *L, int tab, int dtab, fd_set *set) { | |||
| 160 | int ndirty = 0, i = 1; | 160 | int ndirty = 0, i = 1; |
| 161 | if (lua_isnil(L, tab)) | 161 | if (lua_isnil(L, tab)) |
| 162 | return 0; | 162 | return 0; |
| 163 | while (1) { | 163 | for ( ;; ) { |
| 164 | t_socket fd; | 164 | t_socket fd; |
| 165 | lua_pushnumber(L, i); | 165 | lua_pushnumber(L, i); |
| 166 | lua_gettable(L, tab); | 166 | lua_gettable(L, tab); |
| @@ -187,7 +187,7 @@ static void return_fd(lua_State *L, fd_set *set, t_socket max_fd, | |||
| 187 | for (fd = 0; fd < max_fd; fd++) { | 187 | for (fd = 0; fd < max_fd; fd++) { |
| 188 | if (FD_ISSET(fd, set)) { | 188 | if (FD_ISSET(fd, set)) { |
| 189 | lua_pushnumber(L, ++start); | 189 | lua_pushnumber(L, ++start); |
| 190 | lua_pushnumber(L, fd); | 190 | lua_pushnumber(L, (lua_Number) fd); |
| 191 | lua_gettable(L, itab); | 191 | lua_gettable(L, itab); |
| 192 | lua_settable(L, tab); | 192 | lua_settable(L, tab); |
| 193 | } | 193 | } |
| @@ -197,7 +197,7 @@ static void return_fd(lua_State *L, fd_set *set, t_socket max_fd, | |||
| 197 | static void make_assoc(lua_State *L, int tab) { | 197 | static void make_assoc(lua_State *L, int tab) { |
| 198 | int i = 1, atab; | 198 | int i = 1, atab; |
| 199 | lua_newtable(L); atab = lua_gettop(L); | 199 | lua_newtable(L); atab = lua_gettop(L); |
| 200 | while (1) { | 200 | for ( ;; ) { |
| 201 | lua_pushnumber(L, i); | 201 | lua_pushnumber(L, i); |
| 202 | lua_gettable(L, tab); | 202 | lua_gettable(L, tab); |
| 203 | if (!lua_isnil(L, -1)) { | 203 | if (!lua_isnil(L, -1)) { |
| @@ -418,7 +418,7 @@ static const char *tryconnect6(const char *remoteaddr, const char *remoteserv, | |||
| 418 | /* finally try connecting to remote address */ | 418 | /* finally try connecting to remote address */ |
| 419 | err = socket_strerror(socket_connect(&tcp->sock, | 419 | err = socket_strerror(socket_connect(&tcp->sock, |
| 420 | (SA *) iterator->ai_addr, | 420 | (SA *) iterator->ai_addr, |
| 421 | iterator->ai_addrlen, tm)); | 421 | (socklen_t) iterator->ai_addrlen, tm)); |
| 422 | /* if success, break out of loop */ | 422 | /* if success, break out of loop */ |
| 423 | if (err == NULL) break; | 423 | if (err == NULL) break; |
| 424 | } | 424 | } |
| @@ -139,7 +139,7 @@ static int meth_send(lua_State *L) { | |||
| 139 | lua_pushstring(L, udp_strerror(err)); | 139 | lua_pushstring(L, udp_strerror(err)); |
| 140 | return 2; | 140 | return 2; |
| 141 | } | 141 | } |
| 142 | lua_pushnumber(L, sent); | 142 | lua_pushnumber(L, (lua_Number) sent); |
| 143 | return 1; | 143 | return 1; |
| 144 | } | 144 | } |
| 145 | 145 | ||
| @@ -189,7 +189,7 @@ static int meth_sendto(lua_State *L) { | |||
| 189 | lua_pushstring(L, udp_strerror(err)); | 189 | lua_pushstring(L, udp_strerror(err)); |
| 190 | return 2; | 190 | return 2; |
| 191 | } | 191 | } |
| 192 | lua_pushnumber(L, sent); | 192 | lua_pushnumber(L, (lua_Number) sent); |
| 193 | return 1; | 193 | return 1; |
| 194 | } | 194 | } |
| 195 | 195 | ||
diff --git a/src/wsocket.c b/src/wsocket.c index 5b184cf..d6dd004 100644 --- a/src/wsocket.c +++ b/src/wsocket.c | |||
| @@ -181,8 +181,6 @@ int socket_accept(p_socket ps, p_socket pa, SA *addr, socklen_t *len, | |||
| 181 | /* call select to avoid busy wait */ | 181 | /* call select to avoid busy wait */ |
| 182 | if ((err = socket_waitfd(ps, WAITFD_R, tm)) != IO_DONE) return err; | 182 | if ((err = socket_waitfd(ps, WAITFD_R, tm)) != IO_DONE) return err; |
| 183 | } | 183 | } |
| 184 | /* can't reach here */ | ||
| 185 | return IO_UNKNOWN; | ||
| 186 | } | 184 | } |
| 187 | 185 | ||
| 188 | /*-------------------------------------------------------------------------*\ | 186 | /*-------------------------------------------------------------------------*\ |
| @@ -214,8 +212,6 @@ int socket_send(p_socket ps, const char *data, size_t count, | |||
| 214 | /* avoid busy wait */ | 212 | /* avoid busy wait */ |
| 215 | if ((err = socket_waitfd(ps, WAITFD_W, tm)) != IO_DONE) return err; | 213 | if ((err = socket_waitfd(ps, WAITFD_W, tm)) != IO_DONE) return err; |
| 216 | } | 214 | } |
| 217 | /* can't reach here */ | ||
| 218 | return IO_UNKNOWN; | ||
| 219 | } | 215 | } |
| 220 | 216 | ||
| 221 | /*-------------------------------------------------------------------------*\ | 217 | /*-------------------------------------------------------------------------*\ |
| @@ -237,7 +233,6 @@ int socket_sendto(p_socket ps, const char *data, size_t count, size_t *sent, | |||
| 237 | if (err != WSAEWOULDBLOCK) return err; | 233 | if (err != WSAEWOULDBLOCK) return err; |
| 238 | if ((err = socket_waitfd(ps, WAITFD_W, tm)) != IO_DONE) return err; | 234 | if ((err = socket_waitfd(ps, WAITFD_W, tm)) != IO_DONE) return err; |
| 239 | } | 235 | } |
| 240 | return IO_UNKNOWN; | ||
| 241 | } | 236 | } |
| 242 | 237 | ||
| 243 | /*-------------------------------------------------------------------------*\ | 238 | /*-------------------------------------------------------------------------*\ |
| @@ -258,7 +253,6 @@ int socket_recv(p_socket ps, char *data, size_t count, size_t *got, p_timeout tm | |||
| 258 | if (err != WSAEWOULDBLOCK) return err; | 253 | if (err != WSAEWOULDBLOCK) return err; |
| 259 | if ((err = socket_waitfd(ps, WAITFD_R, tm)) != IO_DONE) return err; | 254 | if ((err = socket_waitfd(ps, WAITFD_R, tm)) != IO_DONE) return err; |
| 260 | } | 255 | } |
| 261 | return IO_UNKNOWN; | ||
| 262 | } | 256 | } |
| 263 | 257 | ||
| 264 | /*-------------------------------------------------------------------------*\ | 258 | /*-------------------------------------------------------------------------*\ |
| @@ -280,7 +274,6 @@ int socket_recvfrom(p_socket ps, char *data, size_t count, size_t *got, | |||
| 280 | if (err != WSAEWOULDBLOCK) return err; | 274 | if (err != WSAEWOULDBLOCK) return err; |
| 281 | if ((err = socket_waitfd(ps, WAITFD_R, tm)) != IO_DONE) return err; | 275 | if ((err = socket_waitfd(ps, WAITFD_R, tm)) != IO_DONE) return err; |
| 282 | } | 276 | } |
| 283 | return IO_UNKNOWN; | ||
| 284 | } | 277 | } |
| 285 | 278 | ||
| 286 | /*-------------------------------------------------------------------------*\ | 279 | /*-------------------------------------------------------------------------*\ |
