]> err.no Git - varnish/commitdiff
More Flexelinting
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Wed, 12 Jul 2006 23:30:49 +0000 (23:30 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Wed, 12 Jul 2006 23:30:49 +0000 (23:30 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@466 d4fa192b-c00b-0410-8231-f00ffab90ce4

13 files changed:
varnish-cache/bin/varnishd/cache_hash.c
varnish-cache/bin/varnishd/cache_http.c
varnish-cache/bin/varnishd/cache_main.c
varnish-cache/bin/varnishd/cache_pass.c
varnish-cache/bin/varnishd/cache_pipe.c
varnish-cache/bin/varnishd/cache_pool.c
varnish-cache/bin/varnishd/cache_vrt.c
varnish-cache/bin/varnishd/cli_event.c
varnish-cache/bin/varnishd/flint.lnt
varnish-cache/bin/varnishd/flint.sh
varnish-cache/bin/varnishd/rfc2616.c
varnish-cache/bin/varnishd/shmlog.c
varnish-cache/bin/varnishd/varnishd.c

index a280798d1684bca24e77c8d342ff89f6dee8c590..b345f021f5a52fc231243fb92af731ff41458129 100644 (file)
@@ -92,7 +92,7 @@ HSH_Lookup(struct worker *w, struct http *h)
        }
        if (o != NULL) {
                AZ(pthread_mutex_unlock(&oh->mtx));
-               hash->deref(oh);
+               (void)hash->deref(oh);
                return (o);
        }
 
index 7a080fc01df49b86ff10ec9c76bc9ffa4bdd1326..7afefad86012eaf74644d297b280a91b1ed61c1c 100644 (file)
@@ -338,12 +338,14 @@ http_header_complete(struct http *hp)
 #include <errno.h>
 
 static void
-http_read_f(int fd, short event __unused, void *arg)
+http_read_f(int fd, short event, void *arg)
 {
        struct http *hp = arg;
        unsigned l;
        int i, ret = 0;
 
+       (void)event;
+
        l = hp->e - hp->v;
        if (l <= 1) {
                VSL(SLT_HttpError, fd, "Received too much");
@@ -391,7 +393,8 @@ http_RecvHead(struct http *hp, int fd, struct event_base *eb, http_callback_f *f
        assert(hp->v <= hp->e);
        assert(hp->t <= hp->v);
        if (0)
-       VSL(SLT_Debug, fd, "Recv t %u v %u", hp->t - hp->s, hp->v - hp->s);
+               VSL(SLT_Debug, fd, "Recv t %u v %u",
+                   hp->t - hp->s, hp->v - hp->s);
        if (hp->t > hp->s && hp->t < hp->v) {
                l = hp->v - hp->t;
                memmove(hp->s, hp->t, l);
@@ -409,8 +412,8 @@ http_RecvHead(struct http *hp, int fd, struct event_base *eb, http_callback_f *f
        hp->callback = func;
        hp->arg = arg;
        event_set(&hp->ev, fd, EV_READ | EV_PERSIST, http_read_f, hp);
-       event_base_set(eb, &hp->ev);
-       event_add(&hp->ev, NULL);      /* XXX: timeout */
+       AZ(event_base_set(eb, &hp->ev));
+       AZ(event_add(&hp->ev, NULL));      /* XXX: timeout */
 }
 
 /*--------------------------------------------------------------------*/
index 4de75ded98f3f440fbf473235b13980c9c3ff397..1f6fcb8c44723c3d4f8b6acb551472e80837798c 100644 (file)
@@ -20,15 +20,13 @@ static struct event ev_keepalive;
 
 struct stevedore       *stevedore;
 
-struct varnish_stats *VSL_stats;
-
 /*--------------------------------------------------------------------*/
 
 static void
 timer_keepalive(int a, short b, void *c)
 {
 
-       printf("%s(%d, %d, %p)\n", __func__, a, (int)b, c);
+       printf("%s(%d, %d, %p)\n", (const char *)__func__, a, (int)b, c);
        printf("Heeellloooo ?   Ohh bother...\n");
        exit (1);
 }
@@ -41,8 +39,8 @@ arm_keepalive(void)
        tv.tv_sec = 30;
        tv.tv_usec = 0;
 
-       evtimer_del(&ev_keepalive);
-       evtimer_add(&ev_keepalive, &tv);
+       AZ(evtimer_del(&ev_keepalive));
+       AZ(evtimer_add(&ev_keepalive, &tv));
 }
 
 /*--------------------------------------------------------------------*/
@@ -69,7 +67,7 @@ cli_func_ping(struct cli *cli, char **av, void *priv)
        if (av[2] != NULL) {
                /* XXX: check clock skew is pointless here */
        }
-       time(&t);
+       t = time(NULL);
        cli_out(cli, "PONG %ld\n", t);
 }
 
@@ -126,7 +124,7 @@ child_main(void)
        cli = cli_setup(eb, heritage.fds[2], heritage.fds[1], 0, cli_proto);
 
        evtimer_set(&ev_keepalive, timer_keepalive, NULL);
-       event_base_set(eb, &ev_keepalive);
+       AZ(event_base_set(eb, &ev_keepalive));
        arm_keepalive();
 
        printf("Ready\n");
index 7c3489d2b3a42b8a13ddefd908236d6d1f9bb521..01b1b62bcfa89cfb0c19399010a10a24807f785a 100644 (file)
@@ -12,7 +12,6 @@
 #include <sys/socket.h>
 #include <netdb.h>
 
-#include "libvarnish.h"
 #include "shmlog.h"
 #include "cache.h"
 
@@ -204,7 +203,7 @@ PassSession(struct worker *w, struct sess *sp)
         */
        hp = vc->http;
        http_RecvHead(hp, vc->fd, w->eb, NULL, NULL);
-       event_base_loop(w->eb, 0);
+       (void)event_base_loop(w->eb, 0);
        http_DissectResponse(hp, vc->fd);
 
        sp->bkd_http = hp;
index dc42cd070ec54b90252aad8539119a10e7bbba81..f28652cad2b4924b2cafc3bb8ae3554b4242a7fb 100644 (file)
@@ -18,24 +18,26 @@ struct edir {
 };
 
 static void
-rdf(int fd, short event __unused, void *arg)
+rdf(int fd, short event, void *arg)
 {
        int i, j;
        struct edir *ep;
        char buf[BUFSIZ];
 
+       (void)event;
+
        ep = arg;
        i = read(fd, buf, sizeof buf);
        if (i <= 0) {
                shutdown(fd, SHUT_RD);
                shutdown(ep->fd, SHUT_WR);
-               event_del(&ep->ev);
+               AZ(event_del(&ep->ev));
        } else {
                j = write(ep->fd, buf, i);
                if (i != j) {
                        shutdown(fd, SHUT_WR);
                        shutdown(ep->fd, SHUT_RD);
-                       event_del(&ep->ev);
+                       AZ(event_del(&ep->ev));
                }
        }
 }
@@ -67,12 +69,12 @@ PipeSession(struct worker *w, struct sess *sp)
        e1.fd = vc->fd;
        e2.fd = sp->fd;
        event_set(&e1.ev, sp->fd, EV_READ | EV_PERSIST, rdf, &e1);
-       event_base_set(w->eb, &e1.ev);
+       AZ(event_base_set(w->eb, &e1.ev));
        event_set(&e2.ev, vc->fd, EV_READ | EV_PERSIST, rdf, &e2);
-       event_base_set(w->eb, &e2.ev);
-       event_add(&e1.ev, NULL);
-       event_add(&e2.ev, NULL);
-       event_base_loop(w->eb, 0);
+       AZ(event_base_set(w->eb, &e2.ev));
+       AZ(event_add(&e1.ev, NULL));
+       AZ(event_add(&e2.ev, NULL));
+       (void)event_base_loop(w->eb, 0);
        vca_close_session(sp, "pipe");
        VBE_ClosedFd(vc);
 }
index e302fbf77fcc068ff20bc7aed943e711c7089e4c..dda2b3dde9e8efd6fe8cbcde64244d31db7c8252 100644 (file)
@@ -79,7 +79,7 @@ wrk_thread(void *priv)
                }
 
                /* If we are a dynamic thread, time out and die */
-               clock_gettime(CLOCK_REALTIME, &ts);
+               AZ(clock_gettime(CLOCK_REALTIME, &ts));
                ts.tv_sec += heritage.wthread_timeout;
                if (pthread_cond_timedwait(&w->cv, &wrk_mtx, &ts)) {
                        VSL_stats->n_wrk--;
@@ -102,7 +102,7 @@ WRK_QueueSession(struct sess *sp)
        struct worker *w;
        pthread_t tp;
 
-       time(&sp->t_req);
+       sp->t_req = time(NULL);
 
        /*
         * No locking necessary, we're serialized in the acceptor thread
index 0be28ceaf6a1c6e117d02865111ddca96b097736..0d6f2bcd3448a14cb11732f74cb42343927abb76 100644 (file)
@@ -8,14 +8,10 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
-#include <dlfcn.h>
 
-#include "cli.h"
-#include "cli_priv.h"
 #include "shmlog.h"
 #include "vrt.h"
 #include "vcl.h"
-#include "libvarnish.h"
 #include "cache.h"
 
 /*--------------------------------------------------------------------*/
@@ -24,6 +20,7 @@ void
 VRT_error(struct sess *sp, unsigned err, const char *str)
 { 
 
+       (void)sp;
        VSL(SLT_Debug, 0, "VCL_error(%u, %s)", err, str);
 }
 
index 53e0cc5cf030f79ab940095f2e3fc410fd551aa6..55c693d4e8c7db68fdc20bc8a9773115b58d43c7 100644 (file)
@@ -105,16 +105,17 @@ rdcb(struct bufferevent *bev, void *arg)
                sbuf_finish(cli->sb);
                /* XXX: syslog results ? */
                encode_output(cli);
-               bufferevent_enable(cli->bev1, EV_WRITE);
+               AZ(bufferevent_enable(cli->bev1, EV_WRITE));
        }
 }
 
 static void
