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

A quick round of FlexeLint silencing



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@5743 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 5ac2f951
...@@ -125,16 +125,16 @@ ESI_Include(struct sess *sp, const char *src, const char *host) ...@@ -125,16 +125,16 @@ ESI_Include(struct sess *sp, const char *src, const char *host)
#define Debug(fmt, ...) /**/ #define Debug(fmt, ...) /**/
static void static void
esi_sendchunk(struct sess *sp, const void *cb, ssize_t cl, esi_sendchunk(const struct sess *sp, const void *cb, ssize_t cl,
const void *ptr, ssize_t l) const void *ptr, ssize_t l)
{ {
Debug("VER(%d) %d\n", (int)l, (int)(cb-ce)); Debug("VER(%d) %d\n", (int)l, (int)(cb-ce));
if (sp->wrk->res_mode & RES_CHUNKED) if (sp->wrk->res_mode & RES_CHUNKED)
WRW_Write(sp->wrk, cb, cl); (void)WRW_Write(sp->wrk, cb, cl);
WRW_Write(sp->wrk, ptr, l); (void)WRW_Write(sp->wrk, ptr, l);
if (sp->wrk->res_mode & RES_CHUNKED) if (sp->wrk->res_mode & RES_CHUNKED)
WRW_Write(sp->wrk, "\r\n", -1); (void)WRW_Write(sp->wrk, "\r\n", -1);
} }
void void
...@@ -209,12 +209,7 @@ ESI_Deliver(struct sess *sp) ...@@ -209,12 +209,7 @@ ESI_Deliver(struct sess *sp)
q = (void*)strchr((const char*)p, '\0'); q = (void*)strchr((const char*)p, '\0');
assert (q > p); assert (q > p);
Debug("LIT(%d) %d\n", (int)l, (int)(q-p)); Debug("LIT(%d) %d\n", (int)l, (int)(q-p));
if (sp->wrk->res_mode & RES_CHUNKED) esi_sendchunk(sp, p, q - p, q + 1, l);
WRW_Write(sp->wrk, p, q - p);
p = q + 1;
WRW_Write(sp->wrk, p, l);
if (sp->wrk->res_mode & RES_CHUNKED)
WRW_Write(sp->wrk, "\r\n", -1);
p = p + l; p = p + l;
break; break;
case VEC_INCL: case VEC_INCL:
...@@ -232,10 +227,9 @@ ESI_Deliver(struct sess *sp) ...@@ -232,10 +227,9 @@ ESI_Deliver(struct sess *sp)
default: default:
Debug("XXXX 0x%02x [%s]\n", *p, p); Debug("XXXX 0x%02x [%s]\n", *p, p);
INCOMPL(); INCOMPL();
return;
} }
} }
WRW_Flush(sp->wrk); (void)WRW_Flush(sp->wrk);
} }
#endif /* OLD_ESI */ #endif /* OLD_ESI */
...@@ -53,7 +53,7 @@ typedef void dostuff_f(struct vep_state *, enum dowhat); ...@@ -53,7 +53,7 @@ typedef void dostuff_f(struct vep_state *, enum dowhat);
struct vep_match { struct vep_match {
const char *match; const char *match;
const char **state; const char * const *state;
}; };
struct vep_state { struct vep_state {
...@@ -106,37 +106,37 @@ const char *hack_p; ...@@ -106,37 +106,37 @@ const char *hack_p;
/*---------------------------------------------------------------------*/ /*---------------------------------------------------------------------*/
static const char *VEP_START = "[Start]"; static const char * const VEP_START = "[Start]";
static const char *VEP_TESTXML = "[TestXml]"; static const char * const VEP_TESTXML = "[TestXml]";
static const char *VEP_NOTXML = "[NotXml]"; static const char * const VEP_NOTXML = "[NotXml]";
static const char *VEP_NEXTTAG = "[NxtTag]"; static const char * const VEP_NEXTTAG = "[NxtTag]";
static const char *VEP_NOTMYTAG = "[NotMyTag]"; static const char * const VEP_NOTMYTAG = "[NotMyTag]";
static const char *VEP_STARTTAG = "[StartTag]"; static const char * const VEP_STARTTAG = "[StartTag]";
static const char *VEP_COMMENT = "[Comment]"; static const char * const VEP_COMMENT = "[Comment]";
static const char *VEP_CDATA = "[CDATA]"; static const char * const VEP_CDATA = "[CDATA]";
static const char *VEP_ESITAG = "[ESITag]"; static const char * const VEP_ESITAG = "[ESITag]";
static const char *VEP_ESIETAG = "[ESIEndTag]"; static const char * const VEP_ESIETAG = "[ESIEndTag]";
static const char *VEP_ESIREMOVE = "[ESI:Remove]"; static const char * const VEP_ESIREMOVE = "[ESI:Remove]";
static const char *VEP_ESIINCLUDE = "[ESI:Include]"; static const char * const VEP_ESIINCLUDE = "[ESI:Include]";
static const char *VEP_ESICOMMENT = "[ESI:Comment]"; static const char * const VEP_ESICOMMENT = "[ESI:Comment]";
static const char *VEP_ESIBOGON = "[ESI:Bogon]"; static const char * const VEP_ESIBOGON = "[ESI:Bogon]";
static const char *VEP_INTAG = "[InTag]"; static const char * const VEP_INTAG = "[InTag]";
static const char *VEP_TAGERROR = "[TagError]"; static const char * const VEP_TAGERROR = "[TagError]";
static const char *VEP_ATTR = "[Attribute]"; static const char * const VEP_ATTR = "[Attribute]";
static const char *VEP_SKIPATTR = "[SkipAttribute]"; static const char * const VEP_SKIPATTR = "[SkipAttribute]";
static const char *VEP_SKIPATTR2 = "[SkipAttribute2]"; static const char * const VEP_SKIPATTR2 = "[SkipAttribute2]";
static const char *VEP_ATTRDELIM = "[AttrDelim]"; static const char * const VEP_ATTRDELIM = "[AttrDelim]";
static const char *VEP_ATTRGETVAL = "[AttrGetValue]"; static const char * const VEP_ATTRGETVAL = "[AttrGetValue]";
static const char *VEP_ATTRVAL = "[AttrValue]"; static const char * const VEP_ATTRVAL = "[AttrValue]";
static const char *VEP_UNTIL = "[Until]"; static const char * const VEP_UNTIL = "[Until]";
static const char *VEP_MATCHBUF = "[MatchBuf]"; static const char * const VEP_MATCHBUF = "[MatchBuf]";
static const char *VEP_MATCH = "[Match]"; static const char * const VEP_MATCH = "[Match]";
/*---------------------------------------------------------------------*/ /*---------------------------------------------------------------------*/
...@@ -205,6 +205,7 @@ vep_match(struct vep_state *vep, const char *b, const char *e) ...@@ -205,6 +205,7 @@ vep_match(struct vep_state *vep, const char *b, const char *e)
{ {
struct vep_match *vm; struct vep_match *vm;
const char *q, *r; const char *q, *r;
ssize_t l;
for (vm = vep->match; vm->match; vm++) { for (vm = vep->match; vm->match; vm++) {
r = b; r = b;
...@@ -213,9 +214,10 @@ vep_match(struct vep_state *vep, const char *b, const char *e) ...@@ -213,9 +214,10 @@ vep_match(struct vep_state *vep, const char *b, const char *e)
break; break;
if (*q != '\0' && r == e) { if (*q != '\0' && r == e) {
if (b != vep->tag) { if (b != vep->tag) {
assert(e - b < sizeof vep->tag); l = e - b;
memcpy(vep->tag, b, e - b); assert(l < sizeof vep->tag);
vep->tag_i = e - b; memmove(vep->tag, b, l);
vep->tag_i = l;
} }
return (NULL); return (NULL);
} }
...@@ -230,23 +232,23 @@ vep_match(struct vep_state *vep, const char *b, const char *e) ...@@ -230,23 +232,23 @@ vep_match(struct vep_state *vep, const char *b, const char *e)
*/ */
static void static void
vep_emit_len(struct vep_state *vep, ssize_t l, int m8, int m16, int m64) vep_emit_len(const struct vep_state *vep, ssize_t l, int m8, int m16, int m64)
{ {
uint8_t buf[9]; uint8_t buf[9];
assert(l > 0); assert(l > 0);
if (l < 256) { if (l < 256) {
buf[0] = m8; buf[0] = (uint8_t)m8;
buf[1] = (uint8_t)l; buf[1] = (uint8_t)l;
assert((ssize_t)buf[1] == l); assert((ssize_t)buf[1] == l);
vsb_bcat(vep->vsb, buf, 2); vsb_bcat(vep->vsb, buf, 2);
} else if (l < 65536) { } else if (l < 65536) {
buf[0] = m16; buf[0] = (uint8_t)m16;
vbe16enc(buf + 1, (uint16_t)l); vbe16enc(buf + 1, (uint16_t)l);
assert((ssize_t)vbe16dec(buf + 1) == l); assert((ssize_t)vbe16dec(buf + 1) == l);
vsb_bcat(vep->vsb, buf, 3); vsb_bcat(vep->vsb, buf, 3);
} else { } else {
buf[0] = m64; buf[0] = (uint8_t)m64;
vbe64enc(buf + 1, l); vbe64enc(buf + 1, l);
assert((ssize_t)vbe64dec(buf + 1) == l); assert((ssize_t)vbe64dec(buf + 1) == l);
vsb_bcat(vep->vsb, buf, 9); vsb_bcat(vep->vsb, buf, 9);
...@@ -276,6 +278,7 @@ vep_emit_verbatim(struct vep_state *vep) ...@@ -276,6 +278,7 @@ vep_emit_verbatim(struct vep_state *vep)
vsb_printf(vep->vsb, "%lx\r\n%c", l, 0); vsb_printf(vep->vsb, "%lx\r\n%c", l, 0);
} }
#if 0
static void static void
vep_emit_literal(struct vep_state *vep, const char *p, const char *e) vep_emit_literal(struct vep_state *vep, const char *p, const char *e)
{ {
...@@ -293,7 +296,7 @@ vep_emit_literal(struct vep_state *vep, const char *p, const char *e) ...@@ -293,7 +296,7 @@ vep_emit_literal(struct vep_state *vep, const char *p, const char *e)
vsb_printf(vep->vsb, "%lx\r\n%c", l, 0); vsb_printf(vep->vsb, "%lx\r\n%c", l, 0);
vsb_bcat(vep->vsb, p, l); vsb_bcat(vep->vsb, p, l);
} }
#endif
static void static void
vep_mark_verbatim(struct vep_state *vep, const char *p) vep_mark_verbatim(struct vep_state *vep, const char *p)
...@@ -332,23 +335,7 @@ vep_mark_skip(struct vep_state *vep, const char *p) ...@@ -332,23 +335,7 @@ vep_mark_skip(struct vep_state *vep, const char *p)
/*--------------------------------------------------------------------- /*---------------------------------------------------------------------
*/ */
#if 0 static void __match_proto__()
static void
vep_do_nothing(struct vep_state *vep, enum dowhat what)
{
Debug("DO_NOTHING(%d)\n", what);
if (what == DO_ATTR) {
Debug("ATTR (%s) (%s)\n", vep->match_hit->match,
vsb_data(vep->attr_vsb));
vsb_delete(vep->attr_vsb);
}
}
#endif
/*---------------------------------------------------------------------
*/
static void
vep_do_comment(struct vep_state *vep, enum dowhat what) vep_do_comment(struct vep_state *vep, enum dowhat what)
{ {
Debug("DO_COMMENT(%d)\n", what); Debug("DO_COMMENT(%d)\n", what);
...@@ -369,7 +356,7 @@ vep_do_comment(struct vep_state *vep, enum dowhat what) ...@@ -369,7 +356,7 @@ vep_do_comment(struct vep_state *vep, enum dowhat what)
/*--------------------------------------------------------------------- /*---------------------------------------------------------------------
*/ */
static void static void __match_proto__()
vep_do_remove(struct vep_state *vep, enum dowhat what) vep_do_remove(struct vep_state *vep, enum dowhat what)
{ {
Debug("DO_REMOVE(%d)\n", what); Debug("DO_REMOVE(%d)\n", what);
...@@ -400,7 +387,7 @@ vep_do_remove(struct vep_state *vep, enum dowhat what) ...@@ -400,7 +387,7 @@ vep_do_remove(struct vep_state *vep, enum dowhat what)
/*--------------------------------------------------------------------- /*---------------------------------------------------------------------
*/ */
static void static void __match_proto__()
vep_do_include(struct vep_state *vep, enum dowhat what) vep_do_include(struct vep_state *vep, enum dowhat what)
{ {
char *p, *q, *h; char *p, *q, *h;
...@@ -488,21 +475,17 @@ vep_do_include(struct vep_state *vep, enum dowhat what) ...@@ -488,21 +475,17 @@ vep_do_include(struct vep_state *vep, enum dowhat what)
*/ */
static void static void
vep_parse(struct vep_state *vep, const char *b, size_t l) vep_parse(struct vep_state *vep, const char *p, size_t l)
{ {
const char *e, *p; const char *e;
struct vep_match *vm; struct vep_match *vm;
int i; int i;
CHECK_OBJ_NOTNULL(vep, VEP_MAGIC); CHECK_OBJ_NOTNULL(vep, VEP_MAGIC);
assert(l > 0); assert(l > 0);
e = b + l; e = p + l;
if (0)
vep_emit_literal(vep, "A", "B");
p = b;
while (p < e) { while (p < e) {
AN(vep->state); AN(vep->state);
i = e - p; i = e - p;
...@@ -514,8 +497,6 @@ vep_parse(struct vep_state *vep, const char *b, size_t l) ...@@ -514,8 +497,6 @@ vep_parse(struct vep_state *vep, const char *b, size_t l)
vep->remove, vep->remove,
vep->tag_i, vep->tag, vep->tag_i, vep->tag,
i, p); i, p);
fflush(stdout);
usleep(10);
/****************************************************** /******************************************************
* SECTION A * SECTION A
...@@ -721,7 +702,7 @@ vep_parse(struct vep_state *vep, const char *b, size_t l) ...@@ -721,7 +702,7 @@ vep_parse(struct vep_state *vep, const char *b, size_t l)
vep_mark_skip(vep, p); vep_mark_skip(vep, p);
vep_error(vep, vep_error(vep,
"XML 1.0 Illegal attribute start char"); "XML 1.0 Illegal attribute start char");
Debug("ERR %d [%.*s]\n", __LINE__, (int)(e-p), p); Debug("ERR %d [%.*s]\n", __LINE__, (int)(e-p), p);
vep->state = VEP_TAGERROR; vep->state = VEP_TAGERROR;
} }
} else if (vep->state == VEP_TAGERROR) { } else if (vep->state == VEP_TAGERROR) {
...@@ -803,7 +784,7 @@ Debug("ERR %d [%.*s]\n", __LINE__, (int)(e-p), p); ...@@ -803,7 +784,7 @@ Debug("ERR %d [%.*s]\n", __LINE__, (int)(e-p), p);
vep_mark_skip(vep, p); vep_mark_skip(vep, p);
vep_error(vep, vep_error(vep,
"XML 1.0 Missing end attribute delimiter"); "XML 1.0 Missing end attribute delimiter");
Debug("ERR %d %c %c\n", __LINE__, *p, vep->attr_delim); Debug("ERR %d %c %c\n", __LINE__, *p, vep->attr_delim);
vep->state = VEP_TAGERROR; vep->state = VEP_TAGERROR;
vep->attr_delim = 0; vep->attr_delim = 0;
if (vep->attr_vsb != NULL) { if (vep->attr_vsb != NULL) {
...@@ -838,7 +819,6 @@ Debug("ERR %d %c %c\n", __LINE__, *p, vep->attr_delim); ...@@ -838,7 +819,6 @@ Debug("ERR %d %c %c\n", __LINE__, *p, vep->attr_delim);
if (vm != NULL) { if (vm != NULL) {
if (vm->match != NULL) if (vm->match != NULL)
p += strlen(vm->match); p += strlen(vm->match);
b = p;
vep->state = *vm->state; vep->state = *vm->state;
vep->match = NULL; vep->match = NULL;
vep->tag_i = 0; vep->tag_i = 0;
...@@ -886,6 +866,7 @@ Debug("ERR %d %c %c\n", __LINE__, *p, vep->attr_delim); ...@@ -886,6 +866,7 @@ Debug("ERR %d %c %c\n", __LINE__, *p, vep->attr_delim);
INCOMPL(); INCOMPL();
} }
} }
/* XXX: should we return p ? */
} }
/*--------------------------------------------------------------------- /*---------------------------------------------------------------------
...@@ -919,8 +900,8 @@ vfp_esi_bytes_uu(struct sess *sp, struct http_conn *htc, size_t bytes) ...@@ -919,8 +900,8 @@ vfp_esi_bytes_uu(struct sess *sp, struct http_conn *htc, size_t bytes)
w = HTC_Read(htc, st->ptr + st->len, l); w = HTC_Read(htc, st->ptr + st->len, l);
if (w <= 0) if (w <= 0)
return (w); return (w);
if (vep->hack_p == NULL) if (vep->hack_p == NULL)
vep->hack_p = (const char *)st->ptr + st->len; vep->hack_p = (const char *)st->ptr + st->len;
vep->ver_p = (const char *)st->ptr + st->len; vep->ver_p = (const char *)st->ptr + st->len;
#if 0 #if 0
{ {
...@@ -996,7 +977,6 @@ vfp_esi_end(struct sess *sp) ...@@ -996,7 +977,6 @@ vfp_esi_end(struct sess *sp)
Debug("ENDING %p\n", vep); Debug("ENDING %p\n", vep);
CHECK_OBJ_NOTNULL(vep, VEP_MAGIC); CHECK_OBJ_NOTNULL(vep, VEP_MAGIC);
usleep(100);
st = sp->wrk->storage; st = sp->wrk->storage;
if (st != NULL) if (st != NULL)
l = (const char *)(st->ptr + st->len) - (const char*)vep->ver_p; l = (const char *)(st->ptr + st->len) - (const char*)vep->ver_p;
...@@ -1010,15 +990,14 @@ vfp_esi_end(struct sess *sp) ...@@ -1010,15 +990,14 @@ vfp_esi_end(struct sess *sp)
vep_emit_verbatim(vep); vep_emit_verbatim(vep);
vsb_finish(vep->vsb); vsb_finish(vep->vsb);
l = vsb_len(vep->vsb); l = vsb_len(vep->vsb);
if (vep->state != VEP_NOTXML && l != 0) { if (vep->state != VEP_NOTXML && l > 0) {
Debug("ESI %d <%s>\n", (int)l, vsb_data(vep->vsb)); Debug("ESI %d <%s>\n", (int)l, vsb_data(vep->vsb));
/* XXX: This is a huge waste of storage... */ /* XXX: This is a huge waste of storage... */
sp->obj->esidata = STV_alloc(sp, vsb_len(vep->vsb)); sp->obj->esidata = STV_alloc(sp, l);
AN(sp->obj->esidata); AN(sp->obj->esidata);
memcpy(sp->obj->esidata->ptr, memcpy(sp->obj->esidata->ptr, vsb_data(vep->vsb), l);
vsb_data(vep->vsb), vsb_len(vep->vsb)); sp->obj->esidata->len = l;
sp->obj->esidata->len = vsb_len(vep->vsb);
} }
vsb_delete(vep->vsb); vsb_delete(vep->vsb);
......
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