]> err.no Git - varnish/commitdiff
Assert return values of system{calls,functions}
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Tue, 25 Sep 2007 07:30:38 +0000 (07:30 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Tue, 25 Sep 2007 07:30:38 +0000 (07:30 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2025 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache_backend.c
varnish-cache/bin/varnishd/cache_backend_simple.c
varnish-cache/bin/varnishd/cache_expire.c
varnish-cache/bin/varnishd/cache_pipe.c
varnish-cache/bin/varnishd/mgt_cli.c
varnish-cache/bin/varnishd/mgt_vcc.c

index 141fd05260c4f728c2a6a8caf02f22de6611526f..48572df873e63c47c3827190ee3acf02fac7a253 100644 (file)
@@ -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);
        }
index 282713e411a586be76b08440bc5d61fe133b0717..2eb2ed923aa8023aa06a07922f5e4449142507d1 100644 (file)
@@ -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);
index d615577b3375ecdeb2c5f392702d566afda1ef36..de536256ae64e010bd74bff4bb22bdda014cc7ea 100644 (file)
@@ -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) {
index c33e5b3f051ab325bc1423cf5ba4840f471ac380..20d599afe4ac89626f2e236f3a375a744b96f86a 100644 (file)
@@ -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;
                }
index 8eb48064b50b03f598304249d38b64693c0033f8..c6ac6828d4174303db215eed716a80b7de5748ec 100644 (file)
@@ -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);
index b76a59949a61bf2988df60584b7ef49fc566b999..2046cc1a55ed7751f1ee05c9d32a17cf60fe6d67 100644 (file)
@@ -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);