vcc: Plug more insignificant leaks

Coverity CID 1362617, CID 1362625, CID 1362626, CID 1362627
parent e9576081
...@@ -194,8 +194,10 @@ vcc_acl_add_entry(struct vcc *tl, const struct acl_e *ae, int l, ...@@ -194,8 +194,10 @@ vcc_acl_add_entry(struct vcc *tl, const struct acl_e *ae, int l,
* If the two rules agree, silently ignore it * If the two rules agree, silently ignore it
* XXX: is that counter intuitive ? * XXX: is that counter intuitive ?
*/ */
if (aen->not == ae2->not) if (aen->not == ae2->not) {
free(aen);
return; return;
}
VSB_cat(tl->sb, "Conflicting ACL entries:\n"); VSB_cat(tl->sb, "Conflicting ACL entries:\n");
vcc_ErrWhere(tl, ae2->t_addr); vcc_ErrWhere(tl, ae2->t_addr);
VSB_cat(tl->sb, "vs:\n"); VSB_cat(tl->sb, "vs:\n");
......
...@@ -149,15 +149,15 @@ vcc_Redef(struct vcc *tl, const char *redef, struct token **t_did, ...@@ -149,15 +149,15 @@ vcc_Redef(struct vcc *tl, const char *redef, struct token **t_did,
*/ */
static void static void
vcc_ParseProbeSpec(struct vcc *tl, const struct symbol *sym, char **name) vcc_ParseProbeSpec(struct vcc *tl, const struct symbol *sym, char **namep)
{ {
struct fld_spec *fs; struct fld_spec *fs;
struct token *t_field; struct token *t_field;
struct token *t_did = NULL, *t_window = NULL, *t_threshold = NULL; struct token *t_did = NULL, *t_window = NULL, *t_threshold = NULL;
struct token *t_initial = NULL; struct token *t_initial = NULL;
struct vsb *vsb;
char *retval;
unsigned window, threshold, initial, status; unsigned window, threshold, initial, status;
char buf[32];
const char *name;
double t; double t;
fs = vcc_FldSpec(tl, fs = vcc_FldSpec(tl,
...@@ -173,25 +173,21 @@ vcc_ParseProbeSpec(struct vcc *tl, const struct symbol *sym, char **name) ...@@ -173,25 +173,21 @@ vcc_ParseProbeSpec(struct vcc *tl, const struct symbol *sym, char **name)
SkipToken(tl, '{'); SkipToken(tl, '{');
vsb = VSB_new_auto(); if (sym != NULL) {
AN(vsb); name = sym->rname;
if (sym != NULL) } else {
VSB_cat(vsb, sym->rname); bprintf(buf, "vgc_probe__%d", tl->nprobe++);
else name = buf;
VSB_printf(vsb, "vgc_probe__%d", tl->nprobe++); }
AZ(VSB_finish(vsb)); Fh(tl, 0, "static const struct vrt_backend_probe %s[] = {{\n", name);
retval = TlDup(tl, VSB_data(vsb)); Fh(tl, 0, "\t.magic = VRT_BACKEND_PROBE_MAGIC,\n");
AN(retval); if (namep != NULL)
VSB_destroy(&vsb); *namep = TlDup(tl, name);
if (name != NULL)
*name = retval;
window = 0; window = 0;
threshold = 0; threshold = 0;
initial = 0; initial = 0;
status = 0; status = 0;
Fh(tl, 0, "static const struct vrt_backend_probe %s[] = {{\n", retval);
Fh(tl, 0, "\t.magic = VRT_BACKEND_PROBE_MAGIC,\n");
while (tl->t->tok != '}') { while (tl->t->tok != '}') {
vcc_IsField(tl, &t_field, fs); vcc_IsField(tl, &t_field, fs);
...@@ -323,7 +319,7 @@ vcc_ParseProbe(struct vcc *tl) ...@@ -323,7 +319,7 @@ vcc_ParseProbe(struct vcc *tl)
sym = VCC_HandleSymbol(tl, PROBE, "vgc_probe"); sym = VCC_HandleSymbol(tl, PROBE, "vgc_probe");
ERRCHK(tl); ERRCHK(tl);
AN(sym); AN(sym);
vcc_ParseProbeSpec(tl, sym, &p); vcc_ParseProbeSpec(tl, sym, NULL);
} }
} }
...@@ -480,6 +476,7 @@ vcc_ParseHostDef(struct vcc *tl, const struct token *t_be, const char *vgcname) ...@@ -480,6 +476,7 @@ vcc_ParseHostDef(struct vcc *tl, const struct token *t_be, const char *vgcname)
} else if (vcc_IdIs(t_field, "probe") && tl->t->tok == '{') { } else if (vcc_IdIs(t_field, "probe") && tl->t->tok == '{') {
vcc_ParseProbeSpec(tl, NULL, &p); vcc_ParseProbeSpec(tl, NULL, &p);
Fb(tl, 0, "\t.probe = %s,\n", p); Fb(tl, 0, "\t.probe = %s,\n", p);
free(p);
ERRCHK(tl); ERRCHK(tl);
} else if (vcc_IdIs(t_field, "probe") && tl->t->tok == ID) { } else if (vcc_IdIs(t_field, "probe") && tl->t->tok == ID) {
if (vcc_IdIs(tl->t, "default")) { if (vcc_IdIs(tl->t, "default")) {
......
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