-wrcb(struct bufferevent *bev __unused, void *arg)
+wrcb(struct bufferevent *bev, void *arg)
 {
        struct cli *cli = arg;
 
-       bufferevent_disable(cli->bev1, EV_WRITE);
+       (void)bev;
+       AZ(bufferevent_disable(cli->bev1, EV_WRITE));
 }
 
 static void
@@ -133,20 +134,20 @@ cli_setup(struct event_base *eb, int fdr, int fdw, int ver, struct cli_proto *cl
 
        cli->bev0 = bufferevent_new(fdr, rdcb, wrcb, excb, cli);
        assert(cli->bev0 != NULL);
-       bufferevent_base_set(eb, cli->bev0);
+       AZ(bufferevent_base_set(eb, cli->bev0));
        if (fdr == fdw)
                cli->bev1 = cli->bev0;
        else 
                cli->bev1 = bufferevent_new(fdw, rdcb, wrcb, excb, cli);
        assert(cli->bev1 != NULL);
-       bufferevent_base_set(eb, cli->bev1);
+       AZ(bufferevent_base_set(eb, cli->bev1));
        cli->sb = sbuf_new(NULL, NULL, 0, SBUF_AUTOEXTEND);
        assert(cli->sb != NULL);
 
        cli->verbose = ver;
        cli->cli_proto = cli_proto;
        
-       bufferevent_enable(cli->bev0, EV_READ);
+       AZ(bufferevent_enable(cli->bev0, EV_READ));
        return (cli);
 }
 
