From: phk Date: Thu, 24 Aug 2006 07:57:07 +0000 (+0000) Subject: Go through all asserts and mark those which indicate missing code with X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=07b6f98f4456faf08696fdfbbe106bb714b99699;p=varnish Go through all asserts and mark those which indicate missing code with xxx or XXX. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@914 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache_acceptor.c b/varnish-cache/bin/varnishd/cache_acceptor.c index c6260182..fa77bf4a 100644 --- a/varnish-cache/bin/varnishd/cache_acceptor.c +++ b/varnish-cache/bin/varnishd/cache_acceptor.c @@ -63,7 +63,7 @@ vca_accept_sess(int fd) return (NULL); } sp = SES_New(addr, l); - assert(sp != NULL); /* XXX handle */ + XXXAN(sp); (void)clock_gettime(CLOCK_REALTIME, &sp->t_open); sp->fd = i; @@ -156,8 +156,8 @@ vca_return_session(struct sess *sp) { CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - assert(sp->obj == NULL); - assert(sp->vcl == NULL); + AZ(sp->obj); + AZ(sp->vcl); if (sp->fd >= 0) { VSL(SLT_SessionReuse, sp->fd, "%s %s", sp->addr, sp->port); (void)clock_gettime(CLOCK_REALTIME, &sp->t_open); diff --git a/varnish-cache/bin/varnishd/cache_acceptor_kqueue.c b/varnish-cache/bin/varnishd/cache_acceptor_kqueue.c index e6e62803..ec4ea537 100644 --- a/varnish-cache/bin/varnishd/cache_acceptor_kqueue.c +++ b/varnish-cache/bin/varnishd/cache_acceptor_kqueue.c @@ -32,14 +32,12 @@ static void vca_kq_sess(struct sess *sp, int arm) { struct kevent ke; - int i; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); if (sp->fd < 0) return; EV_SET(&ke, sp->fd, EVFILT_READ, arm, 0, 0, sp); - i = kevent(kq, &ke, 1, NULL, 0, NULL); - assert(i == 0); + AZ(kevent(kq, &ke, 1, NULL, 0, NULL)); } static void @@ -48,7 +46,7 @@ vca_kev(struct kevent *kp) int i; struct sess *sp; - assert(kp->udata != NULL); + AN(kp->udata); if (kp->udata == pipes) { while (kp->data > 0) { i = read(pipes[0], &sp, sizeof sp); @@ -89,7 +87,7 @@ static void * vca_kqueue_main(void *arg) { struct kevent ke[NKEV], *kp; - int i, j, n; + int j, n; struct timespec ts; struct sess *sp; @@ -101,8 +99,7 @@ vca_kqueue_main(void *arg) j = 0; EV_SET(&ke[j++], 0, EVFILT_TIMER, EV_ADD, 0, 100, NULL); EV_SET(&ke[j++], pipes[0], EVFILT_READ, EV_ADD, 0, 0, pipes); - i = kevent(kq, ke, j, NULL, 0, NULL); - assert(i == 0); + AZ(kevent(kq, ke, j, NULL, 0, NULL)); while (1) { n = kevent(kq, NULL, 0, ke, NKEV, NULL); diff --git a/varnish-cache/bin/varnishd/cache_acceptor_poll.c b/varnish-cache/bin/varnishd/cache_acceptor_poll.c index 298c5c58..d0dcd7a8 100644 --- a/varnish-cache/bin/varnishd/cache_acceptor_poll.c +++ b/varnish-cache/bin/varnishd/cache_acceptor_poll.c @@ -44,7 +44,7 @@ vca_pollspace(int fd) u += u; VSL(SLT_Debug, 0, "Acceptor Pollspace %u", u); p = realloc(pollfd, u * sizeof *p); - assert(p != NULL); + XXXAN(p); /* close offending fd */ memset(p + npoll, 0, (u - npoll) * sizeof *p); for (v = npoll ; v <= u; v++) p->fd = -1; diff --git a/varnish-cache/bin/varnishd/cache_backend.c b/varnish-cache/bin/varnishd/cache_backend.c index 950be406..674d11ed 100644 --- a/varnish-cache/bin/varnishd/cache_backend.c +++ b/varnish-cache/bin/varnishd/cache_backend.c @@ -151,8 +151,8 @@ vbe_connect(struct backend *bp) char pbuf1[TCP_PORTBUFSIZE], pbuf2[TCP_PORTBUFSIZE]; struct addrinfo *ai; - assert(bp != NULL); - assert(bp->hostname != NULL); + CHECK_OBJ_NOTNULL(bp, BACKEND_MAGIC); + AN(bp->hostname); s = vbe_conn_try(bp, &ai); if (s < 0) @@ -217,14 +217,14 @@ VBE_GetFd(struct backend *bp, unsigned xid) vc = vbe_new_conn(); else vc = vc2; - assert(vc != NULL); + AN(vc); assert(vc->fd == -1); - assert(vc->backend == NULL); + AZ(vc->backend); } /* If not connected yet, do so */ if (vc->fd < 0) { - assert(vc->backend == NULL); + AZ(vc->backend); vc->fd = vbe_connect(bp); LOCK(&vbemtx); if (vc->fd < 0) { @@ -244,7 +244,7 @@ VBE_GetFd(struct backend *bp, unsigned xid) assert(vc->fd >= 0); VSL_stats->backend_conn++; VSL(SLT_BackendXID, vc->fd, "%u", xid); - assert(vc->backend != NULL); + AN(vc->backend); } return (vc); } @@ -257,7 +257,7 @@ VBE_ClosedFd(struct vbe_conn *vc, int already) CHECK_OBJ_NOTNULL(vc, VBE_CONN_MAGIC); assert(vc->fd >= 0); - assert(vc->backend != NULL); + AN(vc->backend); VSL(SLT_BackendClose, vc->fd, "%s", vc->backend->vcl_name); if (!already) AZ(close(vc->fd)); @@ -277,7 +277,7 @@ VBE_RecycleFd(struct vbe_conn *vc) CHECK_OBJ_NOTNULL(vc, VBE_CONN_MAGIC); assert(vc->fd >= 0); - assert(vc->backend != NULL); + AN(vc->backend); VSL_stats->backend_recycle++; VSL(SLT_BackendReuse, vc->fd, "%s", vc->backend->vcl_name); LOCK(&vbemtx); diff --git a/varnish-cache/bin/varnishd/cache_ban.c b/varnish-cache/bin/varnishd/cache_ban.c index db9264df..ebd43110 100644 --- a/varnish-cache/bin/varnishd/cache_ban.c +++ b/varnish-cache/bin/varnishd/cache_ban.c @@ -30,7 +30,7 @@ AddBan(const char *regexp) int i; b = calloc(sizeof *b, 1); - assert(b != NULL); + XXXAN(b); i = regcomp(&b->regexp, regexp, REG_EXTENDED | REG_NOSUB); if (i) { diff --git a/varnish-cache/bin/varnishd/cache_center.c b/varnish-cache/bin/varnishd/cache_center.c index cce8898f..b4a3565e 100644 --- a/varnish-cache/bin/varnishd/cache_center.c +++ b/varnish-cache/bin/varnishd/cache_center.c @@ -95,8 +95,8 @@ cnt_done(struct sess *sp) double dh, dp, da; struct timespec te; - assert(sp->obj == NULL); - assert(sp->vbc == NULL); + AZ(sp->obj); + AZ(sp->vbc); if (sp->fd >= 0 && sp->doclose != NULL) vca_close_session(sp, sp->doclose); sp->backend = NULL; @@ -194,7 +194,7 @@ static int cnt_fetch(struct sess *sp) { - assert(sp->vbc != NULL); + CHECK_OBJ_NOTNULL(sp->vbc, VBE_CONN_MAGIC); RFC2616_cache_policy(sp, sp->vbc->http); VCL_fetch_method(sp); @@ -220,9 +220,8 @@ cnt_fetch(struct sess *sp) } if (sp->handling == VCL_RET_INSERT) { sp->obj->cacheable = 1; - assert(sp->vbc != NULL); FetchBody(sp); - assert(sp->vbc == NULL); + AZ(sp->vbc); HSH_Ref(sp->obj); /* get another, STP_DELIVER will deref */ HSH_Unbusy(sp->obj); sp->wrk->acct.fetch++; @@ -362,7 +361,7 @@ static int cnt_lookup(struct sess *sp) { - assert(sp->obj == NULL); + AZ(sp->obj); sp->step = STP_LOOKUP2; return (0); } @@ -469,10 +468,10 @@ cnt_miss(struct sess *sp) if (sp->handling == VCL_RET_LOOKUP) INCOMPL(); if (sp->handling == VCL_RET_FETCH) { - assert(sp->vbc == NULL); + AZ(sp->vbc); FetchHeaders(sp); sp->step = STP_FETCH; - assert(sp->vbc != NULL); + AN(sp->vbc); return (0); } INCOMPL(); @@ -497,9 +496,9 @@ static int cnt_pass(struct sess *sp) { - assert(sp->vbc == NULL); + AZ(sp->vbc); if (!PassSession(sp)) { - assert(sp->vbc != NULL); + AN(sp->vbc); sp->step = STP_PASSBODY; } else sp->step = STP_DONE; @@ -526,9 +525,9 @@ cnt_passbody(struct sess *sp) { sp->wrk->acct.pass++; - assert(sp->vbc != NULL); + AN(sp->vbc); PassBody(sp); - assert(sp->vbc == NULL); + AZ(sp->vbc); sp->step = STP_DONE; return (0); } @@ -591,11 +590,11 @@ cnt_recv(struct sess *sp) int done; sp->t0 = time(NULL); - assert(sp->vcl == NULL); + AZ(sp->vcl); sp->vcl = VCL_Get(); - assert(sp->obj == NULL); - assert(sp->vbc == NULL); + AZ(sp->obj); + AZ(sp->vbc); sp->wrk->acct.req++; done = http_DissectRequest(sp->http, sp->fd); diff --git a/varnish-cache/bin/varnishd/cache_cli.c b/varnish-cache/bin/varnishd/cache_cli.c index d244c5fc..fd8ff6c0 100644 --- a/varnish-cache/bin/varnishd/cache_cli.c +++ b/varnish-cache/bin/varnishd/cache_cli.c @@ -65,10 +65,10 @@ CLI_Init(void) memset(cli, 0, sizeof *cli); cli->sb = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND); - assert(cli->sb != NULL); + XXXAN(cli->sb); lbuf = 4096; buf = malloc(lbuf); - assert(buf != NULL); + XXXAN(buf); nbuf = 0; while (1) { pfd[0].fd = heritage.fds[2]; @@ -79,7 +79,7 @@ CLI_Init(void) if ((nbuf + 2) >= lbuf) { lbuf += lbuf; buf = realloc(buf, lbuf); - assert(buf != NULL); + XXXAN(buf); } i = read(heritage.fds[2], buf + nbuf, lbuf - nbuf); if (i <= 0) { diff --git a/varnish-cache/bin/varnishd/cache_expire.c b/varnish-cache/bin/varnishd/cache_expire.c index f65a68e0..33f0a5e6 100644 --- a/varnish-cache/bin/varnishd/cache_expire.c +++ b/varnish-cache/bin/varnishd/cache_expire.c @@ -110,7 +110,7 @@ exp_prefetch(void *arg) (void)arg; sp = SES_New(NULL, 0); - assert(sp != NULL); + XXXAN(sp); while (1) { t = time(NULL); LOCK(&exp_mtx); @@ -179,7 +179,7 @@ EXP_Init(void) AZ(pthread_mutex_init(&exp_mtx, NULL)); exp_heap = binheap_new(NULL, object_cmp, object_update); - assert(exp_heap != NULL); + XXXAN(exp_heap); AZ(pthread_create(&exp_thread, NULL, exp_prefetch, NULL)); AZ(pthread_create(&exp_thread, NULL, exp_hangman, NULL)); } diff --git a/varnish-cache/bin/varnishd/cache_fetch.c b/varnish-cache/bin/varnishd/cache_fetch.c index cf7525b7..08a5fa63 100644 --- a/varnish-cache/bin/varnishd/cache_fetch.c +++ b/varnish-cache/bin/varnishd/cache_fetch.c @@ -40,7 +40,7 @@ fetch_straight(const struct sess *sp, int fd, struct http *hp, char *b) cl = strtoumax(b, NULL, 0); st = stevedore->alloc(stevedore, cl); - assert(st->stevedore != NULL); + XXXAN(st->stevedore); TAILQ_INSERT_TAIL(&sp->obj->store, st, list); st->len = cl; sp->obj->len = cl; @@ -52,7 +52,7 @@ fetch_straight(const struct sess *sp, int fd, struct http *hp, char *b) while (cl > 0) { i = http_Read(hp, fd, p, cl); - assert(i > 0); /* XXX seen */ + xxxassert(i > 0); /* XXX seen */ p += i; cl -= i; } @@ -82,18 +82,18 @@ fetch_chunked(const struct sess *sp, int fd, struct http *hp) st = NULL; while (1) { i = http_Read(hp, fd, bp, be - bp); - assert(i >= 0); + xxxassert(i >= 0); bp += i; *bp = '\0'; u = strtoul(buf, &q, 16); if (q == NULL || q == buf) continue; - assert(isspace(*q)); + xxxassert(isspace(*q)); while (*q == '\t' || *q == ' ') q++; if (*q == '\r') q++; - assert(*q == '\n'); + xxxassert(*q == '\n'); q++; if (u == 0) break; @@ -105,7 +105,7 @@ fetch_chunked(const struct sess *sp, int fd, struct http *hp) } else { st = stevedore->alloc(stevedore, stevedore->trim == NULL ? u : CHUNK_PREALLOC); - assert(st->stevedore != NULL); + XXXAN(st->stevedore); TAILQ_INSERT_TAIL(&sp->obj->store, st, list); p = st->ptr; } @@ -114,9 +114,9 @@ fetch_chunked(const struct sess *sp, int fd, struct http *hp) v = u; i = bp - q; + assert(i >= 0); if (i == 0) { } else if (v > i) { - assert(i > 0); memcpy(p, q, i); p += i; st->len += i; @@ -141,7 +141,6 @@ fetch_chunked(const struct sess *sp, int fd, struct http *hp) continue; while (v > 0) { i = http_Read(hp, fd, p, v); - assert(i > 0); st->len += i; v -= i; u -= i; @@ -178,15 +177,15 @@ fetch_eof(const struct sess *sp, int fd, struct http *hp) while (1) { if (v == 0) { st = stevedore->alloc(stevedore, CHUNK_PREALLOC); - assert(st->stevedore != NULL); + XXXAN(st->stevedore); TAILQ_INSERT_TAIL(&sp->obj->store, st, list); p = st->ptr + st->len; v = st->space - st->len; } - assert(p != NULL); - assert(st != NULL); + AN(p); + AN(st); i = http_Read(hp, fd, p, v); - assert(i >= 0); + xxxassert(i >= 0); if (i == 0) break; p += i; @@ -286,7 +285,7 @@ FetchHeaders(struct sess *sp) vc = VBE_GetFd(sp->backend, sp->xid); if (vc == NULL) vc = VBE_GetFd(sp->backend, sp->xid); - assert(vc != NULL); /* XXX: handle this */ + XXXAN(vc); VSL(SLT_Backend, sp->fd, "%d %s", vc->fd, sp->backend->vcl_name); http_ClrHeader(vc->http); @@ -302,19 +301,19 @@ FetchHeaders(struct sess *sp) WRK_Reset(w, &vc->fd); http_Write(w, vc->http, 0); i = WRK_Flush(w); - assert(i == 0); + xxxassert(i == 0); CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); i = http_RecvHead(vc->http, vc->fd); - assert(i == 0); - assert(http_DissectResponse(vc->http, vc->fd) == 0); + xxxassert(i == 0); + xxxassert(http_DissectResponse(vc->http, vc->fd) == 0); CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); - assert(sp->vbc == NULL); + AZ(sp->vbc); sp->vbc = vc; sp->obj->entered = time(NULL); diff --git a/varnish-cache/bin/varnishd/cache_hash.c b/varnish-cache/bin/varnishd/cache_hash.c index 0a5ac84e..54010656 100644 --- a/varnish-cache/bin/varnishd/cache_hash.c +++ b/varnish-cache/bin/varnishd/cache_hash.c @@ -50,14 +50,14 @@ HSH_Lookup(struct sess *sp) CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(sp->http, HTTP_MAGIC); - assert(hash != NULL); + AN(hash); w = sp->wrk; h = sp->http; /* Precreate an objhead and object in case we need them */ if (w->nobjhead == NULL) { w->nobjhead = calloc(sizeof *w->nobjhead, 1); - assert(w->nobjhead != NULL); + XXXAN(w->nobjhead); w->nobjhead->magic = OBJHEAD_MAGIC; TAILQ_INIT(&w->nobjhead->objects); AZ(pthread_mutex_init(&w->nobjhead->mtx, NULL)); @@ -66,7 +66,7 @@ HSH_Lookup(struct sess *sp) CHECK_OBJ_NOTNULL(w->nobjhead, OBJHEAD_MAGIC); if (w->nobj == NULL) { w->nobj = calloc(sizeof *w->nobj, 1); - assert(w->nobj != NULL); + XXXAN(w->nobj); w->nobj->magic = OBJECT_MAGIC; w->nobj->http.magic = HTTP_MAGIC; w->nobj->busy = 1; @@ -139,7 +139,7 @@ HSH_Unbusy(struct object *o) { struct sess *sp; - assert(o != NULL); + CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); assert(o->busy); assert(o->refcnt > 0); if (o->cacheable) diff --git a/varnish-cache/bin/varnishd/cache_http.c b/varnish-cache/bin/varnishd/cache_http.c index 934ff5da..265e0f15 100644 --- a/varnish-cache/bin/varnishd/cache_http.c +++ b/varnish-cache/bin/varnishd/cache_http.c @@ -87,9 +87,9 @@ http_IsHdr(struct http_hdr *hh, char *hdr) { unsigned l; - assert(hh->b != NULL); - assert(hh->e != NULL); - assert(hdr != NULL); + AN(hh->b); + AN(hh->e); + AN(hdr); l = hdr[0]; assert(l == strlen(hdr + 1)); assert(hdr[l] == ':'); @@ -105,8 +105,8 @@ http_findhdr(struct http *hp, unsigned l, const char *hdr) unsigned u; for (u = HTTP_HDR_FIRST; u < hp->nhd; u++) { - assert(hp->hd[u].b != NULL); - assert(hp->hd[u].e != NULL); + AN(hp->hd[u].b); + AN(hp->hd[u].e); if (hp->hd[u].e < hp->hd[u].b + l + 1) continue; if (hp->hd[u].b[l] != ':') @@ -221,7 +221,7 @@ http_HdrIs(struct http *hp, const char *hdr, const char *val) if (!http_GetHdr(hp, hdr, &p)) return (0); - assert(p != NULL); + AN(p); if (!strcasecmp(p, val)) return (1); return (0); @@ -285,7 +285,7 @@ int http_GetStatus(struct http *hp) { - assert(hp->hd[HTTP_HDR_STATUS].b != NULL); + AN(hp->hd[HTTP_HDR_STATUS].b); return (strtoul(hp->hd[HTTP_HDR_STATUS].b, NULL /* XXX */, 10)); } @@ -346,7 +346,8 @@ http_DissectRequest(struct http *hp, int fd) { char *p; - assert(hp->t != NULL); + CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC); + AN(hp->t); assert(hp->s < hp->t); assert(hp->t <= hp->v); hp->logtag = HTTP_Rx; @@ -412,7 +413,8 @@ http_DissectResponse(struct http *hp, int fd) { char *p, *q; - assert(hp->t != NULL); + CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC); + AN(hp->t); assert(hp->s < hp->t); assert(hp->t <= hp->v); hp->logtag = HTTP_Rx; @@ -462,6 +464,7 @@ http_header_complete(struct http *hp) { char *p; + CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC); assert(hp->v <= hp->e); assert(*hp->v == '\0'); /* Skip any leading white space */ @@ -595,17 +598,17 @@ http_CopyHttp(struct http *to, struct http *fm) for (u = 0; u < fm->nhd; u++) { if (fm->hd[u].b == NULL) continue; - assert(fm->hd[u].e != NULL); + AN(fm->hd[u].e); l += (fm->hd[u].e - fm->hd[u].b) + 1; } to->s = malloc(l); - assert(to->s != NULL); + XXXAN(to->s); to->e = to->s + l; to->f = to->s; for (u = 0; u < fm->nhd; u++) { if (fm->hd[u].b == NULL) continue; - assert(fm->hd[u].e != NULL); + AN(fm->hd[u].e); assert(*fm->hd[u].e == '\0'); l = fm->hd[u].e - fm->hd[u].b; assert(l == strlen(fm->hd[u].b)); @@ -623,8 +626,9 @@ http_CopyHttp(struct http *to, struct http *fm) static void http_seth(int fd, struct http *to, unsigned n, enum httptag tag, const char *fm) { + assert(n < HTTP_HDR_MAX); - assert(fm != NULL); + AN(fm); to->hd[n].b = (void*)(uintptr_t)fm; to->hd[n].e = (void*)(uintptr_t)strchr(fm, '\0'); to->hdf[n] = 0; @@ -636,7 +640,7 @@ http_copyh(int fd, struct http *to, struct http *fm, unsigned n, enum httptag ta { assert(n < HTTP_HDR_MAX); - assert(fm->hd[n].b != NULL); + AN(fm->hd[n].b); to->hd[n].b = fm->hd[n].b; to->hd[n].e = fm->hd[n].e; to->hdf[n] = fm->hdf[n]; @@ -693,7 +697,7 @@ http_copyheader(int fd, struct http *to, struct http *fm, unsigned n) CHECK_OBJ_NOTNULL(fm, HTTP_MAGIC); CHECK_OBJ_NOTNULL(to, HTTP_MAGIC); assert(n < HTTP_HDR_MAX); - assert(fm->hd[n].b != NULL); + AN(fm->hd[n].b); if (to->nhd < HTTP_HDR_MAX) { to->hd[to->nhd].b = fm->hd[n].b; to->hd[to->nhd].e = fm->hd[n].e; @@ -788,19 +792,19 @@ http_Write(struct worker *w, struct http *hp, int resp) unsigned u, l; if (resp) { - assert(hp->hd[HTTP_HDR_STATUS].b != NULL); + AN(hp->hd[HTTP_HDR_STATUS].b); l = WRK_WriteH(w, &hp->hd[HTTP_HDR_PROTO], " "); l += WRK_WriteH(w, &hp->hd[HTTP_HDR_STATUS], " "); l += WRK_WriteH(w, &hp->hd[HTTP_HDR_RESPONSE], "\r\n"); } else { - assert(hp->hd[HTTP_HDR_URL].b != NULL); + AN(hp->hd[HTTP_HDR_URL].b); l = WRK_WriteH(w, &hp->hd[HTTP_HDR_REQ], " "); l += WRK_WriteH(w, &hp->hd[HTTP_HDR_URL], " "); l += WRK_WriteH(w, &hp->hd[HTTP_HDR_PROTO], "\r\n"); } for (u = HTTP_HDR_FIRST; u < hp->nhd; u++) { - assert(hp->hd[u].b != NULL); - assert(hp->hd[u].e != NULL); + AN(hp->hd[u].b); + AN(hp->hd[u].e); l += WRK_WriteH(w, &hp->hd[u], "\r\n"); } l += WRK_Write(w, "\r\n", -1); diff --git a/varnish-cache/bin/varnishd/cache_pass.c b/varnish-cache/bin/varnishd/cache_pass.c index ead16da0..c116cfb2 100644 --- a/varnish-cache/bin/varnishd/cache_pass.c +++ b/varnish-cache/bin/varnishd/cache_pass.c @@ -49,7 +49,6 @@ pass_straight(struct sess *sp, int fd, struct http *hp, char *bi) vca_close_session(sp, "backend closed"); return (1); } - assert(i > 0); sp->wrk->acct.bodybytes += WRK_Write(sp->wrk, buf, i); if (WRK_Flush(sp->wrk)) vca_close_session(sp, "remote closed"); @@ -79,7 +78,7 @@ pass_chunked(struct sess *sp, int fd, struct http *hp) p = buf; while (1) { i = http_Read(hp, fd, bp, be - bp); - assert(i >= 0); + xxxassert(i >= 0); if (i == 0 && p == bp) break; bp += i; @@ -131,7 +130,7 @@ pass_chunked(struct sess *sp, int fd, struct http *hp) if (j > be - bp) j = be - bp; i = http_Read(hp, fd, bp, j); - assert(i > 0); + xxxassert(i > 0); bp += i; } } @@ -150,8 +149,9 @@ PassBody(struct sess *sp) char *b; int cls; + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(sp->vbc, VBE_CONN_MAGIC); vc = sp->vbc; - assert(vc != NULL); sp->vbc = NULL; clock_gettime(CLOCK_REALTIME, &sp->t_resp); @@ -207,7 +207,6 @@ PassSession(struct sess *sp) RES_Error(sp, 503, "Backend did not respond."); return (1); } - assert(vc != NULL); VSL(SLT_Backend, sp->fd, "%d %s", vc->fd, sp->backend->vcl_name); http_CopyReq(vc->fd, vc->http, sp->http); @@ -216,12 +215,12 @@ PassSession(struct sess *sp) WRK_Reset(w, &vc->fd); http_Write(w, vc->http, 0); i = WRK_Flush(w); - assert(i == 0); + xxxassert(i == 0); /* XXX: copy any contents */ i = http_RecvHead(vc->http, vc->fd); - assert(i == 0); + xxxassert(i == 0); http_DissectResponse(vc->http, vc->fd); assert(sp->vbc == NULL); diff --git a/varnish-cache/bin/varnishd/cache_pipe.c b/varnish-cache/bin/varnishd/cache_pipe.c index 99749a7f..40839934 100644 --- a/varnish-cache/bin/varnishd/cache_pipe.c +++ b/varnish-cache/bin/varnishd/cache_pipe.c @@ -58,7 +58,6 @@ PipeSession(struct sess *sp) RES_Error(sp, 503, "Backend did not respond."); return; } - assert(vc != NULL); VSL(SLT_Backend, sp->fd, "%d %s", vc->fd, sp->backend->vcl_name); vc->http->logtag = HTTP_Tx; diff --git a/varnish-cache/bin/varnishd/cache_pool.c b/varnish-cache/bin/varnishd/cache_pool.c index 23442280..bfc2ed6d 100644 --- a/varnish-cache/bin/varnishd/cache_pool.c +++ b/varnish-cache/bin/varnishd/cache_pool.c @@ -69,10 +69,10 @@ WRK_WriteH(struct worker *w, struct http_hdr *hh, const char *suf) unsigned u; CHECK_OBJ_NOTNULL(w, WORKER_MAGIC); - assert(w != NULL); - assert(hh != NULL); - assert(hh->b != NULL); - assert(hh->e != NULL); + AN(w); + AN(hh); + AN(hh->b); + AN(hh->e); u = WRK_Write(w, hh->b, hh->e - hh->b); if (suf != NULL) u += WRK_Write(w, suf, -1); @@ -128,7 +128,7 @@ wrk_do_one(struct worker *w) struct workreq *wrq; wrq = TAILQ_FIRST(&wrk_reqhead); - assert(wrq != NULL); + AN(wrq); VSL_stats->n_wrk_busy++; TAILQ_REMOVE(&wrk_reqhead, wrq, list); VSL_stats->n_wrk_queue--; diff --git a/varnish-cache/bin/varnishd/cache_response.c b/varnish-cache/bin/varnishd/cache_response.c index 73a70fec..8d4f8032 100644 --- a/varnish-cache/bin/varnishd/cache_response.c +++ b/varnish-cache/bin/varnishd/cache_response.c @@ -82,7 +82,7 @@ RES_Error(struct sess *sp, int code, const char *expl) } sb = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND); - assert(sb != NULL); + XXXAN(sb); assert(code >= 100 && code <= 999); if (msg == NULL) { @@ -226,7 +226,7 @@ RES_WriteObj(struct sess *sp) TAILQ_FOREACH(st, &sp->obj->store, list) { CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC); - assert(st->stevedore != NULL); + AN(st->stevedore); u += st->len; sp->wrk->acct.bodybytes += st->len; #ifdef HAVE_SENDFILE diff --git a/varnish-cache/bin/varnishd/cache_session.c b/varnish-cache/bin/varnishd/cache_session.c index f68a9e97..d663ad28 100644 --- a/varnish-cache/bin/varnishd/cache_session.c +++ b/varnish-cache/bin/varnishd/cache_session.c @@ -72,7 +72,7 @@ SES_RefSrcAddr(struct sess *sp) struct srcaddrhead *ch; time_t now; - assert(sp->srcaddr == NULL); + AZ(sp->srcaddr); for (u = 0, p = sp->addr; *p; p++) u += u + *p; v = u % CLIENT_HASH; @@ -110,12 +110,12 @@ SES_RefSrcAddr(struct sess *sp) } if (c3 == NULL) { c3 = malloc(sizeof *c3); - assert(c3 != NULL); + XXXAN(c3); if (c3 != NULL) VSL_stats->n_srcaddr++; } else TAILQ_REMOVE(ch, c3, list); - assert (c3 != NULL); + AN(c3); if (c3 != NULL) { memset(c3, 0, sizeof *c3); strcpy(c3->addr, sp->addr); @@ -177,7 +177,7 @@ ses_relsrcaddr(struct sess *sp) /* If we never get to work pool (illegal req) */ return; } - assert(sp->srcaddr != NULL); + AN(sp->srcaddr); LOCK(&ses_mtx); assert(sp->srcaddr->nref > 0); sp->srcaddr->nref--; @@ -236,7 +236,7 @@ SES_New(struct sockaddr *addr, unsigned len) sm->sess.http = &sm->http; sm->sess.sockaddr = sm->sockaddr; - assert(len < sizeof(sm->sockaddr)); + assert(len < sizeof(sm->sockaddr)); if (addr != NULL) { memcpy(sm->sess.sockaddr, addr, len); sm->sess.sockaddrlen = len; @@ -259,8 +259,8 @@ SES_Delete(struct sess *sp) sm = sp->mem; CHECK_OBJ_NOTNULL(sm, SESSMEM_MAGIC); - assert(sp->obj == NULL); - assert(sp->vcl == NULL); + AZ(sp->obj); + AZ(sp->vcl); VSL_stats->n_sess--; ses_relsrcaddr(sp); VSL(SLT_StatSess, sp->id, "%s %s %d %ju %ju %ju %ju %ju %ju %ju", diff --git a/varnish-cache/bin/varnishd/cache_vcl.c b/varnish-cache/bin/varnishd/cache_vcl.c index f9c11db6..377ed4d9 100644 --- a/varnish-cache/bin/varnishd/cache_vcl.c +++ b/varnish-cache/bin/varnishd/cache_vcl.c @@ -47,9 +47,9 @@ VCL_Get(void) struct VCL_conf *vc; LOCK(&vcl_mtx); - assert(vcl_active != NULL); + AN(vcl_active); vc = vcl_active->conf; - assert(vc != NULL); + AN(vc); vc->busy++; UNLOCK(&vcl_mtx); return (vc); @@ -106,7 +106,7 @@ VCL_Load(const char *fn, const char *name, struct cli *cli) } vcl = calloc(sizeof *vcl, 1); - assert(vcl != NULL); + XXXAN(vcl); vcl->dlh = dlopen(fn, RTLD_NOW | RTLD_LOCAL); @@ -140,7 +140,7 @@ VCL_Load(const char *fn, const char *name, struct cli *cli) } vcl->conf->priv = vcl; vcl->name = strdup(name); - assert(vcl->name != NULL); + XXXAN(vcl->name); TAILQ_INSERT_TAIL(&vcl_head, vcl, list); LOCK(&vcl_mtx); if (vcl_active == NULL) diff --git a/varnish-cache/bin/varnishd/cache_vrt.c b/varnish-cache/bin/varnishd/cache_vrt.c index 14e089c0..6933e752 100644 --- a/varnish-cache/bin/varnishd/cache_vrt.c +++ b/varnish-cache/bin/varnishd/cache_vrt.c @@ -47,8 +47,7 @@ VRT_GetHdr(struct sess *sp, const char *n) char *p; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - assert(sp != NULL); - assert(sp->http != NULL); + AN(sp->http); if (!http_GetHdr(sp->http, n, &p)) return (NULL); return (p); @@ -80,10 +79,10 @@ VRT_alloc_backends(struct VCL_conf *cp) int i; cp->backend = calloc(sizeof *cp->backend, cp->nbackend); - assert(cp->backend != NULL); + XXXAN(cp->backend); for (i = 0; i < cp->nbackend; i++) { cp->backend[i] = calloc(sizeof *cp->backend[i], 1); - assert(cp->backend[i] != NULL); + XXXAN(cp->backend[i]); cp->backend[i]->magic = BACKEND_MAGIC; TAILQ_INIT(&cp->backend[i]->connlist); } diff --git a/varnish-cache/bin/varnishd/cache_vrt_acl.c b/varnish-cache/bin/varnishd/cache_vrt_acl.c index 18160ab4..51bd3c86 100644 --- a/varnish-cache/bin/varnishd/cache_vrt_acl.c +++ b/varnish-cache/bin/varnishd/cache_vrt_acl.c @@ -34,7 +34,7 @@ static int vrt_acl_vsl(struct sess *sp, const char *acl, struct vrt_acl *ap, int r) { - assert(ap != NULL); + AN(ap); if (ap->name == NULL) { assert(r == 0); VSL(SLT_VCL_acl, sp->fd, "NO_MATCH %s", acl); diff --git a/varnish-cache/bin/varnishd/cache_vrt_re.c b/varnish-cache/bin/varnishd/cache_vrt_re.c index 9c99700d..f6622127 100644 --- a/varnish-cache/bin/varnishd/cache_vrt_re.c +++ b/varnish-cache/bin/varnishd/cache_vrt_re.c @@ -20,12 +20,11 @@ void VRT_re_init(void **rep, const char *re) { regex_t *t; - int i; t = calloc(sizeof *t, 1); - assert(t != NULL); - i = regcomp(t, re, REG_EXTENDED | REG_NOSUB); - assert(i == 0); + XXXAN(t); + /* This was already check-compiled by the VCL compiler */ + AZ(regcomp(t, re, REG_EXTENDED | REG_NOSUB)); *rep = t; } @@ -45,7 +44,7 @@ VRT_re_match(const char *s, void *re) if (s == NULL) return (0); - assert(re != NULL); + AN(re); t = re; i = regexec(t, s, 0, NULL, 0); if (i == 0) diff --git a/varnish-cache/bin/varnishd/flint.lnt b/varnish-cache/bin/varnishd/flint.lnt index 90867c4b..6c5f2b8a 100644 --- a/varnish-cache/bin/varnishd/flint.lnt +++ b/varnish-cache/bin/varnishd/flint.lnt @@ -8,6 +8,7 @@ -sem(strchr, 1p, type(1), 2n == 0 ? (@p < 1p) : (@p < 1p || @p == 0 )) -sem(lbv_assert, r_no) +-sem(lbv_xxxassert, r_no) -ffc // No automatic custody diff --git a/varnish-cache/bin/varnishd/hash_classic.c b/varnish-cache/bin/varnishd/hash_classic.c index f0eca583..fff108d7 100644 --- a/varnish-cache/bin/varnishd/hash_classic.c +++ b/varnish-cache/bin/varnishd/hash_classic.c @@ -142,7 +142,7 @@ hcl_start(void) unsigned u; hcl_head = calloc(sizeof *hcl_head, hcl_nhash); - assert(hcl_head != NULL); + XXXAN(hcl_head); for (u = 0; u < hcl_nhash; u++) { TAILQ_INIT(&hcl_head[u].head); @@ -220,7 +220,7 @@ hcl_lookup(const char *key1, const char *key2, struct objhead *noh) i = sizeof *he2 + kl; he2 = calloc(i, 1); - assert(he2 != NULL); + XXXAN(he2); he2->magic = HCL_ENTRY_MAGIC; he2->oh = noh; he2->digest = digest; diff --git a/varnish-cache/bin/varnishd/hash_simple_list.c b/varnish-cache/bin/varnishd/hash_simple_list.c index 69f3a241..b5a7e550 100644 --- a/varnish-cache/bin/varnishd/hash_simple_list.c +++ b/varnish-cache/bin/varnishd/hash_simple_list.c @@ -71,13 +71,13 @@ hsl_lookup(const char *key1, const char *key2, struct objhead *nobj) return (NULL); } he2 = calloc(sizeof *he2, 1); - assert(he2 != NULL); + XXXAN(he2); he2->obj = nobj; he2->refcnt = 1; he2->key1 = strdup(key1); - assert(he2->key1 != NULL); + XXXAN(he2->key1); he2->key2 = strdup(key2); - assert(he2->key2 != NULL); + XXXAN(he2->key2); nobj->hashpriv = he2; if (he != NULL) TAILQ_INSERT_BEFORE(he, he2, list); @@ -97,7 +97,7 @@ hsl_deref(struct objhead *obj) struct hsl_entry *he; int ret; - assert(obj->hashpriv != NULL); + AN(obj->hashpriv); he = obj->hashpriv; LOCK(&hsl_mutex); if (--he->refcnt == 0) { diff --git a/varnish-cache/bin/varnishd/mgt_child.c b/varnish-cache/bin/varnishd/mgt_child.c index 84a39de0..1bf7113d 100644 --- a/varnish-cache/bin/varnishd/mgt_child.c +++ b/varnish-cache/bin/varnishd/mgt_child.c @@ -114,7 +114,7 @@ start_child(void) /* Redirect stdin/out/err */ AZ(close(0)); i = open("/dev/null", O_RDONLY); - assert(i == 0); + xxxassert(i == 0); assert(dup2(child_fds[1], 1) == 1); assert(dup2(child_fds[1], 2) == 2); AZ(close(child_fds[0])); @@ -137,9 +137,9 @@ start_child(void) AZ(close(child_fds[1])); child_fds[1] = -1; - assert(ev_listen == NULL); + AZ(ev_listen); e = ev_new(); - assert(e != NULL); + XXXAN(e); e->fd = child_fds[0]; e->fd_flags = EV_RD; e->name = "Child listener"; @@ -147,9 +147,9 @@ start_child(void) AZ(ev_add(mgt_evb, e)); ev_listen = e; - assert(ev_poker == NULL); + AZ(ev_poker); e = ev_new(); - assert(e != NULL); + XXXAN(e); e->timeout = 3.0; e->callback = child_poker; e->name = "child poker"; @@ -287,7 +287,7 @@ mgt_run(int dflag, const char *T_arg) mgt_pid = getpid(); mgt_evb = ev_new_base(); - assert(mgt_evb != NULL); + XXXAN(mgt_evb); if (dflag) mgt_cli_setup(0, 1, 1); @@ -296,21 +296,21 @@ mgt_run(int dflag, const char *T_arg) mgt_cli_telnet(T_arg); e = ev_new(); - assert(e != NULL); + XXXAN(e); e->sig = SIGTERM; e->callback = mgt_sigint; e->name = "mgt_sigterm"; AZ(ev_add(mgt_evb, e)); e = ev_new(); - assert(e != NULL); + XXXAN(e); e->sig = SIGINT; e->callback = mgt_sigint; e->name = "mgt_sigint"; AZ(ev_add(mgt_evb, e)); e = ev_new(); - assert(e != NULL); + XXXAN(e); e->sig = SIGCHLD; e->sig_flags = SA_NOCLDSTOP; e->callback = mgt_sigchld; diff --git a/varnish-cache/bin/varnishd/mgt_cli.c b/varnish-cache/bin/varnishd/mgt_cli.c index 51da8fef..823abe4a 100644 --- a/varnish-cache/bin/varnishd/mgt_cli.c +++ b/varnish-cache/bin/varnishd/mgt_cli.c @@ -40,7 +40,7 @@ mcf_stats(struct cli *cli, char **av, void *priv) (void)av; (void)priv; - assert (VSL_stats != NULL); + AN(VSL_stats); #define MAC_STAT(n,t,f,d) \ cli_out(cli, "%12ju " d "\n", (VSL_stats->n)); #include "stat_field.h" @@ -72,7 +72,7 @@ mcf_passthru(struct cli *cli, char **av, void *priv) for (u = 1; av[u] != NULL; u++) v += strlen(av[u]) + 3; p = malloc(v); - assert(p != NULL); + XXXAN(p); q = p; for (u = 1; av[u] != NULL; u++) { *q++ = '"'; @@ -90,7 +90,7 @@ mcf_passthru(struct cli *cli, char **av, void *priv) *q++ = '\n'; v = q - p; i = write(cli_o, p, v); - assert(i == v); + xxxassert(i == v); free(p); i = cli_readres(cli_i, &u, &p, 3.0); @@ -149,7 +149,7 @@ mgt_cli_init(void) for (cp = CLI_cmds; cp->request != NULL; cp++) u++; cli_proto = calloc(sizeof *cli_proto, u + 1); - assert(cli_proto != NULL); + XXXAN(cli_proto); u = 0; for (cp = mgt_cli_proto; cp->request != NULL; cp++) cli_proto[u++] = *cp; @@ -268,7 +268,7 @@ mgt_cli_callback(struct ev *e, int what) if (cp->nbuf == cp->lbuf) { cp->lbuf += cp->lbuf; cp->buf = realloc(cp->buf, cp->lbuf); - assert(cp->buf != NULL); + XXXAN(cp->buf); } i = read(cp->fdi, cp->buf + cp->nbuf, cp->lbuf - cp->nbuf); if (i <= 0) @@ -313,7 +313,7 @@ mgt_cli_setup(int fdi, int fdo, int verbose) struct cli_port *cp; cp = calloc(sizeof *cp, 1); - assert(cp != NULL); + XXXAN(cp); sprintf(cp->name, "cli %d->%d", fdi, fdo); cp->magic = CLI_PORT_MAGIC; @@ -324,10 +324,10 @@ mgt_cli_setup(int fdi, int fdo, int verbose) cp->lbuf = 4096; cp->buf = malloc(cp->lbuf); - assert(cp->buf != NULL); + XXXAN(cp->buf); cp->cli->sb = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND); - assert(cp->cli->sb != NULL); + XXXAN(cp->cli->sb); cp->ev = calloc(sizeof *cp->ev, 1); cp->ev->name = cp->name; @@ -370,7 +370,7 @@ mgt_cli_telnet(const char *T_arg) exit (2); } telnet_ev = ev_new(); - assert(telnet_ev != NULL); + XXXAN(telnet_ev); telnet_ev->fd = telnet_sock; telnet_ev->fd_flags = POLLIN; telnet_ev->callback = telnet_accept; diff --git a/varnish-cache/bin/varnishd/mgt_param.c b/varnish-cache/bin/varnishd/mgt_param.c index b358a821..cb8de783 100644 --- a/varnish-cache/bin/varnishd/mgt_param.c +++ b/varnish-cache/bin/varnishd/mgt_param.c @@ -292,12 +292,11 @@ mcf_param_show(struct cli *cli, char **av, void *priv) q = strchr(p, '\n'); if (q == NULL) q = strchr(p, '\0'); - assert(q != NULL); if (q > p + 52) { q = p + 52; while (q > p && *q != ' ') q--; - assert(q != NULL); + AN(q); } cli_out(cli, "%20s %.*s\n", "", q - p, p); p = q; diff --git a/varnish-cache/bin/varnishd/mgt_vcc.c b/varnish-cache/bin/varnishd/mgt_vcc.c index 69999cd8..44c6bade 100644 --- a/varnish-cache/bin/varnishd/mgt_vcc.c +++ b/varnish-cache/bin/varnishd/mgt_vcc.c @@ -83,7 +83,7 @@ mgt_vcc_add(const char *name, char *file) struct vclprog *vp; vp = calloc(sizeof *vp, 1); - assert(vp != NULL); + XXXAN(vp); vp->name = strdup(name); vp->fname = file; TAILQ_INSERT_TAIL(&vclhead, vp, list); @@ -95,7 +95,7 @@ mgt_vcc_del(struct vclprog *vp) { TAILQ_REMOVE(&vclhead, vp, list); printf("unlink %s\n", vp->fname); - AZ(unlink(vp->fname)); /* XXX assert for now */ + XXXAZ(unlink(vp->fname)); free(vp->fname); free(vp->name); free(vp); @@ -126,7 +126,7 @@ mgt_vcc_default(const char *b_arg, const char *f_arg) struct vclprog *vp; sb = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND); - assert(sb != NULL); + XXXAN(sb); if (b_arg != NULL) { /* * XXX: should do a "HEAD /" on the -b argument to see that @@ -149,7 +149,7 @@ mgt_vcc_default(const char *b_arg, const char *f_arg) "}\n", addr, port ? port : "http"); free(addr); free(port); - assert(buf != NULL); + AN(buf); vf = VCC_Compile(sb, buf, NULL); free(buf); } else { @@ -231,7 +231,7 @@ mcf_config_inline(struct cli *cli, char **av, void *priv) (void)priv; sb = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND); - assert(sb != NULL); + XXXAN(sb); vf = VCC_Compile(sb, av[3], NULL); vsb_finish(sb); if (vsb_len(sb) > 0) { @@ -262,7 +262,7 @@ mcf_config_load(struct cli *cli, char **av, void *priv) (void)priv; sb = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND); - assert(sb != NULL); + XXXAN(sb); vf = VCC_CompileFile(sb, av[3]); vsb_finish(sb); if (vsb_len(sb) > 0) { diff --git a/varnish-cache/bin/varnishd/shmlog.c b/varnish-cache/bin/varnishd/shmlog.c index be69874c..2f1fe650 100644 --- a/varnish-cache/bin/varnishd/shmlog.c +++ b/varnish-cache/bin/varnishd/shmlog.c @@ -52,7 +52,6 @@ VSLR(enum shmlogtag tag, unsigned id, const char *b, const char *e) assert(b != NULL); if (e == NULL) e = strchr(b, '\0'); - assert(e != NULL); /* Truncate */ l = e - b; @@ -185,7 +184,7 @@ vsl_buildnew(const char *fn, unsigned size) slh.ptr = 0; slh.start = sizeof slh + sizeof *params; i = write(heritage.vsl_fd, &slh, sizeof slh); - assert(i == sizeof slh); + xxxassert(i == sizeof slh); heritage.vsl_size = slh.start + size; AZ(ftruncate(heritage.vsl_fd, (off_t)heritage.vsl_size)); } @@ -210,7 +209,7 @@ VSL_MgtInit(const char *fn, unsigned size) PROT_READ|PROT_WRITE, MAP_HASSEMAPHORE | MAP_NOSYNC | MAP_SHARED, heritage.vsl_fd, 0); - assert(loghead != MAP_FAILED); + xxxassert(loghead != MAP_FAILED); VSL_stats = &loghead->stats; pp = (void *)(loghead + 1); memcpy(pp, params, sizeof *pp); diff --git a/varnish-cache/bin/varnishd/storage_file.c b/varnish-cache/bin/varnishd/storage_file.c index 0db5ced8..0ae215ce 100644 --- a/varnish-cache/bin/varnishd/storage_file.c +++ b/varnish-cache/bin/varnishd/storage_file.c @@ -92,7 +92,7 @@ smf_calcsize(struct smf_sc *sc, const char *size, int newfile) if (bs < fsst.f_bsize) bs = fsst.f_bsize; - assert(S_ISREG(st.st_mode)); + xxxassert(S_ISREG(st.st_mode)); i = sscanf(size, "%ju%1s", &l, suff); /* can return -1, 0, 1 or 2 */ @@ -202,7 +202,7 @@ smf_init(struct stevedore *parent, const char *spec) struct smf_sc *sc; sc = calloc(sizeof *sc, 1); - assert(sc != NULL); + XXXAN(sc); TAILQ_INIT(&sc->order); TAILQ_INIT(&sc->free); TAILQ_INIT(&sc->used); @@ -218,9 +218,9 @@ smf_init(struct stevedore *parent, const char *spec) asprintf(&p, "%s,", spec); else p = strdup(spec); - assert(p != NULL); + XXXAN(p); size = strchr(p, ','); - assert(size != NULL); + XXXAN(size); *size++ = '\0'; @@ -269,7 +269,7 @@ smf_init(struct stevedore *parent, const char *spec) } asprintf(&q, "%s/varnish.XXXXXX", p); - assert(q != NULL); + XXXAN(q); sc->fd = mkstemp(q); if (sc->fd < 0) { fprintf(stderr, @@ -279,7 +279,7 @@ smf_init(struct stevedore *parent, const char *spec) } AZ(unlink(q)); asprintf(&sc->filename, "%s (unlinked)", q); - assert(sc->filename != NULL); + XXXAN(sc->filename); free(q); smf_initfile(sc, size, 1); } @@ -310,7 +310,7 @@ alloc_smf(struct smf_sc *sc, size_t bytes) /* Split from front */ sp2 = malloc(sizeof *sp2); - assert(sp2 != NULL); + XXXAN(sp2); VSL_stats->n_smf++; *sp2 = *sp; @@ -390,7 +390,7 @@ trim_smf(struct smf *sp, size_t bytes) assert(bytes > 0); CHECK_OBJ_NOTNULL(sp, SMF_MAGIC); sp2 = malloc(sizeof *sp2); - assert(sp2 != NULL); + XXXAN(sp2); VSL_stats->n_smf++; *sp2 = *sp; @@ -413,7 +413,7 @@ new_smf(struct smf_sc *sc, unsigned char *ptr, off_t off, size_t len) struct smf *sp, *sp2; sp = calloc(sizeof *sp, 1); - assert(sp != NULL); + XXXAN(sp); sp->magic = SMF_MAGIC; sp->s.magic = STORAGE_MAGIC; VSL_stats->n_smf++; @@ -515,7 +515,7 @@ smf_alloc(struct stevedore *st, size_t size) smf = alloc_smf(sc, size); CHECK_OBJ_NOTNULL(smf, SMF_MAGIC); UNLOCK(&sc->mtx); - assert(smf != NULL); + XXXAN(smf); assert(smf->size == size); smf->s.space = size; smf->s.priv = smf; @@ -542,7 +542,7 @@ smf_trim(struct storage *s, size_t size) return; } assert(size <= s->space); - assert(size > 0); /* XXX: seen */ + xxxassert(size > 0); /* XXX: seen */ CAST_OBJ_NOTNULL(smf, s->priv, SMF_MAGIC); assert(size <= smf->size); sc = smf->sc; diff --git a/varnish-cache/bin/varnishd/storage_malloc.c b/varnish-cache/bin/varnishd/storage_malloc.c index e97a5977..1d18d6fa 100644 --- a/varnish-cache/bin/varnishd/storage_malloc.c +++ b/varnish-cache/bin/varnishd/storage_malloc.c @@ -18,10 +18,10 @@ sma_alloc(struct stevedore *st, size_t size) struct sma *sma; sma = calloc(sizeof *sma, 1); - assert(sma != NULL); + XXXAN(sma); sma->s.priv = sma; sma->s.ptr = malloc(size); - assert(sma->s.ptr != NULL); + XXXAN(sma->s.ptr); sma->s.len = 0; sma->s.space = size; sma->s.fd = -1; diff --git a/varnish-cache/bin/varnishd/varnishd.c b/varnish-cache/bin/varnishd/varnishd.c index 9183a284..79d422a1 100644 --- a/varnish-cache/bin/varnishd/varnishd.c +++ b/varnish-cache/bin/varnishd/varnishd.c @@ -57,8 +57,8 @@ setup_hash(const char *s_arg) q = p = strchr(s_arg, '\0'); else q = p + 1; - assert(p != NULL); - assert(q != NULL); + xxxassert(p != NULL); + xxxassert(q != NULL); if (!cmp_hash(&hcl_slinger, s_arg, p)) { hp = &hcl_slinger; } else if (!cmp_hash(&hsl_slinger, s_arg, p)) { @@ -102,8 +102,8 @@ setup_storage(const char *s_arg) q = p = strchr(s_arg, '\0'); else q = p + 1; - assert(p != NULL); - assert(q != NULL); + xxxassert(p != NULL); + xxxassert(q != NULL); if (!cmp_storage(&sma_stevedore, s_arg, p)) { stp = &sma_stevedore; } else if (!cmp_storage(&smf_stevedore, s_arg, p)) { @@ -267,12 +267,12 @@ DebugStunt(void) i = read(pipes[1][0], buf, sizeof buf - 1); buf[i] = '\0'; d_child = strtoul(buf, &p, 0); - assert(p != NULL); + xxxassert(p != NULL); printf("New Pid %d\n", d_child); - assert(d_child != 0); + xxxassert(d_child != 0); i = strlen(p); j = write(pipes[1][1], p, i); - assert(j == i); + xxxassert(j == i); while (1) { if (pfd[0].fd == -1 && pfd[1].fd == -1)