From: phk Date: Wed, 12 Jul 2006 22:52:08 +0000 (+0000) Subject: More flexelinting. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dab06688902678cd6692a7de6cfee7bdfd654aa1;p=varnish More flexelinting. No bugs so far. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@465 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache.h b/varnish-cache/bin/varnishd/cache.h index 897a17c9..885e222f 100644 --- a/varnish-cache/bin/varnishd/cache.h +++ b/varnish-cache/bin/varnishd/cache.h @@ -5,8 +5,10 @@ #include #include #include -#include -#include + +#include "queue.h" +#include "event.h" +#include "sbuf.h" #include "vcl_returns.h" #include "common.h" diff --git a/varnish-cache/bin/varnishd/cache_acceptor.c b/varnish-cache/bin/varnishd/cache_acceptor.c index 5fe575e2..54695c0d 100644 --- a/varnish-cache/bin/varnishd/cache_acceptor.c +++ b/varnish-cache/bin/varnishd/cache_acceptor.c @@ -17,8 +17,6 @@ #include -#include - #include "config.h" #include "libvarnish.h" #include "heritage.h" diff --git a/varnish-cache/bin/varnishd/cache_backend.c b/varnish-cache/bin/varnishd/cache_backend.c index fd6da9db..f049ce54 100644 --- a/varnish-cache/bin/varnishd/cache_backend.c +++ b/varnish-cache/bin/varnishd/cache_backend.c @@ -26,7 +26,6 @@ #include #include -#include #include #include #include diff --git a/varnish-cache/bin/varnishd/cache_ban.c b/varnish-cache/bin/varnishd/cache_ban.c index 91e6a47a..db9264df 100644 --- a/varnish-cache/bin/varnishd/cache_ban.c +++ b/varnish-cache/bin/varnishd/cache_ban.c @@ -36,7 +36,7 @@ AddBan(const char *regexp) if (i) { char buf[512]; - regerror(i, &b->regexp, buf, sizeof buf); + (void)regerror(i, &b->regexp, buf, sizeof buf); VSL(SLT_Debug, 0, "REGEX: <%s>", buf); } b->gen = ++ban_next; @@ -71,9 +71,10 @@ BAN_CheckObject(struct object *o, const char *url) } void -cli_func_url_purge(struct cli *cli, char **av, void *priv __unused) +cli_func_url_purge(struct cli *cli, char **av, void *priv) { + (void)priv; AddBan(av[2]); cli_out(cli, "PURGE %s\n", av[2]); } diff --git a/varnish-cache/bin/varnishd/cache_center.c b/varnish-cache/bin/varnishd/cache_center.c index 7f8ad30d..67f66a9d 100644 --- a/varnish-cache/bin/varnishd/cache_center.c +++ b/varnish-cache/bin/varnishd/cache_center.c @@ -33,10 +33,7 @@ DOT start -> RECV #include #include #include -#include -#include "libvarnish.h" -#include "heritage.h" #include "shmlog.h" #include "vcl.h" #include "cache.h" @@ -521,7 +518,7 @@ void CNT_Session(struct worker *w, struct sess *sp) { - time(&sp->t0); + sp->t0 = time(NULL); sp->vcl = VCL_Get(); for (sp->step = STP_RECV; sp->step != STP_DONE; ) { diff --git a/varnish-cache/bin/varnishd/cache_expire.c b/varnish-cache/bin/varnishd/cache_expire.c index c355e1cf..b4428099 100644 --- a/varnish-cache/bin/varnishd/cache_expire.c +++ b/varnish-cache/bin/varnishd/cache_expire.c @@ -43,13 +43,15 @@ EXP_TTLchange(struct object *o) */ static void * -exp_hangman(void *arg __unused) +exp_hangman(void *arg) { struct object *o; time_t t; + (void)arg; + while (1) { - time (&t); + t = time(NULL); AZ(pthread_mutex_lock(&exp_mtx)); TAILQ_FOREACH(o, &exp_deathrow, deathrow) { if (o->ttl >= t) @@ -64,7 +66,7 @@ exp_hangman(void *arg __unused) } if (o == NULL || o->ttl >= t || o->refcnt > 0) { AZ(pthread_mutex_unlock(&exp_mtx)); - sleep(1); + AZ(sleep(1)); continue; } TAILQ_REMOVE(&exp_deathrow, o, deathrow); @@ -84,19 +86,21 @@ exp_hangman(void *arg __unused) */ static void * -exp_prefetch(void *arg __unused) +exp_prefetch(void *arg) { struct object *o; time_t t; struct sess sp; + (void)arg; + while (1) { - time(&t); + t = time(NULL); AZ(pthread_mutex_lock(&exp_mtx)); o = binheap_root(exp_heap); if (o == NULL || o->ttl > t + expearly) { AZ(pthread_mutex_unlock(&exp_mtx)); - sleep(1); + AZ(sleep(1)); continue; } binheap_delete(exp_heap, 0); @@ -121,20 +125,23 @@ exp_prefetch(void *arg __unused) /*--------------------------------------------------------------------*/ static int -object_cmp(void *priv __unused, void *a, void *b) +object_cmp(void *priv, void *a, void *b) { struct object *aa, *bb; + (void)priv; + aa = a; bb = b; return (aa->ttl < bb->ttl); } static void -object_update(void *priv __unused, void *p, unsigned u) +object_update(void *priv, void *p, unsigned u) { struct object *o = p; + (void)priv; o->heap_idx = u; } diff --git a/varnish-cache/bin/varnishd/cache_fetch.c b/varnish-cache/bin/varnishd/cache_fetch.c index 5ac9bcb0..c0e8a454 100644 --- a/varnish-cache/bin/varnishd/cache_fetch.c +++ b/varnish-cache/bin/varnishd/cache_fetch.c @@ -12,7 +12,6 @@ #include #include #include -#include #include "libvarnish.h" #include "shmlog.h" @@ -29,8 +28,9 @@ #define CHUNK_PREALLOC (128 * 1024) /*--------------------------------------------------------------------*/ + static int -fetch_straight(struct sess *sp, int fd, struct http *hp, char *b) +fetch_straight(const struct sess *sp, int fd, struct http *hp, char *b) { int i; char *e; @@ -70,7 +70,7 @@ fetch_straight(struct sess *sp, int fd, struct http *hp, char *b) /* XXX: Cleanup. It must be possible somehow :-( */ static int -fetch_chunked(struct sess *sp, int fd, struct http *hp) +fetch_chunked(const struct sess *sp, int fd, struct http *hp) { int i; char *b, *q, *e; @@ -180,7 +180,7 @@ fetch_chunked(struct sess *sp, int fd, struct http *hp) #include static int -fetch_eof(struct sess *sp, int fd, struct http *hp) +fetch_eof(const struct sess *sp, int fd, struct http *hp) { int i; char *b, *e; @@ -222,7 +222,7 @@ fetch_eof(struct sess *sp, int fd, struct http *hp) sp->obj->len += i; } - if (st != NULL && stevedore->trim != NULL) + if (stevedore->trim != NULL) stevedore->trim(st, st->len); return (1); @@ -294,7 +294,7 @@ FetchHeaders(struct worker *w, struct sess *sp) http_BuildSbuf(vc->fd, Build_Fetch, w->sb, sp->http); i = write(vc->fd, sbuf_data(w->sb), sbuf_len(w->sb)); assert(i == sbuf_len(w->sb)); - time(&sp->t_req); + sp->t_req = time(NULL); /* XXX: copy any body ?? */ @@ -303,8 +303,8 @@ FetchHeaders(struct worker *w, struct sess *sp) * XXX: read(2) the header */ http_RecvHead(hp, vc->fd, w->eb, NULL, NULL); - event_base_loop(w->eb, 0); - time(&sp->t_resp); + (void)event_base_loop(w->eb, 0); + sp->t_resp = time(NULL); assert(http_DissectResponse(hp, vc->fd) == 0); sp->vbc = vc; sp->bkd_http = hp; diff --git a/varnish-cache/bin/varnishd/cache_http.c b/varnish-cache/bin/varnishd/cache_http.c index bd29e859..7a080fc0 100644 --- a/varnish-cache/bin/varnishd/cache_http.c +++ b/varnish-cache/bin/varnishd/cache_http.c @@ -9,7 +9,6 @@ #include #include #include -#include #include "libvarnish.h" #include "shmlog.h" diff --git a/varnish-cache/bin/varnishd/cache_pass.c b/varnish-cache/bin/varnishd/cache_pass.c index 70a870c4..7c3489d2 100644 --- a/varnish-cache/bin/varnishd/cache_pass.c +++ b/varnish-cache/bin/varnishd/cache_pass.c @@ -11,7 +11,6 @@ #include #include #include -#include #include "libvarnish.h" #include "shmlog.h" diff --git a/varnish-cache/bin/varnishd/cache_pipe.c b/varnish-cache/bin/varnishd/cache_pipe.c index 53a0d75b..dc42cd07 100644 --- a/varnish-cache/bin/varnishd/cache_pipe.c +++ b/varnish-cache/bin/varnishd/cache_pipe.c @@ -7,7 +7,6 @@ #include #include #include -#include #include "libvarnish.h" #include "shmlog.h" diff --git a/varnish-cache/bin/varnishd/cache_pool.c b/varnish-cache/bin/varnishd/cache_pool.c index f7f466f2..e302fbf7 100644 --- a/varnish-cache/bin/varnishd/cache_pool.c +++ b/varnish-cache/bin/varnishd/cache_pool.c @@ -9,7 +9,6 @@ #include #include #include -#include #include "libvarnish.h" #include "heritage.h" diff --git a/varnish-cache/bin/varnishd/cache_response.c b/varnish-cache/bin/varnishd/cache_response.c index 554867fb..458a5017 100644 --- a/varnish-cache/bin/varnishd/cache_response.c +++ b/varnish-cache/bin/varnishd/cache_response.c @@ -5,10 +5,8 @@ #include /* XXX: for NULL ?? */ #include #include -#include #include "libvarnish.h" -#include "sbuf.h" #include "cache.h" diff --git a/varnish-cache/bin/varnishd/flint.lnt b/varnish-cache/bin/varnishd/flint.lnt index 9969c085..df82fe7a 100644 --- a/varnish-cache/bin/varnishd/flint.lnt +++ b/varnish-cache/bin/varnishd/flint.lnt @@ -6,19 +6,33 @@ -e763 // Redundant declaration for symbol '...' previously declared -e726 // Extraneous comma ignored -e728 // Symbol ... not explicitly initialized +-e716 // while(1) ... +-e785 // Too few initializers for aggregate +-emacro(740, TAILQ_PREV) // Unusual pointer cast (incompatible indirect types) +-emacro((826), TAILQ_PREV) // Suspicious pointer-to-pointer conversion (area too small) + + +-esym(534, printf) // Ignoring return value of function -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, sbuf_printf) // Ignoring return value of function +-esym(534, sbuf_cat) // Ignoring return value of function // cache.h -emacro(506, INCOMPL) // Constant value Boolean +// cache_center.c +-efunc(525, CNT_Session) // Negative indentation from line + // cache_vcl.c -efunc(525, vcl_handlingname) // Negative indentation from line -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) @@ -26,6 +40,12 @@ // -printf_code( jx, long long unsigned) // +-e767 // Macro redef (system queue.h vs ours ) + +-e574 // Signed-unsigned mix with relational +-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) // // @@ -40,18 +60,13 @@ // -e506 // Constant value boolean // -e527 // Unreachable code at token 'return' // -e774 // Boolean within 'if' always evaluates to False -// -e713 // Loss of precision (assignment) (unsigned long long to long long) -// -e574 // Signed-unsigned mix with relational // // -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) -// -e747 // Significant prototype coercion (arg. no. 2) long -// -e712 // Loss of precision (assignment) (long long to // // -// -e785 // Too few initializers for aggregate // // -e766 // Header file '../../include/libvarnish.h' not used in module // @@ -59,6 +74,5 @@ // // -e788 // enum constant 'HND_Unclass' not used within defaulted switch // -// -e716 // while(1) ... // // -e786 // String concatenation within initializer diff --git a/varnish-cache/bin/varnishd/mgt_child.c b/varnish-cache/bin/varnishd/mgt_child.c index 410c4527..b3ca7350 100644 --- a/varnish-cache/bin/varnishd/mgt_child.c +++ b/varnish-cache/bin/varnishd/mgt_child.c @@ -16,7 +16,7 @@ #include #include -#include +#include "queue.h" #include #include @@ -58,10 +58,12 @@ static TAILQ_HEAD(,creq) creqhead = TAILQ_HEAD_INITIALIZER(creqhead); */ static void -std_rdcb(struct bufferevent *bev, void *arg __unused) +std_rdcb(struct bufferevent *bev, void *arg) { const char *p; + (void)arg; + while (1) { p = evbuffer_readline(bev->input); if (p == NULL) @@ -74,7 +76,8 @@ static void std_wrcb(struct bufferevent *bev, void *arg) { - printf("%s(%p, %p)\n", __func__, (void*)bev, arg); + printf("%s(%p, %p)\n", + (const char *)__func__, (void*)bev, arg); exit (2); } @@ -82,7 +85,8 @@ static void std_excb(struct bufferevent *bev, short what, void *arg) { - printf("%s(%p, %d, %p)\n", __func__, (void*)bev, what, arg); + printf("%s(%p, %d, %p)\n", + (const char *)__func__, (void*)bev, what, arg); exit (2); } @@ -107,7 +111,7 @@ send_req(void) cli_encode_string(child_cli1->output, cr->argv[u]); } evbuffer_add_printf(child_cli1->output, "\n"); - bufferevent_enable(child_cli1, EV_WRITE); + AZ(bufferevent_enable(child_cli1, EV_WRITE)); } void @@ -132,12 +136,14 @@ mgt_child_request(mgt_ccb_f *func, void *priv, char **argv, const char *fmt, ... } static void -cli_rdcb(struct bufferevent *bev, void *arg __unused) +cli_rdcb(struct bufferevent *bev, void *arg) { const char *p; char **av; struct creq *cr; + (void)arg; + p = evbuffer_readline(bev->input); if (p == NULL) return; @@ -167,32 +173,41 @@ static void cli_excb(struct bufferevent *bev, short what, void *arg) { - printf("%s(%p, %d, %p)\n", __func__, (void*)bev, what, arg); + printf("%s(%p, %d, %p)\n", + (const char *)__func__, (void*)bev, what, arg); exit (2); } /*--------------------------------------------------------------------*/ static void -child_pingpong_ccb(unsigned u __unused, const char *r __unused, void *priv __unused) +child_pingpong_ccb(unsigned u, const char *r, void *priv) { + (void)u; + (void)r; + (void)priv; + /* XXX: reset keepalive timer */ } static void -child_pingpong(int a __unused, short b __unused, void *c __unused) +child_pingpong(int a, short b, void *c) { time_t t; struct timeval tv; - time(&t); + (void)a; + (void)b; + (void)c; + + t = time(NULL); mgt_child_request(child_pingpong_ccb, NULL, NULL, "ping %ld", t); if (1) { tv.tv_sec = 10; tv.tv_usec = 0; - evtimer_del(&ev_child_pingpong); - evtimer_add(&ev_child_pingpong, &tv); + AZ(evtimer_del(&ev_child_pingpong)); + AZ(evtimer_add(&ev_child_pingpong, &tv)); } } @@ -237,22 +252,22 @@ start_child(void) child_std = bufferevent_new(child_fds[0], std_rdcb, std_wrcb, std_excb, NULL); assert(child_std != NULL); - bufferevent_base_set(mgt_eb, child_std); + AZ(bufferevent_base_set(mgt_eb, child_std)); bufferevent_enable(child_std, EV_READ); child_cli0 = bufferevent_new(heritage.fds[0], cli_rdcb, cli_wrcb, cli_excb, NULL); assert(child_cli0 != NULL); - bufferevent_base_set(mgt_eb, child_cli0); + AZ(bufferevent_base_set(mgt_eb, child_cli0)); bufferevent_enable(child_cli0, EV_READ); child_cli1 = bufferevent_new(heritage.fds[3], cli_rdcb, cli_wrcb, cli_excb, NULL); assert(child_cli1 != NULL); - bufferevent_base_set(mgt_eb, child_cli1); + AZ(bufferevent_base_set(mgt_eb, child_cli1)); evtimer_set(&ev_child_pingpong, child_pingpong, NULL); - event_base_set(mgt_eb, &ev_child_pingpong); + AZ(event_base_set(mgt_eb, &ev_child_pingpong)); child_pingpong(0, 0, NULL); } @@ -312,12 +327,12 @@ mgt_sigchld(int a, short b, void *c) bufferevent_free(child_std); /* XXX: is this enough ? */ child_std = NULL; - close(heritage.fds[0]); - close(heritage.fds[1]); - close(heritage.fds[2]); - close(heritage.fds[3]); - close(child_fds[0]); - close(child_fds[1]); + AZ(close(heritage.fds[0])); + AZ(close(heritage.fds[1])); + AZ(close(heritage.fds[2])); + AZ(close(heritage.fds[3])); + AZ(close(child_fds[0])); + AZ(close(child_fds[1])); if (desired == H_START) start_child();