@@ -155,7 +156,7 @@ cli_suspend(struct cli *cli)
 {
 
        cli->suspend = 1;
-       bufferevent_disable(cli->bev0, EV_READ);
+       AZ(bufferevent_disable(cli->bev0, EV_READ));
 }
 
 void
@@ -164,8 +165,8 @@ cli_resume(struct cli *cli)
        sbuf_finish(cli->sb);
        /* XXX: syslog results ? */
        encode_output(cli);
-       bufferevent_enable(cli->bev1, EV_WRITE);
+       AZ(bufferevent_enable(cli->bev1, EV_WRITE));
        cli->suspend = 0;
-       bufferevent_enable(cli->bev0, EV_READ);
+       AZ(bufferevent_enable(cli->bev0, EV_READ));
 }
 
index df82fe7a737115868da29e6750be743c3963987d..45285ead17d85d751f9c53578edbdcfadee87d98 100644 (file)
@@ -8,6 +8,7 @@
 -e728  // Symbol ... not explicitly initialized
 -e716  // while(1) ... 
 -e785  // Too few initializers for aggregate 
+-e786  // String concatenation within initializer
 
 -emacro(740, TAILQ_PREV) // Unusual pointer cast (incompatible indirect types)
 -emacro((826), TAILQ_PREV) // Suspicious pointer-to-pointer conversion (area too small)
