1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 15:48:49 -05:00

curlassert macro replaced with DEBUGASSERT macro defined in setup_once.h

This commit is contained in:
Yang Tse 2007-02-21 19:03:20 +00:00
parent 06d1b029f6
commit 3a634a273a
15 changed files with 60 additions and 45 deletions

View 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];
}

View 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

View 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 */

View 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);

View 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 */

View 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:

View 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;

View 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);

View 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)

View 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)

View 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

View 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;
}

View 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;

View 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);

View 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 ?