Commit f4f2a4e0 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Technically speaking, vsb_len() could return -1, except it won't because

of the vsb_overflow() assert.

Make this explicit for FlexeLint.



git-svn-id: http://www.varnish-cache.org/svn/trunk@2967 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 3594ff01
...@@ -40,7 +40,6 @@ ...@@ -40,7 +40,6 @@
#include "shmlog.h" #include "shmlog.h"
#include "cache.h" #include "cache.h"
#include "stevedore.h" #include "stevedore.h"
#include "cli.h"
#include "cli_priv.h" #include "cli_priv.h"
static unsigned fetchfrag; static unsigned fetchfrag;
...@@ -204,7 +203,7 @@ fetch_chunked(struct sess *sp, struct http_conn *htc) ...@@ -204,7 +203,7 @@ fetch_chunked(struct sess *sp, struct http_conn *htc)
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
static void static void
dump_st(struct sess *sp, struct storage *st) dump_st(const struct sess *sp, const struct storage *st)
{ {
txt t; txt t;
...@@ -247,7 +246,7 @@ fetch_eof(struct sess *sp, struct http_conn *htc) ...@@ -247,7 +246,7 @@ fetch_eof(struct sess *sp, struct http_conn *htc)
st->len += i; st->len += i;
sp->obj->len += i; sp->obj->len += i;
} }
if (st != NULL && fetchfrag > 0) if (fetchfrag > 0)
dump_st(sp, st); dump_st(sp, st);
if (st->len == 0) { if (st->len == 0) {
...@@ -272,7 +271,7 @@ FetchReqBody(struct sess *sp) ...@@ -272,7 +271,7 @@ FetchReqBody(struct sess *sp)
unsigned long content_length; unsigned long content_length;
char buf[8192]; char buf[8192];
char *ptr, *endp; char *ptr, *endp;
int read; int rdcnt;
if (http_GetHdr(sp->http, H_Content_Length, &ptr)) { if (http_GetHdr(sp->http, H_Content_Length, &ptr)) {
...@@ -280,16 +279,16 @@ FetchReqBody(struct sess *sp) ...@@ -280,16 +279,16 @@ FetchReqBody(struct sess *sp)
/* XXX should check result of conversion */ /* XXX should check result of conversion */
while (content_length) { while (content_length) {
if (content_length > sizeof buf) if (content_length > sizeof buf)
read = sizeof buf; rdcnt = sizeof buf;
else else
read = content_length; rdcnt = content_length;
read = HTC_Read(sp->htc, buf, read); rdcnt = HTC_Read(sp->htc, buf, rdcnt);
if (read <= 0) if (rdcnt <= 0)
return (1); return (1);
content_length -= read; content_length -= rdcnt;
if (!sp->sendbody) if (!sp->sendbody)
continue; continue;
WRK_Write(sp->wrk, buf, read); WRK_Write(sp->wrk, buf, rdcnt); /* XXX: stats ? */
if (WRK_Flush(sp->wrk)) if (WRK_Flush(sp->wrk))
return (2); return (2);
} }
...@@ -342,7 +341,7 @@ Fetch(struct sess *sp) ...@@ -342,7 +341,7 @@ Fetch(struct sess *sp)
return (__LINE__); return (__LINE__);
TCP_blocking(vc->fd); /* XXX: we should timeout instead */ TCP_blocking(vc->fd); /* XXX: we should timeout instead */
WRK_Reset(w, &vc->fd); WRK_Reset(w, &vc->fd);
http_Write(w, hp, 0); http_Write(w, hp, 0); /* XXX: stats ? */
/* Deal with any message-body the request might have */ /* Deal with any message-body the request might have */
i = FetchReqBody(sp); i = FetchReqBody(sp);
......
...@@ -67,7 +67,7 @@ VRY_Create(const struct sess *sp) ...@@ -67,7 +67,7 @@ VRY_Create(const struct sess *sp)
{ {
char *v, *p, *q, *h, *e; char *v, *p, *q, *h, *e;
struct vsb *sb, *sbh; struct vsb *sb, *sbh;
unsigned l; int l;
/* No Vary: header, no worries */ /* No Vary: header, no worries */
if (!http_GetHdr(sp->obj->http, H_Vary, &v)) if (!http_GetHdr(sp->obj->http, H_Vary, &v))
...@@ -127,6 +127,7 @@ VRY_Create(const struct sess *sp) ...@@ -127,6 +127,7 @@ VRY_Create(const struct sess *sp)
vsb_finish(sb); vsb_finish(sb);
AZ(vsb_overflowed(sb)); AZ(vsb_overflowed(sb));
l = vsb_len(sb); l = vsb_len(sb);
assert(l >= 0);
sp->obj->vary = malloc(l); sp->obj->vary = malloc(l);
AN(sp->obj->vary); AN(sp->obj->vary);
memcpy(sp->obj->vary, vsb_data(sb), l); memcpy(sp->obj->vary, vsb_data(sb), l);
......
...@@ -53,7 +53,8 @@ ...@@ -53,7 +53,8 @@
-esym(534, strcpy) // Ignoring return value of function -esym(534, strcpy) // Ignoring return value of function
-esym(534, strlcpy) // Ignoring return value of function -esym(534, strlcpy) // Ignoring return value of function
-emacro(506, isnan) // constant value boolean -emacro(506, isnan, isfinite) // constant value boolean
-emacro(736, isfinite) // loss of precision
-emacro(747, isnan) // significant coersion -emacro(747, isnan) // significant coersion
-emacro(506, assert) // constant value boolean -emacro(506, assert) // constant value boolean
-emacro(827, assert) // loop not reachable -emacro(827, assert) // loop not reachable
......
...@@ -8,7 +8,7 @@ flexelint \ ...@@ -8,7 +8,7 @@ flexelint \
-I../.. \ -I../.. \
-DVARNISH_STATE_DIR=\"foo\" \ -DVARNISH_STATE_DIR=\"foo\" \
flint.lnt \ flint.lnt \
*.c > $T 2>&1 *.c ../../lib/libvarnish/*.c > $T 2>&1
for t in Error Warning Info Note for t in Error Warning Info Note
do do
......
...@@ -170,6 +170,7 @@ smf_calcsize(struct smf_sc *sc, const char *size, int newfile) ...@@ -170,6 +170,7 @@ smf_calcsize(struct smf_sc *sc, const char *size, int newfile)
*/ */
l = st.st_size; l = st.st_size;
} else { } else {
AN(size);
q = str2bytes(size, &l, fssize); q = str2bytes(size, &l, fssize);
if (q != NULL) if (q != NULL)
......
...@@ -401,7 +401,7 @@ cli_check(const struct cli *cli) ...@@ -401,7 +401,7 @@ cli_check(const struct cli *cli)
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
int int
main(int argc, char *argv[]) main(int argc, char * const *argv)
{ {
int o; int o;
unsigned C_flag = 0; unsigned C_flag = 0;
......
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