Permalink
Browse files

Remove unnecessary asserts

  • Loading branch information...
1 parent a4b7692 commit 07e115a5c223ff9dcfb997ada2e0a05f5b6c733e @Sh4rK Sh4rK committed Apr 16, 2012
Showing with 3 additions and 89 deletions.
  1. +0 −1 src/lhttp_parser.c
  2. +0 −4 src/luv.c
  3. +0 −3 src/luv_dns.c
  4. +0 −4 src/luv_fs.c
  5. +0 −1 src/luv_fs_watcher.c
  6. +0 −13 src/luv_handle.c
  7. +0 −7 src/luv_pipe.c
  8. +0 −3 src/luv_process.c
  9. +0 −1 src/luv_stream.c
  10. +0 −12 src/luv_tcp.c
  11. +0 −13 src/luv_timer.c
  12. +1 −4 src/luv_tty.c
  13. +0 −13 src/luv_udp.c
  14. +0 −1 src/luv_zlib.c
  15. +0 −1 src/luvit_main.c
  16. +2 −8 src/utils.c
View
@@ -17,7 +17,6 @@
#include <string.h>
#include <stdlib.h>
-#include <assert.h>
#include "lhttp_parser.h"
#include "http_parser.h"
View
@@ -18,7 +18,6 @@
#include "luv.h"
#include "uv.h"
#include <stdlib.h>
-#include <assert.h>
#include <string.h>
#include "uv-private/ev.h"
@@ -174,8 +173,6 @@ static int luv_handle_gc(lua_State* L) {
}
LUALIB_API int luaopen_uv_native (lua_State* L) {
- int before = lua_gettop(L);
-
/* metatable for handle userdata types */
/* It is it's own __index table to save space */
luaL_newmetatable(L, "luv_handle");
@@ -192,7 +189,6 @@ LUALIB_API int luaopen_uv_native (lua_State* L) {
lua_pushnumber(L, UV_VERSION_MINOR);
lua_setfield(L, -2, "VERSION_MINOR");
- assert(lua_gettop(L) == before + 1);
return 1;
}
View
@@ -31,17 +31,14 @@ typedef struct {
/* Utility for storing the callback in the dns_req token */
static luv_dns_ref_t* luv_dns_store_callback(lua_State* L, int index) {
- int before;
luv_dns_ref_t* ref;
- before = lua_gettop(L);
ref = calloc(1, sizeof(luv_dns_ref_t));
ref->L = L;
if (lua_isfunction(L, index)) {
lua_pushvalue(L, index); /* Store the callback */
ref->r = luaL_ref(L, LUA_REGISTRYINDEX);
}
- assert(lua_gettop(L) == before);
return ref;
}
View
@@ -175,7 +175,6 @@ int luv_process_fs_result(lua_State* L, uv_fs_t* req) {
void luv_after_fs(uv_fs_t* req) {
luv_fs_ref_t* ref = req->data;
lua_State *L = ref->L;
- int before = lua_gettop(L);
int argc;
lua_rawgeti(L, LUA_REGISTRYINDEX, ref->r);
luaL_unref(L, LUA_REGISTRYINDEX, ref->r);
@@ -186,12 +185,10 @@ void luv_after_fs(uv_fs_t* req) {
uv_fs_req_cleanup(req);
free(ref); /* We're done with the ref object, free it */
- assert(lua_gettop(L) == before);
}
/* Utility for storing the callback in the fs_req token */
uv_fs_t* luv_fs_store_callback(lua_State* L, int index) {
- int before = lua_gettop(L);
luv_fs_ref_t* ref = malloc(sizeof(luv_fs_ref_t));
ref->L = L;
@@ -200,7 +197,6 @@ uv_fs_t* luv_fs_store_callback(lua_State* L, int index) {
ref->r = luaL_ref(L, LUA_REGISTRYINDEX);
}
ref->fs_req.data = ref;
- assert(lua_gettop(L) == before);
return &ref->fs_req;
}
@@ -16,7 +16,6 @@
*/
#include <stdlib.h>
-#include <assert.h>
#include "luv_fs_watcher.h"
#include "luv_fs.h"
View
@@ -22,19 +22,16 @@
/* Registers a callback, callback_index can't be negative */
void luv_register_event(lua_State* L, int userdata_index, const char* name, int callback_index) {
- int before = lua_gettop(L);
lua_getfenv(L, userdata_index);
lua_pushvalue(L, callback_index);
lua_setfield(L, -2, name);
lua_pop(L, 1);
- assert(lua_gettop(L) == before);
}
/* Emit an event of the current userdata consuming nargs
* Assumes userdata is right below args
*/
void luv_emit_event(lua_State* L, const char* name, int nargs) {
- int before = lua_gettop(L);
/* Load the connection callback */
lua_getfenv(L, -nargs - 1);
lua_getfield(L, -1, name);
@@ -45,16 +42,13 @@ void luv_emit_event(lua_State* L, const char* name, int nargs) {
if (lua_isfunction (L, -1) == 0) {
lua_pop(L, 1 + nargs);
- assert(lua_gettop(L) == before - nargs - 1);
return;
}
/* move the function below the args */
lua_insert(L, -nargs - 1);
luv_acall(L, nargs, 0, name);
-
- assert(lua_gettop(L) == before - nargs - 1);
}
uv_buf_t luv_on_alloc(uv_handle_t* handle, size_t suggested_size) {
@@ -69,7 +63,6 @@ void luv_on_close(uv_handle_t* handle) {
/* load the lua state and the userdata */
luv_handle_t* lhandle = handle->data;
lua_State *L = lhandle->L;
- int before = lua_gettop(L);
lua_rawgeti(L, LUA_REGISTRYINDEX, lhandle->ref);
luv_emit_event(L, "closed", 0);
@@ -86,32 +79,26 @@ void luv_on_close(uv_handle_t* handle) {
/* This handle is no longer valid, clean up memory */
lhandle->handle = 0;
free(handle);
-
- assert(lua_gettop(L) == before);
}
int luv_close (lua_State* L) {
luv_handle_t* lhandle;
- int before = lua_gettop(L);
uv_handle_t* handle = luv_checkudata(L, 1, "handle");
/* printf("close \tlhandle=%p handle=%p\n", handle->data, handle);*/
uv_close(handle, luv_on_close);
luv_handle_ref(L, handle->data, 1);
- assert(lua_gettop(L) == before);
lhandle = handle->data;
return 0;
}
int luv_set_handler(lua_State* L) {
- int before = lua_gettop(L);
const char* name;
luv_checkudata(L, 1, "handle");
name = luaL_checkstring(L, 2);
luaL_checktype(L, 3, LUA_TFUNCTION);
luv_register_event(L, 1, name, 3);
- assert(lua_gettop(L) == before);
return 0;
}
View
@@ -16,7 +16,6 @@
*/
#include <stdlib.h>
-#include <assert.h>
#include "luv_pipe.h"
#include "utils.h"
@@ -29,18 +28,15 @@ int luv_new_pipe (lua_State* L) {
}
int luv_pipe_open(lua_State* L) {
- int before = lua_gettop(L);
uv_pipe_t* handle = (uv_pipe_t*)luv_checkudata(L, 1, "pipe");
uv_file file = luaL_checkint(L, 2);
uv_pipe_open(handle, file);
- assert(lua_gettop(L) == before);
return 0;
}
int luv_pipe_bind(lua_State* L) {
- int before = lua_gettop(L);
uv_pipe_t* handle = (uv_pipe_t*)luv_checkudata(L, 1, "pipe");
const char* name = luaL_checkstring(L, 2);
@@ -49,7 +45,6 @@ int luv_pipe_bind(lua_State* L) {
return luaL_error(L, "pipe_bind: %s", uv_strerror(err));
}
- assert(lua_gettop(L) == before);
return 0;
}
@@ -58,15 +53,13 @@ int luv_pipe_bind(lua_State* L) {
* const char* name, uv_connect_cb cb);
*/
int luv_pipe_connect(lua_State* L) {
- int before = lua_gettop(L);
uv_pipe_t* handle = (uv_pipe_t*)luv_checkudata(L, 1, "pipe");
const char* name = luaL_checkstring(L, 2);
uv_connect_t* req = (uv_connect_t*)malloc(sizeof(uv_connect_t));
uv_pipe_connect(req, handle, name, luv_after_connect);
- assert(lua_gettop(L) == before);
return 0;
}
View
@@ -16,7 +16,6 @@
*/
#include <stdlib.h>
-#include <assert.h>
#include "luv_process.h"
#include "luv_portability.h"
@@ -36,7 +35,6 @@ void luv_process_on_exit(uv_process_t* handle, int exit_status, int term_signal)
/* Initializes uv_process_t and starts the process. */
int luv_spawn(lua_State* L) {
- int before = lua_gettop(L);
uv_pipe_t* stdin_stream = (uv_pipe_t*)luv_checkudata(L, 1, "pipe");
uv_pipe_t* stdout_stream = (uv_pipe_t*)luv_checkudata(L, 2, "pipe");
uv_pipe_t* stderr_stream = (uv_pipe_t*)luv_checkudata(L, 3, "pipe");
@@ -105,7 +103,6 @@ int luv_spawn(lua_State* L) {
return luaL_error(L, "spawn: %s", uv_strerror(err));
}
- assert(lua_gettop(L) == before + 1);
/* return the userdata */
return 1;
}
View
@@ -16,7 +16,6 @@
*/
#include <stdlib.h>
-#include <assert.h>
#include "luv_stream.h"
View
@@ -54,7 +54,6 @@ int luv_tcp_keepalive (lua_State* L) {
int luv_tcp_bind (lua_State* L) {
- int before = lua_gettop(L);
uv_tcp_t* handle = (uv_tcp_t*)luv_checkudata(L, 1, "tcp");
const char* host = luaL_checkstring(L, 2);
int port = luaL_checkint(L, 3);
@@ -66,12 +65,10 @@ int luv_tcp_bind (lua_State* L) {
return luaL_error(L, "tcp_bind: %s", uv_strerror(err));
}
- assert(lua_gettop(L) == before);
return 0;
}
int luv_tcp_bind6(lua_State* L) {
- int before = lua_gettop(L);
uv_tcp_t* handle = (uv_tcp_t*)luv_checkudata(L, 1, "tcp");
const char* host = luaL_checkstring(L, 2);
int port = luaL_checkint(L, 3);
@@ -83,12 +80,10 @@ int luv_tcp_bind6(lua_State* L) {
return luaL_error(L, "tcp_bind6: %s", uv_strerror(err));
}
- assert(lua_gettop(L) == before);
return 0;
}
int luv_tcp_getsockname(lua_State* L) {
- int before = lua_gettop(L);
uv_tcp_t* handle = (uv_tcp_t*)luv_checkudata(L, 1, "tcp");
int port = 0;
char ip[INET6_ADDRSTRLEN];
@@ -121,12 +116,10 @@ int luv_tcp_getsockname(lua_State* L) {
lua_pushstring(L, ip);
lua_setfield(L, -2, "address");
- assert(lua_gettop(L) == before + 1);
return 1;
}
int luv_tcp_getpeername(lua_State* L) {
- int before = lua_gettop(L);
uv_tcp_t* handle = (uv_tcp_t*)luv_checkudata(L, 1, "tcp");
int port = 0;
char ip[INET6_ADDRSTRLEN];
@@ -159,12 +152,10 @@ int luv_tcp_getpeername(lua_State* L) {
lua_pushstring(L, ip);
lua_setfield(L, -2, "address");
- assert(lua_gettop(L) == before + 1);
return 1;
}
int luv_tcp_connect(lua_State* L) {
- int before = lua_gettop(L);
uv_tcp_t* handle = (uv_tcp_t*)luv_checkudata(L, 1, "tcp");
const char* ip_address = luaL_checkstring(L, 2);
@@ -181,12 +172,10 @@ int luv_tcp_connect(lua_State* L) {
luv_handle_ref(L, handle->data, 1);
- assert(lua_gettop(L) == before);
return 0;
}
int luv_tcp_connect6(lua_State* L) {
- int before = lua_gettop(L);
uv_tcp_t* handle = (uv_tcp_t*)luv_checkudata(L, 1, "tcp");
const char* ip_address = luaL_checkstring(L, 2);
@@ -201,7 +190,6 @@ int luv_tcp_connect6(lua_State* L) {
return luaL_error(L, "tcp_connect6: %s", uv_strerror(err));
}
- assert(lua_gettop(L) == before);
return 0;
}
Oops, something went wrong. Retry.

0 comments on commit 07e115a

Please sign in to comment.