[master] 80b3ecc Make VRT_String() return a const char *
Poul-Henning Kamp
phk at varnish-cache.org
Wed May 1 14:36:44 CEST 2013
commit 80b3ecc00e764db3351786e75b871fe1535a1260
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Wed May 1 12:36:21 2013 +0000
Make VRT_String() return a const char *
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index ccbd56c..865b315 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -638,7 +638,7 @@ struct req {
double t_resp;
struct http_conn htc[1];
- char *client_identity;
+ const char *client_identity;
/* HTTP request */
struct http *http;
@@ -1029,7 +1029,11 @@ const char *VCL_Method_Name(unsigned);
/* cache_vrt.c */
-char *VRT_String(struct ws *ws, const char *h, const char *p, va_list ap);
+/*
+ * These prototypes go here, because we do not want to pollute vrt.h
+ * with va_list. VCC never generates direct calls to them.
+ */
+const char *VRT_String(struct ws *ws, const char *h, const char *p, va_list ap);
char *VRT_StringList(char *d, unsigned dl, const char *p, va_list ap);
void ESI_Deliver(struct req *);
diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index f85669d..a298ad7 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -116,11 +116,13 @@ vrt_selecthttp(const struct vrt_ctx *ctx, enum gethdr_e where)
hp = ctx->http_obj;
break;
default:
- INCOMPL();
+ WRONG("vrt_selecthttp 'where' invalid");
}
return (hp);
}
+/*--------------------------------------------------------------------*/
+
char *
VRT_GetHdr(const struct vrt_ctx *ctx, const struct gethdr_s *hs)
{
@@ -136,7 +138,7 @@ VRT_GetHdr(const struct vrt_ctx *ctx, const struct gethdr_s *hs)
}
/*--------------------------------------------------------------------
- * XXX: Optimize the single element case ?
+ * Collapse a STRING_LIST in the space provided, or return NULL
*/
char *
@@ -163,10 +165,10 @@ VRT_StringList(char *d, unsigned dl, const char *p, va_list ap)
}
/*--------------------------------------------------------------------
- * XXX: Optimize the single element case ?
+ * Copy and merge a STRING_LIST into a workspace.
*/
-char *
+const char *
VRT_String(struct ws *ws, const char *h, const char *p, va_list ap)
{
char *b, *e;
@@ -196,14 +198,14 @@ VRT_String(struct ws *ws, const char *h, const char *p, va_list ap)
}
/*--------------------------------------------------------------------
- * Build a string on the request workspace
+ * Copy and merge a STRING_LIST on the current workspace
*/
const char *
VRT_CollectString(const struct vrt_ctx *ctx, const char *p, ...)
{
va_list ap;
- char *b;
+ const char *b;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(ctx->ws, WS_MAGIC);
@@ -221,7 +223,7 @@ VRT_SetHdr(const struct vrt_ctx *ctx , const struct gethdr_s *hs,
{
struct http *hp;
va_list ap;
- char *b;
+ const char *b;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
AN(hs);
diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c
index 6b79f9c..7e9f133 100644
--- a/bin/varnishd/cache/cache_vrt_var.c
+++ b/bin/varnishd/cache/cache_vrt_var.c
@@ -50,7 +50,7 @@ static void
vrt_do_string(const struct http *hp, int fld,
const char *err, const char *p, va_list ap)
{
- char *b;
+ const char *b;
AN(hp);
b = VRT_String(hp->ws, NULL, p, ap);
@@ -165,7 +165,7 @@ void
VRT_l_client_identity(const struct vrt_ctx *ctx, const char *str, ...)
{
va_list ap;
- char *b;
+ const char *b;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC);
@@ -248,7 +248,7 @@ void
VRT_l_beresp_storage(const struct vrt_ctx *ctx, const char *str, ...)
{
va_list ap;
- char *b;
+ const char *b;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC);
diff --git a/include/vrt.h b/include/vrt.h
index 05b6cde..1394668 100644
--- a/include/vrt.h
+++ b/include/vrt.h
@@ -260,5 +260,4 @@ char *VRT_REAL_string(const struct vrt_ctx *, double);
char *VRT_TIME_string(const struct vrt_ctx *, double);
const char *VRT_BOOL_string(unsigned);
const char *VRT_BACKEND_string(const struct director *d);
-
const char *VRT_CollectString(const struct vrt_ctx *, const char *p, ...);
diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c
index 5583a4f..083962f 100644
--- a/lib/libvmod_debug/vmod_debug.c
+++ b/lib/libvmod_debug/vmod_debug.c
@@ -39,7 +39,7 @@ VCL_VOID __match_proto__(td_debug_panic)
vmod_panic(const struct vrt_ctx *ctx, const char *str, ...)
{
va_list ap;
- char *b;
+ const char *b;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
va_start(ap, str);
More information about the varnish-commit
mailing list