Commit 8aa9d566 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Clean up FlexeLint fluff.


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@1657 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent eeec0e50
...@@ -128,6 +128,7 @@ action: ...@@ -128,6 +128,7 @@ action:
'call' ident ';' 'call' ident ';'
'rewrite' cstr cstr ';' 'rewrite' cstr cstr ';'
'set' assignment ';' 'set' assignment ';'
'remove' variable ';'
# see variable 'returns' in vcc_gen_fixed_token.tcl # see variable 'returns' in vcc_gen_fixed_token.tcl
return_action: return_action:
...@@ -162,6 +163,7 @@ assign_int: ...@@ -162,6 +163,7 @@ assign_int:
'-=' cnum '-=' cnum
'=' cnum '=' cnum
ratio: ratio:
'*=' double '*=' double
'/=' double '/=' double
......
...@@ -30,13 +30,13 @@ ...@@ -30,13 +30,13 @@
*/ */
#include <stdio.h> #include <stdio.h>
#include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#include "vsb.h" #include "vsb.h"
#include "vcc_priv.h" #include "vcc_priv.h"
#include "vcc_compile.h" #include "vcc_compile.h"
#include "libvarnish.h"
static void static void
vcc_acl_top(struct tokenlist *tl, const char *acln) vcc_acl_top(struct tokenlist *tl, const char *acln)
...@@ -108,7 +108,7 @@ vcc_acl_bot(struct tokenlist *tl, const char *acln) ...@@ -108,7 +108,7 @@ vcc_acl_bot(struct tokenlist *tl, const char *acln)
} }
void void
vcc_Cond_Ip(struct var *vp, struct tokenlist *tl) vcc_Cond_Ip(const struct var *vp, struct tokenlist *tl)
{ {
unsigned tcond; unsigned tcond;
char *acln; char *acln;
......
...@@ -94,7 +94,7 @@ parse_error(struct tokenlist *tl) ...@@ -94,7 +94,7 @@ parse_error(struct tokenlist *tl)
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
static void static void
illegal_assignment(struct tokenlist *tl, const char *type) illegal_assignment(const struct tokenlist *tl, const char *type)
{ {
vsb_printf(tl->sb, "Invalid assignment operator "); vsb_printf(tl->sb, "Invalid assignment operator ");
...@@ -104,7 +104,7 @@ illegal_assignment(struct tokenlist *tl, const char *type) ...@@ -104,7 +104,7 @@ illegal_assignment(struct tokenlist *tl, const char *type)
} }
static void static void
check_writebit(struct tokenlist *tl, struct var *vp) check_writebit(struct tokenlist *tl, const struct var *vp)
{ {
if (vp->access == V_RW || vp->access == V_WO) if (vp->access == V_RW || vp->access == V_WO)
...@@ -195,13 +195,12 @@ parse_set(struct tokenlist *tl) ...@@ -195,13 +195,12 @@ parse_set(struct tokenlist *tl)
vcc_NextToken(tl); vcc_NextToken(tl);
Fb(tl, 0, ");\n"); Fb(tl, 0, ");\n");
break; break;
return;
case HASH: case HASH:
ExpectErr(tl, T_INCR); ExpectErr(tl, T_INCR);
vcc_NextToken(tl); vcc_NextToken(tl);
vcc_StringVal(tl); vcc_StringVal(tl);
Fb(tl, 0, ");\n"); Fb(tl, 0, ");\n");
return; break;
case STRING: case STRING:
if (tl->t->tok != '=') { if (tl->t->tok != '=') {
illegal_assignment(tl, "strings"); illegal_assignment(tl, "strings");
...@@ -209,7 +208,7 @@ parse_set(struct tokenlist *tl) ...@@ -209,7 +208,7 @@ parse_set(struct tokenlist *tl)
} }
vcc_NextToken(tl); vcc_NextToken(tl);
vcc_StringVal(tl); vcc_StringVal(tl);
if (vp->ishdr) { if (vp->hdr != NULL) {
while (tl->t->tok != ';') { while (tl->t->tok != ';') {
Fb(tl, 0, ", "); Fb(tl, 0, ", ");
vcc_StringVal(tl); vcc_StringVal(tl);
...@@ -232,13 +231,13 @@ static void ...@@ -232,13 +231,13 @@ static void
parse_remove(struct tokenlist *tl) parse_remove(struct tokenlist *tl)
{ {
struct var *vp; struct var *vp;
struct token *vt;
vcc_NextToken(tl); vcc_NextToken(tl);
ExpectErr(tl, VAR); ExpectErr(tl, VAR);
vt = tl->t;
vp = vcc_FindVar(tl, tl->t, vcc_vars); vp = vcc_FindVar(tl, tl->t, vcc_vars);
if (vp->fmt != STRING || !vp->ishdr) { ERRCHK(tl);
assert(vp != NULL);
if (vp->fmt != STRING || vp->hdr == NULL) {
vsb_printf(tl->sb, "Only http header lines can be removed.\n"); vsb_printf(tl->sb, "Only http header lines can be removed.\n");
vcc_ErrWhere(tl, tl->t); vcc_ErrWhere(tl, tl->t);
return; return;
......
...@@ -86,7 +86,7 @@ struct method method_tab[] = { ...@@ -86,7 +86,7 @@ struct method method_tab[] = {
#include "vcl_returns.h" #include "vcl_returns.h"
#undef VCL_MET_MAC #undef VCL_MET_MAC
#undef VCL_RET_MAC #undef VCL_RET_MAC
{ NULL, 0U } { NULL, 0U, 0}
}; };
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
......
...@@ -121,7 +121,7 @@ struct var { ...@@ -121,7 +121,7 @@ struct var {
const char *rname; const char *rname;
const char *lname; const char *lname;
enum {V_RO, V_RW, V_WO} access; enum {V_RO, V_RW, V_WO} access;
char ishdr; const char *hdr;
unsigned methods; unsigned methods;
}; };
...@@ -136,7 +136,7 @@ struct method { ...@@ -136,7 +136,7 @@ struct method {
/* vcc_acl.c */ /* vcc_acl.c */
void vcc_Acl(struct tokenlist *tl); void vcc_Acl(struct tokenlist *tl);
void vcc_Cond_Ip(struct var *vp, struct tokenlist *tl); void vcc_Cond_Ip(const struct var *vp, struct tokenlist *tl);
/* vcc_action.c */ /* vcc_action.c */
void vcc_ParseAction(struct tokenlist *tl); void vcc_ParseAction(struct tokenlist *tl);
......
...@@ -32,9 +32,9 @@ ...@@ -32,9 +32,9 @@
# Objects available in backends # Objects available in backends
set beobj { set beobj {
{ backend.host WO HOSTNAME } { backend.host WO HOSTNAME {} }
{ backend.port WO PORTNAME } { backend.port WO PORTNAME {} }
{ backend.dnsttl WO TIME } { backend.dnsttl WO TIME {} }
} }
# Variables available in sessions # Variables available in sessions
...@@ -70,6 +70,7 @@ set spobj { ...@@ -70,6 +70,7 @@ set spobj {
{ req.http. { req.http.
RW HEADER RW HEADER
{recv pipe pass hash miss hit fetch } {recv pipe pass hash miss hit fetch }
HDR_REQ
} }
# Possibly misnamed, not really part of the request # Possibly misnamed, not really part of the request
...@@ -98,6 +99,7 @@ set spobj { ...@@ -98,6 +99,7 @@ set spobj {
{ bereq.http. { bereq.http.
RW HEADER RW HEADER
{ pipe pass miss } { pipe pass miss }
HDR_BEREQ
} }
# The (possibly) cached object # The (possibly) cached object
...@@ -116,6 +118,7 @@ set spobj { ...@@ -116,6 +118,7 @@ set spobj {
{ obj.http. { obj.http.
RW HEADER RW HEADER
{ hit fetch } { hit fetch }
HDR_OBJ
} }
{ obj.valid { obj.valid
...@@ -151,6 +154,7 @@ set spobj { ...@@ -151,6 +154,7 @@ set spobj {
{ resp.http. { resp.http.
RW HEADER RW HEADER
{ deliver } { deliver }
HDR_RESP
} }
# Miscellaneous # Miscellaneous
...@@ -200,6 +204,9 @@ proc method_map {m} { ...@@ -200,6 +204,9 @@ proc method_map {m} {
append l " | " append l " | "
append l VCL_MET_[string toupper $i] append l VCL_MET_[string toupper $i]
} }
if {$l == ""} {
return "0"
}
return [string range $l 3 end] return [string range $l 3 end]
} }
...@@ -231,7 +238,11 @@ proc vars {v ty pa} { ...@@ -231,7 +238,11 @@ proc vars {v ty pa} {
puts $fo "\t NULL," puts $fo "\t NULL,"
} }
puts $fo "\t V_$a," puts $fo "\t V_$a,"
puts $fo "\t 0," if {$t != "HEADER"} {
puts $fo "\t 0,"
} else {
puts $fo "\t \"[lindex $v 4]\","
}
puts $fo "\t [method_map [lindex $v 3]]" puts $fo "\t [method_map [lindex $v 3]]"
puts $fo "\t\}," puts $fo "\t\},"
......
...@@ -15,21 +15,21 @@ struct var vcc_be_vars[] = { ...@@ -15,21 +15,21 @@ struct var vcc_be_vars[] = {
"VRT_l_backend_host(backend, ", "VRT_l_backend_host(backend, ",
V_WO, V_WO,
0, 0,
0
}, },
{ "backend.port", PORTNAME, 12, { "backend.port", PORTNAME, 12,
NULL, NULL,
"VRT_l_backend_port(backend, ", "VRT_l_backend_port(backend, ",
V_WO, V_WO,
0, 0,
0
}, },
{ "backend.dnsttl", TIME, 14, { "backend.dnsttl", TIME, 14,
NULL, NULL,
"VRT_l_backend_dnsttl(backend, ", "VRT_l_backend_dnsttl(backend, ",
V_WO, V_WO,
0, 0,
0
}, },
{ NULL } { NULL }
}; };
...@@ -74,7 +74,7 @@ struct var vcc_vars[] = { ...@@ -74,7 +74,7 @@ struct var vcc_vars[] = {
"VRT_r_req_http_(sp)", "VRT_r_req_http_(sp)",
"VRT_l_req_http_(sp, ", "VRT_l_req_http_(sp, ",
V_RW, V_RW,
0, "HDR_REQ",
VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH
}, },
{ "req.hash", HASH, 8, { "req.hash", HASH, 8,
...@@ -116,7 +116,7 @@ struct var vcc_vars[] = { ...@@ -116,7 +116,7 @@ struct var vcc_vars[] = {
"VRT_r_bereq_http_(sp)", "VRT_r_bereq_http_(sp)",
"VRT_l_bereq_http_(sp, ", "VRT_l_bereq_http_(sp, ",
V_RW, V_RW,
0, "HDR_BEREQ",
VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_MISS VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_MISS
}, },
{ "obj.proto", STRING, 9, { "obj.proto", STRING, 9,
...@@ -144,7 +144,7 @@ struct var vcc_vars[] = { ...@@ -144,7 +144,7 @@ struct var vcc_vars[] = {
"VRT_r_obj_http_(sp)", "VRT_r_obj_http_(sp)",
"VRT_l_obj_http_(sp, ", "VRT_l_obj_http_(sp, ",
V_RW, V_RW,
0, "HDR_OBJ",
VCL_MET_HIT | VCL_MET_FETCH VCL_MET_HIT | VCL_MET_FETCH
}, },
{ "obj.valid", BOOL, 9, { "obj.valid", BOOL, 9,
...@@ -200,7 +200,7 @@ struct var vcc_vars[] = { ...@@ -200,7 +200,7 @@ struct var vcc_vars[] = {
"VRT_r_resp_http_(sp)", "VRT_r_resp_http_(sp)",
"VRT_l_resp_http_(sp, ", "VRT_l_resp_http_(sp, ",
V_RW, V_RW,
0, "HDR_RESP",
VCL_MET_DELIVER VCL_MET_DELIVER
}, },
{ "now", TIME, 3, { "now", TIME, 3,
......
...@@ -57,6 +57,7 @@ vcc_StringVal(struct tokenlist *tl) ...@@ -57,6 +57,7 @@ vcc_StringVal(struct tokenlist *tl)
ERRCHK(tl); ERRCHK(tl);
vp = vcc_FindVar(tl, tl->t, vcc_vars); vp = vcc_FindVar(tl, tl->t, vcc_vars);
ERRCHK(tl); ERRCHK(tl);
assert(vp != NULL);
switch (vp->fmt) { switch (vp->fmt) {
case STRING: case STRING:
Fb(tl, 0, "%s", vp->rname); Fb(tl, 0, "%s", vp->rname);
...@@ -77,7 +78,6 @@ static struct var * ...@@ -77,7 +78,6 @@ static struct var *
HeaderVar(struct tokenlist *tl, const struct token *t, const struct var *vh) HeaderVar(struct tokenlist *tl, const struct token *t, const struct var *vh)
{ {
char *p; char *p;
const char *wh;
struct var *v; struct var *v;
int i; int i;
...@@ -93,23 +93,13 @@ HeaderVar(struct tokenlist *tl, const struct token *t, const struct var *vh) ...@@ -93,23 +93,13 @@ HeaderVar(struct tokenlist *tl, const struct token *t, const struct var *vh)
v->name = p; v->name = p;
v->access = V_RW; v->access = V_RW;
v->fmt = STRING; v->fmt = STRING;
v->ishdr = 1; v->hdr = vh->hdr;
v->methods = vh->methods; v->methods = vh->methods;
if (!memcmp(vh->name, "req.", 4)) asprintf(&p, "VRT_GetHdr(sp, %s, \"\\%03o%s:\")", v->hdr,
wh = "HDR_REQ";
else if (!memcmp(vh->name, "resp.", 5))
wh = "HDR_RESP";
else if (!memcmp(vh->name, "obj.", 4))
wh = "HDR_OBJ";
else if (!memcmp(vh->name, "bereq.", 6))
wh = "HDR_BEREQ";
else
assert(0 == 1);
asprintf(&p, "VRT_GetHdr(sp, %s, \"\\%03o%s:\")", wh,
(unsigned)(strlen(v->name + vh->len) + 1), v->name + vh->len); (unsigned)(strlen(v->name + vh->len) + 1), v->name + vh->len);
AN(p); AN(p);
v->rname = p; v->rname = p;
asprintf(&p, "VRT_SetHdr(sp, %s, \"\\%03o%s:\", ", wh, asprintf(&p, "VRT_SetHdr(sp, %s, \"\\%03o%s:\", ", v->hdr,
(unsigned)(strlen(v->name + vh->len) + 1), v->name + vh->len); (unsigned)(strlen(v->name + vh->len) + 1), v->name + vh->len);
AN(p); AN(p);
v->lname = p; v->lname = p;
......
...@@ -328,7 +328,7 @@ vcc_CheckAction(struct tokenlist *tl) ...@@ -328,7 +328,7 @@ vcc_CheckAction(struct tokenlist *tl)
} }
static struct procuse * static struct procuse *
vcc_FindIllegalUse(struct proc *p, struct method *m) vcc_FindIllegalUse(const struct proc *p, const struct method *m)
{ {
struct procuse *pu; struct procuse *pu;
...@@ -339,7 +339,7 @@ vcc_FindIllegalUse(struct proc *p, struct method *m) ...@@ -339,7 +339,7 @@ vcc_FindIllegalUse(struct proc *p, struct method *m)
} }
static int static int
vcc_CheckUseRecurse(struct tokenlist *tl, struct proc *p, struct method *m) vcc_CheckUseRecurse(struct tokenlist *tl, const struct proc *p, struct method *m)
{ {
struct proccall *pc; struct proccall *pc;
struct procuse *pu; struct procuse *pu;
......
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