]> granicus.if.org Git - curl/commitdiff
curlassert macro replaced with DEBUGASSERT macro defined in setup_once.h
authorYang Tse <yangsita@gmail.com>
Wed, 21 Feb 2007 19:03:20 +0000 (19:03 +0000)
committerYang Tse <yangsita@gmail.com>
Wed, 21 Feb 2007 19:03:20 +0000 (19:03 +0000)
15 files changed:
ares/ares_strerror.c
ares/setup_once.h
lib/connect.c
lib/hostip.c
lib/hostthre.c
lib/http.c
lib/http_ntlm.c
lib/inet_ntop.c
lib/memdebug.c
lib/setup.h
lib/setup_once.h
lib/ssluse.c
lib/strerror.c
lib/telnet.c
lib/transfer.c

index 28d2e0bf1665dcd68ef82a826ff51299c93bff4f..3486ebfbbb9cd698aba34dba6c6477f78f20cb64 100644 (file)
@@ -46,6 +46,6 @@ const char *ares_strerror(int code)
     "Illegal hints flags specified"
   };
 
-  assert(code >= 0 && code < (int)(sizeof(errtext) / sizeof(*errtext)));
+  DEBUGASSERT(code >= 0 && code < (int)(sizeof(errtext) / sizeof(*errtext)));
   return errtext[code];
 }
index 32d8293eee8ff730f64fb3948f71426b75f60316..20ea3819ddf94cec8c02c236932f8864c5987936 100644 (file)
@@ -200,9 +200,20 @@ typedef int sig_atomic_t;
  */
 
 #ifdef CURLDEBUG
-#define DEBUGF(X) X
+#define DEBUGF(x) x
 #else
-#define DEBUGF(X) do { } while (0)
+#define DEBUGF(x) do { } while (0)
+#endif
+
+
+/*
+ * Macro used to include assertion code only in debug builds.
+ */
+
+#if defined(CURLDEBUG) && defined(HAVE_ASSERT_H)
+#define DEBUGASSERT(x) assert(x)
+#else
+#define DEBUGASSERT(x) do { } while (0)
 #endif
 
 