@@ -17,6 +18,8 @@
 -esym(534, fprintf)    // Ignoring return value of function
 -esym(534, memset)     // Ignoring return value of function
 -esym(534, memcpy)     // Ignoring return value of function
+-esym(534, memmove)    // Ignoring return value of function
+-esym(534, strcpy)     // Ignoring return value of function
 -esym(534, sbuf_printf)        // Ignoring return value of function
 -esym(534, sbuf_cat)   // Ignoring return value of function
 
 -esym(528, vcl_handlingname)   // Not referenced
 -e641  // Converting enum 'cli_status_e' to int
 
-// storage_file.c
-
-// Review all below this line
-
-// -printf_code( H, void *, unsigned)
-// -printf_code( ju, long long unsigned)
-// -printf_code( jx, long long unsigned)
-// 
+// Review all below this line ///////////////////////////////////////////////
 
 -e767  // Macro redef (system queue.h vs ours )
 
 -e712  // Loss of precision (assignment) (long long to
 -e747  // Significant prototype coercion (arg. no. 2) long
 -e713  // Loss of precision (assignment) (unsigned long long to long long)
+-e506  // Constant value boolean
+-e818  // Pointer parameter '...' could be declared as pointing to const
+-e774  // Boolean within 'if' always evaluates to False
+-e534  // Ignoring return value of function
+-e557  // unrecog format
+-e732   // Loss of sign (arg. no. 2) (int to unsigned
+-e737  // [45]  Loss of sign in promotion from int to unsigned
 
-// 
-// 
--e737  //  Loss of sign in promotion from int to unsigned int
--e732  // Loss of sign (arg. no. 2) (int to unsigned int)
-// -e715       // Symbol 'arg' (line 43) not referenced
-// -e818       // Pointer parameter '...' could be declared as pointing to const
-// 
-// -e534       // Ignoring return value of function
-// -e767       // macro 'LIST_INIT' was defined differently
-// 
-// -e506       // Constant value boolean
-// -e527       // Unreachable code at token 'return'
-// -e774       // Boolean within 'if' always evaluates to False
-// 
-// -e525       // Negative indentation from line 90
-// -e539       // Did not expect positive indentation
-// -e725       // Expected positive indentation from line 136
-// -e734       // Loss of precision (assignment) (31 bits to 8 bits)
-// 
-// 
-// 
-// -e766       //  Header file '../../include/libvarnish.h' not used in module
-// 
-// -e773       // Expression-like macro 'VCL_FARGS' not parenthesized
-// 
-// -e788       // enum constant 'HND_Unclass' not used within defaulted switch
-// 
-// 
-// -e786       // String concatenation within initializer
index 019ab086107bd0e89ec3548854e4075960fdbfd0..97da917a209eeec375ac326b1dcbac48e26b2112 100644 (file)
@@ -1,9 +1,30 @@
 #!/bin/sh
 
