3131#include " util.h"
3232#include " uv.h"
3333
34- #include < assert.h>
3534#include < errno.h>
3635#include < stdlib.h>
3736#include < string.h>
@@ -85,7 +84,7 @@ RB_GENERATE_STATIC(ares_task_list, ares_task_t, node, cmp_ares_tasks)
8584/* call back into c-ares for possibly processing timeouts. */
8685static void ares_timeout (uv_timer_t * handle) {
8786 Environment* env = Environment::from_cares_timer_handle (handle);
88- assert (! RB_EMPTY (env->cares_task_list ()));
87+ CHECK_EQ ( false , RB_EMPTY (env->cares_task_list ()));
8988 ares_process_fd (env->cares_channel (), ARES_SOCKET_BAD, ARES_SOCKET_BAD);
9089}
9190
@@ -159,7 +158,7 @@ static void ares_sockstate_cb(void* data,
159158 /* If this is the first socket then start the timer. */
160159 uv_timer_t * timer_handle = env->cares_timer_handle ();
161160 if (!uv_is_active (reinterpret_cast <uv_handle_t *>(timer_handle))) {
162- assert (RB_EMPTY (env->cares_task_list ()));
161+ CHECK (RB_EMPTY (env->cares_task_list ()));
163162 uv_timer_start (timer_handle, ares_timeout, 1000 , 1000 );
164163 }
165164
@@ -184,8 +183,8 @@ static void ares_sockstate_cb(void* data,
184183 /* read == 0 and write == 0 this is c-ares's way of notifying us that */
185184 /* the socket is now closed. We must free the data associated with */
186185 /* socket. */
187- assert (task &&
188- " When an ares socket is closed we should have a handle for it" );
186+ CHECK (task &&
187+ " When an ares socket is closed we should have a handle for it" );
189188
190189 RB_REMOVE (ares_task_list, env->cares_task_list (), task);
191190 uv_close (reinterpret_cast <uv_handle_t *>(&task->poll_watcher ),
@@ -233,18 +232,18 @@ class QueryWrap : public AsyncWrap {
233232 }
234233
235234 virtual ~QueryWrap () {
236- assert (! persistent ().IsEmpty ());
235+ CHECK_EQ ( false , persistent ().IsEmpty ());
237236 persistent ().Reset ();
238237 }
239238
240239 // Subclasses should implement the appropriate Send method.
241240 virtual int Send (const char * name) {
242- assert ( 0 );
241+ UNREACHABLE ( );
243242 return 0 ;
244243 }
245244
246245 virtual int Send (const char * name, int family) {
247- assert ( 0 );
246+ UNREACHABLE ( );
248247 return 0 ;
249248 }
250249
@@ -301,7 +300,7 @@ class QueryWrap : public AsyncWrap {
301300 }
302301
303302 void ParseError (int status) {
304- assert (status != ARES_SUCCESS);
303+ CHECK_NE (status, ARES_SUCCESS);
305304 HandleScope handle_scope (env ()->isolate ());
306305 Context::Scope context_scope (env ()->context ());
307306 Local<Value> arg;
@@ -344,11 +343,11 @@ class QueryWrap : public AsyncWrap {
344343
345344 // Subclasses should implement the appropriate Parse method.
346345 virtual void Parse (unsigned char * buf, int len) {
347- assert ( 0 );
346+ UNREACHABLE ( );
348347 };
349348
350349 virtual void Parse (struct hostent * host) {
351- assert ( 0 );
350+ UNREACHABLE ( );
352351 };
353352};
354353
@@ -843,9 +842,9 @@ template <class Wrap>
843842static void Query (const FunctionCallbackInfo<Value>& args) {
844843 Environment* env = Environment::GetCurrent (args.GetIsolate ());
845844
846- assert (! args.IsConstructCall ());
847- assert (args[0 ]->IsObject ());
848- assert (args[1 ]->IsString ());
845+ CHECK_EQ ( false , args.IsConstructCall ());
846+ CHECK (args[0 ]->IsObject ());
847+ CHECK (args[1 ]->IsString ());
849848
850849 Local<Object> req_wrap_obj = args[0 ].As <Object>();
851850 Local<String> string = args[1 ].As <String>();
@@ -894,7 +893,7 @@ void AfterGetAddrInfo(uv_getaddrinfo_t* req, int status, struct addrinfo* res) {
894893 // strings for each IP and filling the results array.
895894 address = res;
896895 while (address) {
897- assert (address->ai_socktype == SOCK_STREAM);
896+ CHECK_EQ (address->ai_socktype , SOCK_STREAM);
898897
899898 // Ignore random ai_family types.
900899 if (address->ai_family == AF_INET) {
@@ -921,7 +920,7 @@ void AfterGetAddrInfo(uv_getaddrinfo_t* req, int status, struct addrinfo* res) {
921920 // Iterate over the IPv6 responses putting them in the array.
922921 address = res;
923922 while (address) {
924- assert (address->ai_socktype == SOCK_STREAM);
923+ CHECK_EQ (address->ai_socktype , SOCK_STREAM);
925924
926925 // Ignore random ai_family types.
927926 if (address->ai_family == AF_INET6) {
@@ -1008,9 +1007,9 @@ static void IsIP(const FunctionCallbackInfo<Value>& args) {
10081007static void GetAddrInfo (const FunctionCallbackInfo<Value>& args) {
10091008 Environment* env = Environment::GetCurrent (args.GetIsolate ());
10101009
1011- assert (args[0 ]->IsObject ());
1012- assert (args[1 ]->IsString ());
1013- assert (args[2 ]->IsInt32 ());
1010+ CHECK (args[0 ]->IsObject ());
1011+ CHECK (args[1 ]->IsString ());
1012+ CHECK (args[2 ]->IsInt32 ());
10141013 Local<Object> req_wrap_obj = args[0 ].As <Object>();
10151014 node::Utf8Value hostname (args[1 ]);
10161015
@@ -1028,7 +1027,7 @@ static void GetAddrInfo(const FunctionCallbackInfo<Value>& args) {
10281027 family = AF_INET6;
10291028 break ;
10301029 default :
1031- assert (0 && " bad address family" );
1030+ CHECK (0 && " bad address family" );
10321031 abort ();
10331032 }
10341033
@@ -1097,7 +1096,7 @@ static void GetServers(const FunctionCallbackInfo<Value>& args) {
10971096 ares_addr_node* servers;
10981097
10991098 int r = ares_get_servers (env->cares_channel (), &servers);
1100- assert (r == ARES_SUCCESS);
1099+ CHECK_EQ (r, ARES_SUCCESS);
11011100
11021101 ares_addr_node* cur = servers;
11031102
@@ -1106,7 +1105,7 @@ static void GetServers(const FunctionCallbackInfo<Value>& args) {
11061105
11071106 const void * caddr = static_cast <const void *>(&cur->addr );
11081107 int err = uv_inet_ntop (cur->family , caddr, ip, sizeof (ip));
1109- assert (err == 0 );
1108+ CHECK_EQ (err, 0 );
11101109
11111110 Local<String> addr = OneByteString (env->isolate (), ip);
11121111 server_array->Set (i, addr);
@@ -1121,7 +1120,7 @@ static void GetServers(const FunctionCallbackInfo<Value>& args) {
11211120static void SetServers (const FunctionCallbackInfo<Value>& args) {
11221121 Environment* env = Environment::GetCurrent (args.GetIsolate ());
11231122
1124- assert (args[0 ]->IsArray ());
1123+ CHECK (args[0 ]->IsArray ());
11251124
11261125 Local<Array> arr = Local<Array>::Cast (args[0 ]);
11271126
@@ -1138,12 +1137,12 @@ static void SetServers(const FunctionCallbackInfo<Value>& args) {
11381137 int err;
11391138
11401139 for (uint32_t i = 0 ; i < len; i++) {
1141- assert (arr->Get (i)->IsArray ());
1140+ CHECK (arr->Get (i)->IsArray ());
11421141
11431142 Local<Array> elm = Local<Array>::Cast (arr->Get (i));
11441143
1145- assert (elm->Get (0 )->Int32Value ());
1146- assert (elm->Get (1 )->IsString ());
1144+ CHECK (elm->Get (0 )->Int32Value ());
1145+ CHECK (elm->Get (1 )->IsString ());
11471146
11481147 int fam = elm->Get (0 )->Int32Value ();
11491148 node::Utf8Value ip (elm->Get (1 ));
@@ -1160,7 +1159,7 @@ static void SetServers(const FunctionCallbackInfo<Value>& args) {
11601159 err = uv_inet_pton (AF_INET6, *ip, &cur->addr );
11611160 break ;
11621161 default :
1163- assert (0 && " Bad address family." );
1162+ CHECK (0 && " Bad address family." );
11641163 abort ();
11651164 }
11661165
@@ -1213,7 +1212,7 @@ static void Initialize(Handle<Object> target,
12131212 Environment* env = Environment::GetCurrent (context);
12141213
12151214 int r = ares_library_init (ARES_LIB_INIT_ALL);
1216- assert (r == ARES_SUCCESS);
1215+ CHECK_EQ (r, ARES_SUCCESS);
12171216
12181217 struct ares_options options;
12191218 memset (&options, 0 , sizeof (options));
@@ -1225,7 +1224,7 @@ static void Initialize(Handle<Object> target,
12251224 r = ares_init_options (env->cares_channel_ptr (),
12261225 &options,
12271226 ARES_OPT_FLAGS | ARES_OPT_SOCK_STATE_CB);
1228- assert (r == ARES_SUCCESS);
1227+ CHECK_EQ (r, ARES_SUCCESS);
12291228
12301229 /* Initialize the timeout timer. The timer won't be started until the */
12311230 /* first socket is opened. */
0 commit comments