Commit 9764cb28 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

More Flexelinting


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@466 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 5b868fd7
......@@ -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);
}
......
......@@ -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 */
}
/*--------------------------------------------------------------------*/
......
......@@ -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");
......
......@@ -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;
......
......@@ -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);
}
......@@ -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
......
......@@ -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);
}
......
......@@ -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));
}
......@@ -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
#!/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
......@@ -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;
......
......@@ -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;
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment