From d922dc1f30ecbde1e2b0f155c48af5365c4201d7 Mon Sep 17 00:00:00 2001 From: phk Date: Tue, 25 Sep 2007 07:30:38 +0000 Subject: [PATCH] Assert return values of system{calls,functions} git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2025 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/cache_backend.c | 2 +- .../bin/varnishd/cache_backend_simple.c | 4 ++-- varnish-cache/bin/varnishd/cache_expire.c | 2 +- varnish-cache/bin/varnishd/cache_pipe.c | 8 ++++---- varnish-cache/bin/varnishd/mgt_cli.c | 10 +++++----- varnish-cache/bin/varnishd/mgt_vcc.c | 19 ++++++++++--------- 6 files changed, 23 insertions(+), 22 deletions(-) diff --git a/varnish-cache/bin/varnishd/cache_backend.c b/varnish-cache/bin/varnishd/cache_backend.c index 141fd052..48572df8 100644 --- a/varnish-cache/bin/varnishd/cache_backend.c +++ b/varnish-cache/bin/varnishd/cache_backend.c @@ -92,7 +92,7 @@ VBE_TryConnect(const struct sess *sp, const struct addrinfo *ai) } if (connect(s, (void *)&ss, alen) != 0) { - close(s); + AZ(close(s)); LOCK(&sp->backend->mtx); return (-1); } diff --git a/varnish-cache/bin/varnishd/cache_backend_simple.c b/varnish-cache/bin/varnishd/cache_backend_simple.c index 282713e4..2eb2ed92 100644 --- a/varnish-cache/bin/varnishd/cache_backend_simple.c +++ b/varnish-cache/bin/varnishd/cache_backend_simple.c @@ -257,7 +257,7 @@ bes_GetFd(struct sess *sp) for (n = 1; n < 5; n++) { vc = bes_nextfd(sp); if (vc == NULL) { - usleep(100000 * n); + AZ(usleep(100000 * n)); continue; } assert(vc->fd >= 0); @@ -325,7 +325,7 @@ bes_Cleanup(struct backend *b) break; TAILQ_REMOVE(&bes->connlist, vbe, list); if (vbe->fd >= 0) - close(vbe->fd); + AZ(close(vbe->fd)); FREE_OBJ(vbe); } FREE_OBJ(bes); diff --git a/varnish-cache/bin/varnishd/cache_expire.c b/varnish-cache/bin/varnishd/cache_expire.c index d615577b..de536256 100644 --- a/varnish-cache/bin/varnishd/cache_expire.c +++ b/varnish-cache/bin/varnishd/cache_expire.c @@ -175,7 +175,7 @@ exp_prefetch(void *arg) ww.wlp = ww.wlog; ww.wle = ww.wlog + sizeof ww.wlog; - sleep(10); /* Takes time for VCL to arrive */ + AZ(sleep(10)); /* XXX: Takes time for VCL to arrive */ VCL_Get(&sp->vcl); t = TIM_real(); while (1) { diff --git a/varnish-cache/bin/varnishd/cache_pipe.c b/varnish-cache/bin/varnishd/cache_pipe.c index c33e5b3f..20d599af 100644 --- a/varnish-cache/bin/varnishd/cache_pipe.c +++ b/varnish-cache/bin/varnishd/cache_pipe.c @@ -50,16 +50,16 @@ rdf(struct pollfd *fds, int idx) i = read(fds[idx].fd, buf, sizeof buf); if (i <= 0 || fds[1-idx].events == 0) { - shutdown(fds[idx].fd, SHUT_RD); - shutdown(fds[1-idx].fd, SHUT_WR); + AZ(shutdown(fds[idx].fd, SHUT_RD)); + AZ(shutdown(fds[1-idx].fd, SHUT_WR)); fds[idx].events = 0; return; } for (p = buf; i > 0; i -= j, p += j) { j = write(fds[1-idx].fd, p, i); if (j != i) { - shutdown(fds[idx].fd, SHUT_WR); - shutdown(fds[1-idx].fd, SHUT_RD); + AZ(shutdown(fds[idx].fd, SHUT_WR)); + AZ(shutdown(fds[1-idx].fd, SHUT_RD)); fds[1-idx].events = 0; return; } diff --git a/varnish-cache/bin/varnishd/mgt_cli.c b/varnish-cache/bin/varnishd/mgt_cli.c index 8eb48064..c6ac6828 100644 --- a/varnish-cache/bin/varnishd/mgt_cli.c +++ b/varnish-cache/bin/varnishd/mgt_cli.c @@ -345,14 +345,14 @@ mgt_cli_callback(struct ev *e, int what) cli_close: vsb_delete(cp->cli->sb); free(cp->buf); - close(cp->fdi); + AZ(close(cp->fdi)); if (cp->fdi == 0) - open("/dev/null", O_RDONLY); - close(cp->fdo); + assert(open("/dev/null", O_RDONLY) == 0); + AZ(close(cp->fdo)); if (cp->fdo == 1) { + assert(open("/dev/null", O_WRONLY) == 1); close(2); - open("/dev/null", O_WRONLY); - open("/dev/null", O_WRONLY); + assert(open("/dev/null", O_WRONLY) == 2); } free(cp); return (1); diff --git a/varnish-cache/bin/varnishd/mgt_vcc.c b/varnish-cache/bin/varnishd/mgt_vcc.c index b76a5994..2046cc1a 100644 --- a/varnish-cache/bin/varnishd/mgt_vcc.c +++ b/varnish-cache/bin/varnishd/mgt_vcc.c @@ -173,8 +173,8 @@ mgt_CallCc(const char *source, struct vsb *sb) vsb_printf(sb, "Write error to C source file: %s\n", strerror(errno)); - unlink(sf); - fclose(fs); + AZ(unlink(sf)); + AZ(fclose(fs)); return (NULL); } rewind(fs); @@ -216,8 +216,8 @@ mgt_CallCc(const char *source, struct vsb *sb) "\tcommand attempted: %s\n", strerror(errno), vsb_data(cccmd)); free(of); - unlink(sf); - fclose(fs); + AZ(unlink(sf)); + AZ(fclose(fs)); vsb_delete(cccmd); return (NULL); } @@ -241,8 +241,8 @@ mgt_CallCc(const char *source, struct vsb *sb) i = pclose(fo); - unlink(sf); - fclose(fs); + AZ(unlink(sf)); + AZ(fclose(fs)); if (j == 0 && i != 0) { vsb_printf(sb, @@ -262,7 +262,7 @@ mgt_CallCc(const char *source, struct vsb *sb) /* If the compiler complained, or exited non-zero, fail */ if (i || j) { - unlink(of); + AZ(unlink(of)); free(of); return (NULL); } @@ -272,12 +272,12 @@ mgt_CallCc(const char *source, struct vsb *sb) if (p == NULL) { vsb_printf(sb, "Problem loading compiled VCL program:\n\t%s\n", dlerror()); - unlink(of); + AZ(unlink(of)); free(of); return (NULL); } - (void)dlclose(p); + AZ(dlclose(p)); return (of); } @@ -328,6 +328,7 @@ mgt_vcc_add(const char *name, char *file) vp = calloc(sizeof *vp, 1); XXXAN(vp); vp->name = strdup(name); + XXXAN(vp->name); vp->fname = file; TAILQ_INSERT_TAIL(&vclhead, vp, list); return (vp); -- 2.39.5