aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2007-02-21 19:03:20 +0000
committerYang Tse <yangsita@gmail.com>2007-02-21 19:03:20 +0000
commit3a634a273a7bff3d219883f572db786e2c1004b1 (patch)
treea0f1f70c6de10f38c29e3f5f468bed50db759ec1
parent06d1b029f63b9b03dfa3b9bfe34ba1baeb67df29 (diff)
curlassert macro replaced with DEBUGASSERT macro defined in setup_once.h
-rw-r--r--ares/ares_strerror.c2
-rw-r--r--ares/setup_once.h15
-rw-r--r--lib/connect.c2
-rw-r--r--lib/hostip.c4
-rw-r--r--lib/hostthre.c4
-rw-r--r--lib/http.c14
-rw-r--r--lib/http_ntlm.c16
-rw-r--r--lib/inet_ntop.c2
-rw-r--r--lib/memdebug.c6
-rw-r--r--lib/setup.h7
-rw-r--r--lib/setup_once.h15
-rw-r--r--lib/ssluse.c8
-rw-r--r--lib/strerror.c6
-rw-r--r--lib/telnet.c2
-rw-r--r--lib/transfer.c2
15 files changed, 60 insertions, 45 deletions
diff --git a/ares/ares_strerror.c b/ares/ares_strerror.c
index 28d2e0bf1..3486ebfbb 100644
--- a/ares/ares_strerror.c
+++ b/ares/ares_strerror.c
@@ -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];
}
diff --git a/ares/setup_once.h b/ares/setup_once.h
index 32d8293ee..20ea3819d 100644
--- a/ares/setup_once.h
+++ b/ares/setup_once.h
@@ -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
diff --git a/lib/connect.c b/lib/connect.c
index 5be0df27e..2b8e11ff8 100644
--- a/lib/connect.c
+++ b/lib/connect.c
@@ -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 */
diff --git a/lib/hostip.c b/lib/hostip.c
index fd555ef9d..b27475188 100644
--- a/lib/hostip.c
+++ b/lib/hostip.c
@@ -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);
diff --git a/lib/hostthre.c b/lib/hostthre.c
index c588c558b..9c8942a28 100644
--- a/lib/hostthre.c
+++ b/lib/hostthre.c
@@ -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 */
diff --git a/lib/http.c b/lib/http.c
index 638c5fad2..522bc00f4 100644
--- a/lib/http.c
+++ b/lib/http.c
@@ -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:
diff --git a/lib/http_ntlm.c b/lib/http_ntlm.c
index aff1bb1b6..8e910a290 100644
--- a/lib/http_ntlm.c
+++ b/lib/http_ntlm.c
@@ -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;
diff --git a/lib/inet_ntop.c b/lib/inet_ntop.c
index a0b8ba46b..8ff428192 100644
--- a/lib/inet_ntop.c
+++ b/lib/inet_ntop.c
@@ -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);
diff --git a/lib/memdebug.c b/lib/memdebug.c
index cca62347d..110169474 100644
--- a/lib/memdebug.c
+++ b/lib/memdebug.c
@@ -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)
diff --git a/lib/setup.h b/lib/setup.h
index ca8155b3a..d02eec92d 100644
--- a/lib/setup.h
+++ b/lib/setup.h
@@ -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)
diff --git a/lib/setup_once.h b/lib/setup_once.h
index 190b69ed7..7af68bf3f 100644
--- a/lib/setup_once.h
+++ b/lib/setup_once.h
@@ -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
diff --git a/lib/ssluse.c b/lib/ssluse.c
index b362ab3f2..6ef57853a 100644
--- a/lib/ssluse.c
+++ b/lib/ssluse.c
@@ -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;
}
diff --git a/lib/strerror.c b/lib/strerror.c
index e18af7286..b07067cec 100644
--- a/lib/strerror.c
+++ b/lib/strerror.c
@@ -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;
diff --git a/lib/telnet.c b/lib/telnet.c
index 4449a7949..74467ec86 100644
--- a/lib/telnet.c
+++ b/lib/telnet.c
@@ -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);
diff --git a/lib/transfer.c b/lib/transfer.c
index a311a9974..7fb08883a 100644
--- a/lib/transfer.c
+++ b/lib/transfer.c
@@ -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 ?