index 5be0df27e230fa0aeef810f06ffae2f5f91f3988..2b8e11ff82513a757f330ac8f5128808a396f5ab 100644 (file)
@@ -527,7 +527,7 @@ CURLcode Curl_is_connected(struct connectdata *conn,
   long allow_total = 0;
   long has_passed;
 
-  curlassert(sockindex >= FIRSTSOCKET && sockindex <= SECONDARYSOCKET);
+  DEBUGASSERT(sockindex >= FIRSTSOCKET && sockindex <= SECONDARYSOCKET);
 
   *connected = FALSE; /* a very negative world view is best */
 
index fd555ef9dad904e854ce6344f61abc274469eebc..b27475188990a98137821eb5da174257671f4026 100644 (file)
@@ -5,7 +5,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
  *
  * This software is licensed as described in the file COPYING, which
  * you should have received as part of this distribution. The terms
@@ -512,7 +512,7 @@ int Curl_resolv(struct connectdata *conn,
  */
 void Curl_resolv_unlock(struct SessionHandle *data, struct Curl_dns_entry *dns)
 {
-  curlassert(dns && (dns->inuse>0));
+  DEBUGASSERT(dns && (dns->inuse>0));
 
   if(data->share)
     Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE);
index c588c558b74bc7975c220d4dc3596c56312535db..9c8942a289c68b45307c0cfaec8f9b64fefc0250 100644 (file)
@@ -537,7 +537,7 @@ static bool init_resolve_thread (struct connectdata *conn,
 #endif
 
 #ifdef CURLRES_IPV6
-  curlassert(hints);
+  DEBUGASSERT(hints);
   td->hints = *hints;
 #else
   (void) hints;
@@ -591,7 +591,7 @@ CURLcode Curl_wait_for_resolv(struct connectdata *conn,
   DWORD  status, ticks;
   CURLcode rc;
 
-  curlassert (conn && td);
+  DEBUGASSERT(conn && td);
 
   /* now, see if there's a connect timeout or a regular timeout to
      use instead of the default one */
index 638c5fad2e70bd40852a946a00b44933d9905ae9..522bc00f4b4e6bdce22632bdfc0370cc64a19360 100644 (file)
@@ -391,7 +391,7 @@ Curl_http_output_auth(struct connectdata *conn,
   struct auth *authhost;
   struct auth *authproxy;
 
-  curlassert(data);
+  DEBUGASSERT(data);
 
   authhost = &data->state.authhost;
   authproxy = &data->state.authproxy;
@@ -676,9 +676,9 @@ int Curl_http_should_fail(struct connectdata *conn)
   struct SessionHandle *data;
   struct Curl_transfer_keeper *k;
 
-  curlassert(conn);
+  DEBUGASSERT(conn);
   data = conn->data;
-  curlassert(data);
+  DEBUGASSERT(data);
 
   /*
   ** For readability
@@ -717,7 +717,7 @@ int Curl_http_should_fail(struct connectdata *conn)
   /*
   ** All we have left to deal with is 401 and 407
   */
-  curlassert((k->httpcode == 401) || (k->httpcode == 407));
+  DEBUGASSERT((k->httpcode == 401) || (k->httpcode == 407));
 
   /*
   ** Examine the current authentication state to see if this
@@ -864,7 +864,7 @@ CURLcode add_buffer_send(send_buffer *in,
   size_t sendsize;
   curl_socket_t sockfd;
 
-  curlassert(socketindex <= SECONDARYSOCKET);
+  DEBUGASSERT(socketindex <= SECONDARYSOCKET);
 
   sockfd = conn->sock[socketindex];
 
@@ -1459,7 +1459,7 @@ CURLcode Curl_http_connect(struct connectdata *conn, bool *done)
 CURLcode Curl_https_connecting(struct connectdata *conn, bool *done)
 {
   CURLcode result;
-  curlassert(conn->protocol & PROT_HTTPS);
+  DEBUGASSERT((conn) && (conn->protocol & PROT_HTTPS));
 
   /* perform SSL initialization for this socket */
   result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, done);
@@ -1690,7 +1690,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
     if(conn->bits.no_body)
       request = (char *)"HEAD";
     else {
-      curlassert((httpreq > HTTPREQ_NONE) && (httpreq < HTTPREQ_LAST));
+      DEBUGASSERT((httpreq > HTTPREQ_NONE) && (httpreq < HTTPREQ_LAST));
       switch(httpreq) {
       case HTTPREQ_POST:
       case HTTPREQ_POST_FORM:
index aff1bb1b632a0146fe979f0ae58d59c88bdf6c7f..8e910a2904917a324cb14efe263353b244f5bf03 100644 (file)
@@ -511,8 +511,8 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
   struct ntlmdata *ntlm;
   struct auth *authp;
 
-  curlassert(conn);
-  curlassert(conn->data);
+  DEBUGASSERT(conn);
+  DEBUGASSERT(conn->data);
 
   if(proxy) {
     allocuserpwd = &conn->allocptr.proxyuserpwd;
@@ -991,9 +991,9 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
                     0x0, 0x0,
 
                     LONGQUARTET(ntlm->flags));
-    DEBUG_OUT(assert(size==64));
+    DEBUGASSERT(size==64);
 
-    DEBUG_OUT(assert(size == lmrespoff));
+    DEBUGASSERT(size == lmrespoff);
     /* We append the binary hashes */
     if(size < (sizeof(ntlmbuf) - 0x18)) {
       memcpy(&ntlmbuf[size], lmresp, 0x18);
@@ -1007,7 +1007,7 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
 
 #if USE_NTRESPONSES
     if(size < (sizeof(ntlmbuf) - 0x18)) {
-      DEBUG_OUT(assert(size == ntrespoff));
+      DEBUGASSERT(size == ntrespoff);
       memcpy(&ntlmbuf[size], ntresp, 0x18);
       size += 0x18;
     }
@@ -1034,15 +1034,15 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
       return CURLE_OUT_OF_MEMORY;
     }
 
-    curlassert(size == domoff);
+    DEBUGASSERT(size == domoff);
     memcpy(&ntlmbuf[size], domain, domlen);
     size += domlen;
 
-    curlassert(size == useroff);
+    DEBUGASSERT(size == useroff);
     memcpy(&ntlmbuf[size], user, userlen);
     size += userlen;
 
-    curlassert(size == hostoff);
+    DEBUGASSERT(size == hostoff);
     memcpy(&ntlmbuf[size], host, hostlen);
     size += hostlen;
 
index a0b8ba46bab68591b7c6333c2a4559c4c1655ffd..8ff428192398e8b74a53e7f9ace6cdb846d4d890 100644 (file)
@@ -67,7 +67,7 @@ static char *inet_ntop4 (const unsigned char *src, char *dst, size_t size)
 {
 #if defined(HAVE_INET_NTOA_R_2_ARGS)
   const char *ptr;
-  curlassert(size >= 16);
+  DEBUGASSERT(size >= 16);
   ptr = inet_ntoa_r(*(struct in_addr*)src, dst);
   return (char *)memmove(dst, ptr, strlen(ptr)+1);
 
index cca62347d6afa606fca7e29c1f8d396720bdea15..110169474bc652e2b2e7b081bc8af93a051133e5 100644 (file)
@@ -170,7 +170,7 @@ char *curl_dostrdup(const char *str, int line, const char *source)
   char *mem;
   size_t len;
 
-  curlassert(str != NULL);
+  DEBUGASSERT(str != NULL);
 
   if(countcheck("strdup", line, source))
     return NULL;
@@ -220,7 +220,7 @@ void curl_dofree(void *ptr, int line, const char *source)
 {
   struct memdebug *mem;
 
-  curlassert(ptr != NULL);
+  DEBUGASSERT(ptr != NULL);
 
   mem = (struct memdebug *)((char *)ptr - offsetof(struct memdebug, mem));
 
@@ -280,7 +280,7 @@ int curl_fclose(FILE *file, int line, const char *source)
 {
   int res;
 
-  curlassert(file != NULL);
+  DEBUGASSERT(file != NULL);
 
   res=(fclose)(file);
   if(logfile)
index ca8155b3a531676cc5bf87eae5b0c57d58d32279..d02eec92dfcabae45cff30c7b82b55c94b27b299 100644 (file)
@@ -204,13 +204,6 @@ typedef unsigned char bool;
   #include <clib.h>
 #endif
 
-#if defined(CURLDEBUG) && defined(HAVE_ASSERT_H)
-#define curlassert(x) assert(x)
-#else
-/* does nothing without CURLDEBUG defined */
-#define curlassert(x)
-#endif
-
 
 /* To make large file support transparent even on Windows */
 #if defined(WIN32) && (SIZEOF_CURL_OFF_T > 4)
index 190b69ed71334d563839c0848d36b9b593905443..7af68bf3fc53e14e1f4817bf4400da1257239fa1 100644 (file)
@@ -207,9 +207,20 @@ typedef int sig_atomic_t;
  */
 
 #ifdef CURLDEBUG
-#define DEBUGF(X) X
+#define DEBUGF(x) x
 #else
-#define DEBUGF(X) do { } while (0)
+#define DEBUGF(x) do { } while (0)
+#endif
+
+
+/*
+ * Macro used to include assertion code only in debug builds.
+ */
+
+#if defined(CURLDEBUG) && defined(HAVE_ASSERT_H)
+#define DEBUGASSERT(x) assert(x)
+#else
+#define DEBUGASSERT(x) do { } while (0)
 #endif
 
 
index b362ab3f2e12206605a04398880474ce6e33ce8d..6ef57853a02129e2fce8e1b95b8fce82c763014d 100644 (file)
@@ -1272,7 +1272,7 @@ Curl_ossl_connect_step1(struct connectdata *conn,
   curl_socket_t sockfd = conn->sock[sockindex];
   struct ssl_connect_data *connssl = &conn->ssl[sockindex];
 
-  curlassert(ssl_connect_1 == connssl->connecting_state);
+  DEBUGASSERT(ssl_connect_1 == connssl->connecting_state);
 
   /* Make funny stuff to get random input */
   Curl_ossl_seed(data);
@@ -1451,7 +1451,7 @@ Curl_ossl_connect_step2(struct connectdata *conn,
   long has_passed;
   struct ssl_connect_data *connssl = &conn->ssl[sockindex];
 
-  curlassert(ssl_connect_2 == connssl->connecting_state
+  DEBUGASSERT(ssl_connect_2 == connssl->connecting_state
              || ssl_connect_2_reading == connssl->connecting_state
              || ssl_connect_2_writing == connssl->connecting_state);
 
@@ -1581,7 +1581,7 @@ Curl_ossl_connect_step3(struct connectdata *conn,
   struct SessionHandle *data = conn->data;
   struct ssl_connect_data *connssl = &conn->ssl[sockindex];
 
-  curlassert(ssl_connect_3 == connssl->connecting_state);
+  DEBUGASSERT(ssl_connect_3 == connssl->connecting_state);
 
   if(Curl_ssl_getsessionid(conn, &ssl_sessionid, NULL)) {
     /* Since this is not a cached session ID, then we want to stach this one
@@ -1794,7 +1794,7 @@ Curl_ossl_connect(struct connectdata *conn,
   if (retcode)
     return retcode;
 
-  curlassert(done);
+  DEBUGASSERT(done);
 
   return CURLE_OK;
 }
index e18af7286d26e3a0eaeb075e2212ac811d0007ec..b07067cec6e2fcf6567be9e716213491e76d1da6 100644 (file)
@@ -600,8 +600,8 @@ const char *Curl_strerror(struct connectdata *conn, int err)
   char *buf, *p;
   size_t max;
 
-  curlassert(conn);
-  curlassert(err >= 0);
+  DEBUGASSERT(conn);
+  DEBUGASSERT(err >= 0);
 
   buf = conn->syserr_buf;
   max = sizeof(conn->syserr_buf)-1;
@@ -685,7 +685,7 @@ const char *Curl_idn_strerror (struct connectdata *conn, int err)
   char *buf;
   size_t max;
 
-  curlassert(conn);
+  DEBUGASSERT(conn);
 
   buf = conn->syserr_buf;
   max = sizeof(conn->syserr_buf)-1;
index 4449a7949ec8c4c6c6101d1bca026ee2b41bc552..74467ec868fa5bc8fda7b4886d8402c0080315e7 100644 (file)
@@ -179,7 +179,7 @@ check_wsock2 ( struct SessionHandle *data )
   WORD wVersionRequested;
   WSADATA wsaData;
 
-  curlassert(data);
+  DEBUGASSERT(data);
 
   /* telnet requires at least WinSock 2.0 so ask for it. */
   wVersionRequested = MAKEWORD(2, 0);
index a311a9974a77bbef2af9da097e0313dfa05e4c45..7fb08883a0dec38654db95c18eb1229a3b671ccc 100644 (file)
@@ -2481,7 +2481,7 @@ Curl_setup_transfer(
   if(!conn)
     return CURLE_BAD_FUNCTION_ARGUMENT;
 
-  curlassert((sockindex <= 1) && (sockindex >= -1));
+  DEBUGASSERT((sockindex <= 1) && (sockindex >= -1));
 
   /* now copy all input parameters */
   conn->sockfd = sockindex == -1 ?