From ba90bec4f8df2a69e08b6273a7c04c7b7ca37e95 Mon Sep 17 00:00:00 2001 From: phk Date: Wed, 12 Jul 2006 23:30:49 +0000 Subject: [PATCH] More Flexelinting git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@466 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/cache_hash.c | 2 +- varnish-cache/bin/varnishd/cache_http.c | 11 +++--- varnish-cache/bin/varnishd/cache_main.c | 12 +++---- varnish-cache/bin/varnishd/cache_pass.c | 3 +- varnish-cache/bin/varnishd/cache_pipe.c | 18 +++++----- varnish-cache/bin/varnishd/cache_pool.c | 4 +-- varnish-cache/bin/varnishd/cache_vrt.c | 5 +-- varnish-cache/bin/varnishd/cli_event.c | 19 +++++----- varnish-cache/bin/varnishd/flint.lnt | 48 ++++++------------------- varnish-cache/bin/varnishd/flint.sh | 23 +++++++++++- varnish-cache/bin/varnishd/rfc2616.c | 2 ++ varnish-cache/bin/varnishd/shmlog.c | 4 +-- varnish-cache/bin/varnishd/varnishd.c | 11 +++--- 13 files changed, 80 insertions(+), 82 deletions(-) diff --git a/varnish-cache/bin/varnishd/cache_hash.c b/varnish-cache/bin/varnishd/cache_hash.c index a280798d..b345f021 100644 --- a/varnish-cache/bin/varnishd/cache_hash.c +++ b/varnish-cache/bin/varnishd/cache_hash.c @@ -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); } diff --git a/varnish-cache/bin/varnishd/cache_http.c b/varnish-cache/bin/varnishd/cache_http.c index 7a080fc0..7afefad8 100644 --- a/varnish-cache/bin/varnishd/cache_http.c +++ b/varnish-cache/bin/varnishd/cache_http.c @@ -338,12 +338,14 @@ http_header_complete(struct http *hp) #include 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 */ } /*--------------------------------------------------------------------*/ diff --git a/varnish-cache/bin/varnishd/cache_main.c b/varnish-cache/bin/varnishd/cache_main.c index 4de75ded..1f6fcb8c 100644 --- a/varnish-cache/bin/varnishd/cache_main.c +++ b/varnish-cache/bin/varnishd/cache_main.c @@ -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"); diff --git a/varnish-cache/bin/varnishd/cache_pass.c b/varnish-cache/bin/varnishd/cache_pass.c index 7c3489d2..01b1b62b 100644 --- a/varnish-cache/bin/varnishd/cache_pass.c +++ b/varnish-cache/bin/varnishd/cache_pass.c @@ -12,7 +12,6 @@ #include #include -#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; diff --git a/varnish-cache/bin/varnishd/cache_pipe.c b/varnish-cache/bin/varnishd/cache_pipe.c index dc42cd07..f28652ca 100644 --- a/varnish-cache/bin/varnishd/cache_pipe.c +++ b/varnish-cache/bin/varnishd/cache_pipe.c @@ -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); } diff --git a/varnish-cache/bin/varnishd/cache_pool.c b/varnish-cache/bin/varnishd/cache_pool.c index e302fbf7..dda2b3dd 100644 --- a/varnish-cache/bin/varnishd/cache_pool.c +++ b/varnish-cache/bin/varnishd/cache_pool.c @@ -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 diff --git a/varnish-cache/bin/varnishd/cache_vrt.c b/varnish-cache/bin/varnishd/cache_vrt.c index 0be28cea..0d6f2bcd 100644 --- a/varnish-cache/bin/varnishd/cache_vrt.c +++ b/varnish-cache/bin/varnishd/cache_vrt.c @@ -8,14 +8,10 @@ #include #include #include -#include -#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); } diff --git a/varnish-cache/bin/varnishd/cli_event.c b/varnish-cache/bin/varnishd/cli_event.c index 53e0cc5c..55c693d4 100644 --- a/varnish-cache/bin/varnishd/cli_event.c +++ b/varnish-cache/bin/varnishd/cli_event.c @@ -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)); } diff --git a/varnish-cache/bin/varnishd/flint.lnt b/varnish-cache/bin/varnishd/flint.lnt index df82fe7a..45285ead 100644 --- a/varnish-cache/bin/varnishd/flint.lnt +++ b/varnish-cache/bin/varnishd/flint.lnt @@ -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 @@ -31,14 +34,7 @@ -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 ) @@ -46,33 +42,11 @@ -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 diff --git a/varnish-cache/bin/varnishd/flint.sh b/varnish-cache/bin/varnishd/flint.sh index 019ab086..97da917a 100644 --- a/varnish-cache/bin/varnishd/flint.sh +++ b/varnish-cache/bin/varnishd/flint.sh @@ -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 diff --git a/varnish-cache/bin/varnishd/rfc2616.c b/varnish-cache/bin/varnishd/rfc2616.c index f79d0e64..109e1b9d 100644 --- a/varnish-cache/bin/varnishd/rfc2616.c +++ b/varnish-cache/bin/varnishd/rfc2616.c @@ -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; diff --git a/varnish-cache/bin/varnishd/shmlog.c b/varnish-cache/bin/varnishd/shmlog.c index f352886b..cfe84d62 100644 --- a/varnish-cache/bin/varnishd/shmlog.c +++ b/varnish-cache/bin/varnishd/shmlog.c @@ -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; diff --git a/varnish-cache/bin/varnishd/varnishd.c b/varnish-cache/bin/varnishd/varnishd.c index a45ad886..8e4f5892 100644 --- a/varnish-cache/bin/varnishd/varnishd.c +++ b/varnish-cache/bin/varnishd/varnishd.c @@ -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); -- 2.39.5