[master] f4f41c51c Use vmod symbol instead of vmod name

Poul-Henning Kamp phk at FreeBSD.org
Fri May 17 08:14:11 UTC 2019


commit f4f41c51cb5c3f9dd2e21b9e785ae94bffcb85e7
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Fri May 17 06:19:09 2019 +0000

    Use vmod symbol instead of vmod name

diff --git a/lib/libvcc/vcc_compile.h b/lib/libvcc/vcc_compile.h
index 00b45d15a..f164a9e92 100644
--- a/lib/libvcc/vcc_compile.h
+++ b/lib/libvcc/vcc_compile.h
@@ -144,7 +144,7 @@ struct symbol {
 	int				hirev;
 
 	struct symbol			*parent;
-	const char			*vmod;
+	const struct symbol		*vmod;
 
 	sym_wildcard_t			*wildcard;
 	vcc_kind_t			kind;
@@ -356,7 +356,8 @@ extern const char SYMTAB_NOERR[];
 extern const char SYMTAB_CREATE[];
 struct symbol *VCC_SymbolGet(struct vcc *, vcc_kind_t, const char *,
     const char *);
-struct symbol *VCC_SymbolGetTok(struct vcc *, vcc_kind_t, const char *, const char *, struct token *);
+struct symbol *VCC_SymbolGetTok(struct vcc *, vcc_kind_t, const char *,
+    const char *, const struct token *);
 
 typedef void symwalk_f(struct vcc *tl, const struct symbol *s);
 void VCC_WalkSymbols(struct vcc *tl, symwalk_f *func, vcc_kind_t);
diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c
index d04444dae..9638b519f 100644
--- a/lib/libvcc/vcc_expr.c
+++ b/lib/libvcc/vcc_expr.c
@@ -355,22 +355,24 @@ vcc_priv_arg(struct vcc *tl, const char *p, const struct symbol *sym)
 {
 	char buf[64];
 	struct inifin *ifp;
-	const char *vmod, *f = NULL;
+	const char *f = NULL;
 	struct procprivhead *marklist = NULL;
 
 	AN(sym);
 	AN(sym->vmod);
-	vmod = sym->vmod;
 
-	if (!strcmp(p, "PRIV_VCL")) {
-		return (vcc_mk_expr(VOID, "&vmod_priv_%s", vmod));
-	} else if (!strcmp(p, "PRIV_CALL")) {
+	if (!strcmp(p, "PRIV_VCL"))
+		return (vcc_mk_expr(VOID, "&vmod_priv_%s", sym->vmod->name));
+
+	if (!strcmp(p, "PRIV_CALL")) {
 		bprintf(buf, "vmod_priv_%u", tl->unique++);
 		ifp = New_IniFin(tl);
 		Fh(tl, 0, "static struct vmod_priv %s;\n", buf);
 		VSB_printf(ifp->fin, "\tVRT_priv_fini(&%s);", buf);
 		return (vcc_mk_expr(VOID, "&%s", buf));
-	} else if (!strcmp(p, "PRIV_TASK")) {
+	}
+
+	if (!strcmp(p, "PRIV_TASK")) {
 		f = "task";
 		marklist = &tl->curproc->priv_tasks;
 	} else if (!strcmp(p, "PRIV_TOP")) {
@@ -381,9 +383,9 @@ vcc_priv_arg(struct vcc *tl, const char *p, const struct symbol *sym)
 	}
 	AN(f);
 	AN(marklist);
-	bprintf(buf, "ARG_priv_%s_%s", f, vmod);
+	bprintf(buf, "ARG_priv_%s_%s", f, sym->vmod->name);
 
-	if (vcc_MarkPriv(tl, marklist, vmod) == NULL)
+	if (vcc_MarkPriv(tl, marklist, sym->vmod->name) == NULL)
 		VSB_printf(tl->curproc->prologue,
 			   "  struct vmod_priv *%s = "
 			   "VRT_priv_%s(ctx, &VGC_vmod_%s);\n"
@@ -392,7 +394,7 @@ vcc_priv_arg(struct vcc *tl, const char *p, const struct symbol *sym)
 			   "for vmod %s\");\n"
 			   "    return;\n"
 			   "  }\n",
-			   buf, f, vmod, buf, f, vmod);
+			   buf, f, sym->vmod->name, buf, f, sym->vmod->name);
 	return (vcc_mk_expr(VOID, "%s", buf));
 }
 
diff --git a/lib/libvcc/vcc_symb.c b/lib/libvcc/vcc_symb.c
index a7c8880e0..25a2573cb 100644
--- a/lib/libvcc/vcc_symb.c
+++ b/lib/libvcc/vcc_symb.c
@@ -199,7 +199,7 @@ const char SYMTAB_CREATE[] = "sym_create";
 
 struct symbol *
 VCC_SymbolGetTok(struct vcc *tl, vcc_kind_t kind, const char *e, const char *x,
-    struct token *t)
+    const struct token *t)
 {
 	struct symbol *sym;
 
diff --git a/lib/libvcc/vcc_vmod.c b/lib/libvcc/vcc_vmod.c
index 61380edf2..6eadd44dc 100644
--- a/lib/libvcc/vcc_vmod.c
+++ b/lib/libvcc/vcc_vmod.c
@@ -57,7 +57,8 @@ vcc_path_dlopen(void *priv, const char *fn)
 }
 
 static void
-func_sym(struct symbol *sym, const char *vmod, const struct vjsn_val *v)
+func_sym(struct symbol *sym, const struct symbol *vmod,
+    const struct vjsn_val *v)
 {
 
 	assert(v->type == VJSN_ARRAY);
@@ -139,13 +140,13 @@ vcc_json_wildcard(struct vcc *tl, struct symbol *msym, struct symbol *tsym)
 		    !strcmp(vv2->value, tsym->name)) {
 			tsym->kind = SYM_FUNC;
 			tsym->noref = 1;
-			func_sym(tsym, msym->name, VTAILQ_NEXT(vv2, list));
+			func_sym(tsym, msym, VTAILQ_NEXT(vv2, list));
 			return;
 		} else if (!strcmp(vv1->value, "$OBJ") &&
 			   !strcmp(vv2->value, tsym->name)) {
 			tsym->kind = SYM_OBJECT;
 			tsym->eval_priv = vv2;
-			tsym->vmod = msym->name;
+			tsym->vmod = msym;
 			return;
 		}
 	}


More information about the varnish-commit mailing list