From: phk Date: Wed, 12 Jul 2006 22:01:43 +0000 (+0000) Subject: Give this file a flexelinting X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fff70f48a926744fada6053d0b31539e8e700922;p=varnish Give this file a flexelinting git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@463 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache_acceptor.c b/varnish-cache/bin/varnishd/cache_acceptor.c index 1469588f..5fe575e2 100644 --- a/varnish-cache/bin/varnishd/cache_acceptor.c +++ b/varnish-cache/bin/varnishd/cache_acceptor.c @@ -20,7 +20,6 @@ #include #include "config.h" -#include "compat.h" #include "libvarnish.h" #include "heritage.h" #include "shmlog.h" @@ -72,7 +71,7 @@ vca_new_sess(void) } static void -vca_delete_sess(struct sess *sp) +vca_delete_sess(const struct sess *sp) { VSL_stats->n_sess--; @@ -160,13 +159,16 @@ vca_write_obj(struct worker *w, struct sess *sp) /*--------------------------------------------------------------------*/ static void -vca_tick(int a __unused, short b __unused, void *c __unused) +vca_tick(int a, short b, void *c) { struct sess *sp, *sp2; time_t t; - evtimer_add(&tick_e, &tick_rate); - time(&t); + (void)a; + (void)b; + (void)c; + AZ(evtimer_add(&tick_e, &tick_rate)); + (void)time(&t); TAILQ_FOREACH_SAFE(sp, &sesshead, list, sp2) { if (sp->t_resp + 30 < t) { TAILQ_REMOVE(&sesshead, sp, list); @@ -194,20 +196,22 @@ vca_callback(void *arg, int bad) } static void -pipe_f(int fd, short event __unused, void *arg __unused) +pipe_f(int fd, short event, void *arg) { struct sess *sp; int i; + (void)event; + (void)arg; i = read(fd, &sp, sizeof sp); assert(i == sizeof sp); - time(&sp->t_resp); + sp->t_resp = time(NULL); TAILQ_INSERT_TAIL(&sesshead, sp, list); http_RecvHead(sp->http, sp->fd, evb, vca_callback, sp); } static void -accept_f(int fd, short event __unused, void *arg __unused) +accept_f(int fd, short event, void *arg) { socklen_t l; struct sockaddr addr[2]; /* XXX: IPv6 hack */ @@ -215,6 +219,8 @@ accept_f(int fd, short event __unused, void *arg __unused) int i; struct linger linger; + (void)event; + (void)arg; VSL_stats->client_conn++; sp = vca_new_sess(); @@ -239,28 +245,31 @@ accept_f(int fd, short event __unused, void *arg __unused) TCP_name(addr, l, sp->addr); VSL(SLT_SessionOpen, sp->fd, "%s", sp->addr); - time(&sp->t_resp); + (void)time(&sp->t_resp); TAILQ_INSERT_TAIL(&sesshead, sp, list); http_RecvHead(sp->http, sp->fd, evb, vca_callback, sp); } static void * -vca_main(void *arg __unused) +vca_main(void *arg) { unsigned u; struct event *ep; + (void)arg; + AZ(pipe(pipes)); evb = event_init(); + assert(evb != NULL); event_set(&pipe_e, pipes[0], EV_READ | EV_PERSIST, pipe_f, NULL); - event_base_set(evb, &pipe_e); - event_add(&pipe_e, NULL); + AZ(event_base_set(evb, &pipe_e)); + AZ(event_add(&pipe_e, NULL)); evtimer_set(&tick_e, vca_tick, NULL); - event_base_set(evb, &tick_e); + AZ(event_base_set(evb, &tick_e)); - evtimer_add(&tick_e, &tick_rate); + AZ(evtimer_add(&tick_e, &tick_rate)); ep = accept_e; for (u = 0; u < HERITAGE_NSOCKS; u++) { @@ -268,23 +277,22 @@ vca_main(void *arg __unused) event_set(ep, heritage.sock_local[u], EV_READ | EV_PERSIST, accept_f, NULL); - event_base_set(evb, ep); - event_add(ep, NULL); + AZ(event_base_set(evb, ep)); + AZ(event_add(ep, NULL)); ep++; } if (heritage.sock_remote[u] >= 0) { event_set(ep, heritage.sock_remote[u], EV_READ | EV_PERSIST, accept_f, NULL); - event_base_set(evb, ep); - event_add(ep, NULL); + AZ(event_base_set(evb, ep)); + AZ(event_add(ep, NULL)); ep++; } } - event_base_loop(evb, 0); - assert(0 == 1); - return (NULL); + AZ(event_base_loop(evb, 0)); + INCOMPL(); } /*--------------------------------------------------------------------*/ @@ -294,7 +302,8 @@ vca_close_session(struct sess *sp, const char *why) { VSL(SLT_SessionClose, sp->fd, why); - close(sp->fd); + if (sp->fd >= 0) + AZ(close(sp->fd)); sp->fd = -1; } @@ -306,7 +315,7 @@ vca_return_session(struct sess *sp) if (sp->fd >= 0) { VSL(SLT_SessionReuse, sp->fd, "%s", sp->addr); - write(pipes[1], &sp, sizeof sp); + assert(sizeof sp == write(pipes[1], &sp, sizeof sp)); } else { vca_delete_sess(sp); } diff --git a/varnish-cache/bin/varnishd/cache_backend.c b/varnish-cache/bin/varnishd/cache_backend.c index 394510ae..5a43a64e 100644 --- a/varnish-cache/bin/varnishd/cache_backend.c +++ b/varnish-cache/bin/varnishd/cache_backend.c @@ -199,7 +199,6 @@ vbe_connect(struct backend *bp) TCP_myname(s, buf); p = strchr(buf, '\0'); - assert(p != NULL); *p++ = ' '; TCP_name(ai->ai_addr, ai->ai_addrlen, p); VSL(SLT_BackendOpen, s, buf); diff --git a/varnish-cache/bin/varnishd/flint.lnt b/varnish-cache/bin/varnishd/flint.lnt index ffd1e442..9969c085 100644 --- a/varnish-cache/bin/varnishd/flint.lnt +++ b/varnish-cache/bin/varnishd/flint.lnt @@ -1,47 +1,64 @@ -passes=3 -// Review all below this line - --printf_code( H, void *, unsigned) --printf_code( ju, long long unsigned) --printf_code( jx, long long unsigned) +// Fix strchr() semtics, it can only return NULL if arg2 != 0 +-sem(strchr, 1p, type(1), 2n == 0 ? (@p < 1p) : (@p < 1p || @p == 0 )) -e763 // Redundant declaration for symbol '...' previously declared +-e726 // Extraneous comma ignored +-e728 // Symbol ... not explicitly initialized +-esym(534, fprintf) // Ignoring return value of function +-esym(534, memset) // Ignoring return value of function +-esym(534, sbuf_printf) // Ignoring return value of function --e737 // Loss of sign in promotion from 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' --e732 // Loss of sign (arg. no. 2) (int to unsigned int) --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 - +// cache.h +-emacro(506, INCOMPL) // Constant value Boolean --e785 // Too few initializers for aggregate - --e766 // Header file '../../include/libvarnish.h' not used in module +// 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 --e773 // Expression-like macro 'VCL_FARGS' not parenthesized +// Review all below this line --e788 // enum constant 'HND_Unclass' not used within defaulted switch +// -printf_code( H, void *, unsigned) +// -printf_code( ju, long long unsigned) +// -printf_code( jx, long long unsigned) +// --e716 // while(1) ... --e641 // Converting enum 'cli_status_e' to int --e786 // String concatenation within initializer - --emacro(19, MAC_STAT) // Useless Declaration +// +// +-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 +// -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 +// +// -e773 // Expression-like macro 'VCL_FARGS' not parenthesized +// +// -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/varnishd.c b/varnish-cache/bin/varnishd/varnishd.c index 8315532b..a45ad886 100644 --- a/varnish-cache/bin/varnishd/varnishd.c +++ b/varnish-cache/bin/varnishd/varnishd.c @@ -122,6 +122,7 @@ vcl_default(const char *bflag) q = p + 1; } else { p = strchr(bflag, '\0'); + assert(p != NULL); q = "http"; }