Commit 50440ca1 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

More flexelint nit-picking of various sorts


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@2043 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent da8912c1
...@@ -161,8 +161,8 @@ struct worker { ...@@ -161,8 +161,8 @@ struct worker {
int *wfd; int *wfd;
unsigned werr; /* valid after WRK_Flush() */ unsigned werr; /* valid after WRK_Flush() */
struct iovec iov[MAX_IOVS]; struct iovec iov[MAX_IOVS];
unsigned niov; int niov;
size_t liov; ssize_t liov;
struct VCL_conf *vcl; struct VCL_conf *vcl;
struct srcaddr *srcaddr; struct srcaddr *srcaddr;
...@@ -446,7 +446,7 @@ void HSH_Deref(struct object *o); ...@@ -446,7 +446,7 @@ void HSH_Deref(struct object *o);
void HSH_Init(void); void HSH_Init(void);
/* cache_http.c */ /* cache_http.c */
const char *http_StatusMessage(int); const char *http_StatusMessage(unsigned);
void HTTP_Init(void); void HTTP_Init(void);
void http_ClrHeader(struct http *to); void http_ClrHeader(struct http *to);
unsigned http_Write(struct worker *w, const struct http *hp, int resp); unsigned http_Write(struct worker *w, const struct http *hp, int resp);
......
...@@ -135,9 +135,10 @@ vca_acct(void *arg) ...@@ -135,9 +135,10 @@ vca_acct(void *arg)
socklen_t l; socklen_t l;
struct sockaddr_storage addr_s; struct sockaddr_storage addr_s;
struct sockaddr *addr; struct sockaddr *addr;
int i, j; int i;
struct pollfd *pfd; struct pollfd *pfd;
struct listen_sock *ls; struct listen_sock *ls;
unsigned u;
(void)arg; (void)arg;
...@@ -171,16 +172,16 @@ vca_acct(void *arg) ...@@ -171,16 +172,16 @@ vca_acct(void *arg)
&tv_rcvtimeo, sizeof tv_rcvtimeo)); &tv_rcvtimeo, sizeof tv_rcvtimeo));
} }
i = poll(pfd, heritage.nsocks, 1000); i = poll(pfd, heritage.nsocks, 1000);
for (j = 0; j < heritage.nsocks; j++) { for (u = 0; u < heritage.nsocks; u++) {
if (pfd[j].revents == 0) if (pfd[u].revents == 0)
continue; continue;
VSL_stats->client_conn++; VSL_stats->client_conn++;
l = sizeof addr_s; l = sizeof addr_s;
addr = (void*)&addr_s; addr = (void*)&addr_s;
i = accept(pfd[j].fd, addr, &l); i = accept(pfd[u].fd, addr, &l);
if (i < 0) { if (i < 0) {
if (errno != EAGAIN) { if (errno != EAGAIN) {
VSL(SLT_Debug, pfd[j].fd, VSL(SLT_Debug, pfd[u].fd,
"Accept failed errno=%d", errno); "Accept failed errno=%d", errno);
/* XXX: stats ? */ /* XXX: stats ? */
} }
......
...@@ -56,7 +56,7 @@ static VTAILQ_HEAD(,sess) sesshead = VTAILQ_HEAD_INITIALIZER(sesshead); ...@@ -56,7 +56,7 @@ static VTAILQ_HEAD(,sess) sesshead = VTAILQ_HEAD_INITIALIZER(sesshead);
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
static void static void
vca_pollspace(int fd) vca_pollspace(unsigned fd)
{ {
struct pollfd *p; struct pollfd *p;
unsigned u, v; unsigned u, v;
...@@ -82,7 +82,9 @@ vca_pollspace(int fd) ...@@ -82,7 +82,9 @@ vca_pollspace(int fd)
static void static void
vca_poll(int fd) vca_poll(int fd)
{ {
vca_pollspace(fd);
assert(fd >= 0);
vca_pollspace((unsigned)fd);
pollfd[fd].fd = fd; pollfd[fd].fd = fd;
pollfd[fd].events = POLLIN; pollfd[fd].events = POLLIN;
} }
...@@ -90,7 +92,9 @@ vca_poll(int fd) ...@@ -90,7 +92,9 @@ vca_poll(int fd)
static void static void
vca_unpoll(int fd) vca_unpoll(int fd)
{ {
vca_pollspace(fd);
assert(fd >= 0);
vca_pollspace((unsigned)fd);
pollfd[fd].fd = -1; pollfd[fd].fd = -1;
pollfd[fd].events = 0; pollfd[fd].events = 0;
} }
......
...@@ -299,7 +299,7 @@ ber_GetFd(const struct sess *sp) ...@@ -299,7 +299,7 @@ ber_GetFd(const struct sess *sp)
for (n = 1; n < 5; n++) { for (n = 1; n < 5; n++) {
vc = ber_nextfd(sp); vc = ber_nextfd(sp);
if (vc == NULL) { if (vc == NULL) {
usleep(100000 * n); AZ(usleep(100000 * n));
continue; continue;
} }
assert(vc->fd >= 0); assert(vc->fd >= 0);
...@@ -371,7 +371,7 @@ ber_Cleanup(const struct backend *b) ...@@ -371,7 +371,7 @@ ber_Cleanup(const struct backend *b)
break; break;
VTAILQ_REMOVE(&bs->connlist, vbe, list); VTAILQ_REMOVE(&bs->connlist, vbe, list);
if (vbe->fd >= 0) if (vbe->fd >= 0)
close(vbe->fd); AZ(close(vbe->fd));
free(vbe); free(vbe);
} }
bstmp = bs; bstmp = bs;
......
...@@ -284,7 +284,7 @@ brr_GetFd(const struct sess *sp) ...@@ -284,7 +284,7 @@ brr_GetFd(const struct sess *sp)
for (n = 1; n < 5; n++) { for (n = 1; n < 5; n++) {
vc = brr_nextfd(sp); vc = brr_nextfd(sp);
if (vc == NULL) { if (vc == NULL) {
usleep(100000 * n); AZ(usleep(100000 * n));
continue; continue;
} }
assert(vc->fd >= 0); assert(vc->fd >= 0);
...@@ -356,7 +356,7 @@ brr_Cleanup(const struct backend *b) ...@@ -356,7 +356,7 @@ brr_Cleanup(const struct backend *b)
break; break;
VTAILQ_REMOVE(&bs->connlist, vbe, list); VTAILQ_REMOVE(&bs->connlist, vbe, list);
if (vbe->fd >= 0) if (vbe->fd >= 0)
close(vbe->fd); AZ(close(vbe->fd));
free(vbe); free(vbe);
} }
bstmp = bs; bstmp = bs;
......
...@@ -53,13 +53,17 @@ fetch_straight(struct sess *sp, int fd, struct http *hp, const char *b) ...@@ -53,13 +53,17 @@ fetch_straight(struct sess *sp, int fd, struct http *hp, const char *b)
{ {
int i; int i;
unsigned char *p; unsigned char *p;
off_t cl; uintmax_t cll;
unsigned cl;
struct storage *st; struct storage *st;
cl = strtoumax(b, NULL, 0); cll = strtoumax(b, NULL, 0);
if (cl == 0) if (cll == 0)
return (0); return (0);
cl = (unsigned)cll;
assert((uintmax_t)cl == cll); /* Protect against bogusly large values */
st = STV_alloc(sp, cl); st = STV_alloc(sp, cl);
VTAILQ_INSERT_TAIL(&sp->obj->store, st, list); VTAILQ_INSERT_TAIL(&sp->obj->store, st, list);
st->len = cl; st->len = cl;
...@@ -89,7 +93,7 @@ fetch_chunked(struct sess *sp, int fd, struct http *hp) ...@@ -89,7 +93,7 @@ fetch_chunked(struct sess *sp, int fd, struct http *hp)
int i; int i;
char *q; char *q;
struct storage *st; struct storage *st;
unsigned u, v; unsigned u, v, w;
char buf[20]; /* XXX: arbitrary */ char buf[20]; /* XXX: arbitrary */
char *bp, *be; char *bp, *be;
...@@ -157,17 +161,16 @@ fetch_chunked(struct sess *sp, int fd, struct http *hp) ...@@ -157,17 +161,16 @@ fetch_chunked(struct sess *sp, int fd, struct http *hp)
v = u; v = u;
/* Handle anything left in our buffer first */ /* Handle anything left in our buffer first */
i = pdiff(q, bp); w = pdiff(q, bp);
assert(i >= 0); if (w > v)
if (i > v) w = v;
i = v; if (w != 0) {
if (i != 0) { memcpy(st->ptr + st->len, q, w);
memcpy(st->ptr + st->len, q, i); st->len += w;
st->len += i; sp->obj->len += w;
sp->obj->len += i; u -= w;
u -= i; v -= w;
v -= i; q += w;
q += i;
} }
if (u == 0) if (u == 0)
break; break;
...@@ -263,7 +266,8 @@ Fetch(struct sess *sp) ...@@ -263,7 +266,8 @@ Fetch(struct sess *sp)
struct http *hp, *hp2; struct http *hp, *hp2;
struct storage *st; struct storage *st;
struct bereq *bereq; struct bereq *bereq;
int len, mklen, is_head; int mklen, is_head;
unsigned len;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
......
...@@ -89,7 +89,7 @@ http2shmlog(const struct http *hp, enum httptag t) ...@@ -89,7 +89,7 @@ http2shmlog(const struct http *hp, enum httptag t)
} }
static void static void
WSLH(struct worker *w, enum httptag t, int fd, const struct http *hp, int hdr) WSLH(struct worker *w, enum httptag t, int fd, const struct http *hp, unsigned hdr)
{ {
WSLR(w, http2shmlog(hp, t), fd, hp->hd[hdr].b, hp->hd[hdr].e); WSLR(w, http2shmlog(hp, t), fd, hp->hd[hdr].b, hp->hd[hdr].e);
...@@ -146,7 +146,7 @@ static struct http_msg { ...@@ -146,7 +146,7 @@ static struct http_msg {
}; };
const char * const char *
http_StatusMessage(int status) http_StatusMessage(unsigned status)
{ {
struct http_msg *mp; struct http_msg *mp;
...@@ -237,7 +237,7 @@ int ...@@ -237,7 +237,7 @@ int
http_GetHdrField(const struct http *hp, const char *hdr, const char *field, char **ptr) http_GetHdrField(const struct http *hp, const char *hdr, const char *field, char **ptr)
{ {
char *h; char *h;
int fl; unsigned fl;
if (!http_GetHdr(hp, hdr, &h)) if (!http_GetHdr(hp, hdr, &h))
return (0); return (0);
...@@ -273,7 +273,6 @@ http_DoConnection(struct sess *sp) ...@@ -273,7 +273,6 @@ http_DoConnection(struct sess *sp)
{ {
struct http *hp = sp->http; struct http *hp = sp->http;
char *p, *q; char *p, *q;
int i;
unsigned u; unsigned u;
if (!http_GetHdr(hp, H_Connection, &p)) { if (!http_GetHdr(hp, H_Connection, &p)) {
...@@ -289,10 +288,10 @@ http_DoConnection(struct sess *sp) ...@@ -289,10 +288,10 @@ http_DoConnection(struct sess *sp)
for (q = p + 1; *q; q++) for (q = p + 1; *q; q++)
if (*q == ',' || isspace(*q)) if (*q == ',' || isspace(*q))
break; break;
i = pdiff(p, q); u = pdiff(p, q);
if (i == 5 && !strncasecmp(p, "close", i)) if (u == 5 && !strncasecmp(p, "close", u))
sp->doclose = "Connection: close"; sp->doclose = "Connection: close";
u = http_findhdr(hp, i, p); u = http_findhdr(hp, u, p);
if (u != 0) if (u != 0)
hp->hdf[u] |= HDF_FILTER; hp->hdf[u] |= HDF_FILTER;
if (!*q) if (!*q)
...@@ -346,7 +345,7 @@ int ...@@ -346,7 +345,7 @@ int
http_Read(struct http *hp, int fd, void *p, unsigned len) http_Read(struct http *hp, int fd, void *p, unsigned len)
{ {
int i; int i;
int u; unsigned u;
char *b = p; char *b = p;
u = 0; u = 0;
...@@ -363,7 +362,7 @@ http_Read(struct http *hp, int fd, void *p, unsigned len) ...@@ -363,7 +362,7 @@ http_Read(struct http *hp, int fd, void *p, unsigned len)
hp->pl_s = hp->pl_e = NULL; hp->pl_s = hp->pl_e = NULL;
if (len > 0) { if (len > 0) {
i = read(fd, b, len); i = read(fd, b, len);
if (i < 0) if (i < 0) /* XXX i == 0 ?? */
return (i); return (i);
u += i; u += i;
} }
...@@ -904,7 +903,7 @@ static void ...@@ -904,7 +903,7 @@ static void
http_PutField(struct worker *w, int fd, struct http *to, int field, const char *string) http_PutField(struct worker *w, int fd, struct http *to, int field, const char *string)
{ {
char *p; char *p;
int l; unsigned l;
CHECK_OBJ_NOTNULL(to, HTTP_MAGIC); CHECK_OBJ_NOTNULL(to, HTTP_MAGIC);
l = strlen(string); l = strlen(string);
......
...@@ -94,7 +94,7 @@ WRK_Reset(struct worker *w, int *fd) ...@@ -94,7 +94,7 @@ WRK_Reset(struct worker *w, int *fd)
unsigned unsigned
WRK_Flush(struct worker *w) WRK_Flush(struct worker *w)
{ {
int i; ssize_t i;
CHECK_OBJ_NOTNULL(w, WORKER_MAGIC); CHECK_OBJ_NOTNULL(w, WORKER_MAGIC);
if (*w->wfd < 0 || w->niov == 0 || w->werr) if (*w->wfd < 0 || w->niov == 0 || w->werr)
...@@ -133,7 +133,7 @@ WRK_Write(struct worker *w, const void *ptr, int len) ...@@ -133,7 +133,7 @@ WRK_Write(struct worker *w, const void *ptr, int len)
if (len == -1) if (len == -1)
len = strlen(ptr); len = strlen(ptr);
if (w->niov == MAX_IOVS) if (w->niov == MAX_IOVS)
WRK_Flush(w); (void)WRK_Flush(w);
w->iov[w->niov].iov_base = (void*)(uintptr_t)ptr; w->iov[w->niov].iov_base = (void*)(uintptr_t)ptr;
w->iov[w->niov].iov_len = len; w->iov[w->niov].iov_len = len;
w->liov += len; w->liov += len;
...@@ -394,7 +394,7 @@ wrk_reaperthread(void *priv) ...@@ -394,7 +394,7 @@ wrk_reaperthread(void *priv)
(void)priv; (void)priv;
while (1) { while (1) {
wrk_addpools(params->wthread_pools); wrk_addpools(params->wthread_pools);
sleep(1); AZ(sleep(1));
if (VSL_stats->n_wrk <= params->wthread_min) if (VSL_stats->n_wrk <= params->wthread_min)
continue; continue;
now = TIM_real(); now = TIM_real();
...@@ -415,7 +415,6 @@ wrk_reaperthread(void *priv) ...@@ -415,7 +415,6 @@ wrk_reaperthread(void *priv)
assert(1 == write(w->pipe[1], w, 1)); assert(1 == write(w->pipe[1], w, 1));
} }
} }
INCOMPL();
} }
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
-emacro(740, VTAILQ_LAST) // Unusual pointer cast (incompatible indirect types) -emacro(740, VTAILQ_LAST) // Unusual pointer cast (incompatible indirect types)
-emacro((826), VTAILQ_PREV) // Suspicious pointer-to-pointer conversion (area too small) -emacro((826), VTAILQ_PREV) // Suspicious pointer-to-pointer conversion (area too small)
-emacro((826), VTAILQ_LAST) // Suspicious pointer-to-pointer conversion (area too small) -emacro((826), VTAILQ_LAST) // Suspicious pointer-to-pointer conversion (area too small)
-emacro(506, VTAILQ_FOREACH_SAFE) // constant value boolean
-esym(534, sprintf) // Ignoring return value of function -esym(534, sprintf) // Ignoring return value of function
-esym(534, asprintf) // Ignoring return value of function -esym(534, asprintf) // Ignoring return value of function
......
...@@ -53,7 +53,7 @@ struct heritage { ...@@ -53,7 +53,7 @@ struct heritage {
/* Sockets from which to accept connections */ /* Sockets from which to accept connections */
struct listen_sock_head socks; struct listen_sock_head socks;
int nsocks; unsigned nsocks;
/* Share memory log fd and size (incl header) */ /* Share memory log fd and size (incl header) */
int vsl_fd; int vsl_fd;
......
...@@ -55,7 +55,7 @@ struct evsig { ...@@ -55,7 +55,7 @@ struct evsig {
}; };
static struct evsig *ev_sigs; static struct evsig *ev_sigs;
static unsigned ev_nsig; static int ev_nsig;
struct evbase { struct evbase {
unsigned magic; unsigned magic;
......
...@@ -297,7 +297,7 @@ mgt_VccCompile(struct vsb *sb, const char *b, const char *e, int C_flag) ...@@ -297,7 +297,7 @@ mgt_VccCompile(struct vsb *sb, const char *b, const char *e, int C_flag)
csrc = VCC_Compile(sb, b, e); csrc = VCC_Compile(sb, b, e);
if (csrc != NULL) { if (csrc != NULL) {
if (C_flag) if (C_flag)
fputs(csrc, stdout); (void)fputs(csrc, stdout);
vf = mgt_CallCc(csrc, sb); vf = mgt_CallCc(csrc, sb);
if (C_flag && vf != NULL) if (C_flag && vf != NULL)
AZ(unlink(vf)); AZ(unlink(vf));
...@@ -500,7 +500,7 @@ mcf_config_inline(struct cli *cli, const char * const *av, void *priv) ...@@ -500,7 +500,7 @@ mcf_config_inline(struct cli *cli, const char * const *av, void *priv)
free(p); free(p);
return; return;
} }
mgt_vcc_add(av[2], vf); (void)mgt_vcc_add(av[2], vf);
} }
void void
...@@ -531,7 +531,7 @@ mcf_config_load(struct cli *cli, const char * const *av, void *priv) ...@@ -531,7 +531,7 @@ mcf_config_load(struct cli *cli, const char * const *av, void *priv)
free(p); free(p);
return; return;
} }
mgt_vcc_add(av[2], vf); (void)mgt_vcc_add(av[2], vf);
} }
static struct vclprog * static struct vclprog *
......
...@@ -79,9 +79,9 @@ volatile struct params *params; ...@@ -79,9 +79,9 @@ volatile struct params *params;
static int static int
cmp_hash(const struct hash_slinger *s, const char *p, const char *q) cmp_hash(const struct hash_slinger *s, const char *p, const char *q)
{ {
if (strlen(s->name) != q - p) if (strlen(s->name) != (q - p))
return (1); return (1);
if (strncmp(s->name, p, q - p)) if (strncmp(s->name, p, (q - p)))
return (1); return (1);
return (0); return (0);
} }
...@@ -288,7 +288,7 @@ DebugStunt(void) ...@@ -288,7 +288,7 @@ DebugStunt(void)
/* close the rest */ /* close the rest */
for (i = 5; i < getdtablesize(); i++) for (i = 5; i < getdtablesize(); i++)
close(i); (void)close(i);
pfd[0].fd = pipes[0][0]; pfd[0].fd = pipes[0][0];
pfd[0].events = POLLIN; pfd[0].events = POLLIN;
......
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