+T=/tmp/_$$
 flexelint \
        -I/usr/include \
        -I. \
        -I../../include \
        -I../../contrib/libevent \
        flint.lnt \
-       *.c
+       *.c > $T 2>&1
+
+for t in Error Warning Info
+do
+       sed -n "/$t [0-9][0-9][0-9]:/s/.*\($t [0-9][0-9][0-9]\).*/\1/p" $T
+done | awk '
+$2 == 830      { next }
+$2 == 831      { next }
+       {
+       i=$2"_"$1
+       h[i]++
+       n++
+       }
+END    {
+       printf "%5d %s\n", n, "Total"
+       for (i in h)
+               printf "%5d %s\n", h[i], i
+       }
+' | sort -rn
+
+cat $T
index f79d0e64f4ec9a11d169b3717755637b172dad1e..109e1b9d6a912111b05ea9728f2b4438a0095650 100644 (file)
@@ -78,6 +78,8 @@ RFC2616_Ttl(struct http *hp, time_t t_req, time_t t_resp, struct object *obj)
        time_t h_date, h_expires, ttd;
        char *p;
        
+       (void)t_resp;   /* XXX */
+
        retirement_age = INT_MAX;
 
        u1 = u2 = 0;
index f352886b120920319080de2708a31825b5486c75..cfe84d626b64517a384ed615e5cd6a253628b8f4 100644 (file)
@@ -69,8 +69,8 @@ VSLR(enum shmlogtag tag, unsigned id, const char *b, const char *e)
        if (loghead->ptr + 4 + l + 1 > loghead->size)
                vsl_wrap();
        p = logstart + loghead->ptr;
-       p[1] = l;
-       p[2] = id >> 8;
+       p[1] = l & 0xff;
+       p[2] = (id >> 8) & 0xff;
        p[3] = id & 0xff;
        memcpy(p + 4, b, l);
        p[4 + l] = SLT_ENDMARKER;
index a45ad886c5f5c0f387ef5949711941628de7ba4a..8e4f5892e48be2a24347bfe17377743055c634b7 100644 (file)
@@ -91,10 +91,11 @@ cli_passthrough_cb(unsigned u, const char *r, void *priv)
 }
 
 static void
-m_cli_func_passthrough(struct cli *cli, char **av, void *priv __unused)
+m_cli_func_passthrough(struct cli *cli, char **av, void *priv)
 {
 
        (void)av;
+       (void)priv;
 
        cli_suspend(cli);
        mgt_child_request(cli_passthrough_cb, cli, &av[2], av[1]);
@@ -277,7 +278,7 @@ m_cli_func_ping(struct cli *cli, char **av, void *priv)
        if (av[2] != NULL) {
                cli_out(cli, "Got your %s\n", av[2]);
        } 
-       time(&t);
+       t = time(NULL);
        cli_out(cli, "PONG %ld\n", t);
 }
 
@@ -340,8 +341,8 @@ testme(void)
        cli = cli_setup(mgt_eb, 0, 1, 1, cli_proto);
 
        signal_set(&e_sigchld, SIGCHLD, mgt_sigchld, NULL);
-       event_base_set(mgt_eb, &e_sigchld);
-       signal_add(&e_sigchld, NULL);
+       AZ(event_base_set(mgt_eb, &e_sigchld));
+       AZ(signal_add(&e_sigchld, NULL));
 
        mgt_child_start();
 
@@ -505,7 +506,7 @@ main(int argc, char *argv[])
        const char *sflag = "file";
        const char *hflag = "classic";
 
-       register_printf_render_std((const unsigned char *)"HVQ");
+       (void)register_printf_render_std((const unsigned char *)"HVQ");
 
        setbuf(stdout, NULL);
        setbuf(stderr, NULL);