Commit e5bf34a0 authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

ws: Constify WS_Printf()

Unlike WS_Alloc() it fills the allocated space with the result, which
should be considered constant at this point. And on top of that it's
a constant string and shouldn't be a void pointer.
parent 3e1ad1a1
...@@ -790,7 +790,7 @@ void *WS_Alloc(struct ws *ws, unsigned bytes); ...@@ -790,7 +790,7 @@ void *WS_Alloc(struct ws *ws, unsigned bytes);
void *WS_Copy(struct ws *ws, const void *str, int len); void *WS_Copy(struct ws *ws, const void *str, int len);
uintptr_t WS_Snapshot(struct ws *ws); uintptr_t WS_Snapshot(struct ws *ws);
int WS_Overflowed(const struct ws *ws); int WS_Overflowed(const struct ws *ws);
void *WS_Printf(struct ws *ws, const char *fmt, ...) v_printflike_(2, 3); const char *WS_Printf(struct ws *ws, const char *fmt, ...) v_printflike_(2, 3);
int WS_Inside(const struct ws *, const void *, const void *); int WS_Inside(const struct ws *, const void *, const void *);
void WS_Assert_Allocated(const struct ws *ws, const void *ptr, ssize_t len); void WS_Assert_Allocated(const struct ws *ws, const void *ptr, ssize_t len);
......
...@@ -282,7 +282,7 @@ http_SetH(struct http *to, unsigned n, const char *fm) ...@@ -282,7 +282,7 @@ http_SetH(struct http *to, unsigned n, const char *fm)
static void static void
http_PutField(struct http *to, int field, const char *string) http_PutField(struct http *to, int field, const char *string)
{ {
char *p; const char *p;
CHECK_OBJ_NOTNULL(to, HTTP_MAGIC); CHECK_OBJ_NOTNULL(to, HTTP_MAGIC);
p = WS_Copy(to->ws, string, -1); p = WS_Copy(to->ws, string, -1);
...@@ -1182,7 +1182,7 @@ void ...@@ -1182,7 +1182,7 @@ void
http_CopyHome(const struct http *hp) http_CopyHome(const struct http *hp)
{ {
unsigned u, l; unsigned u, l;
char *p; const char *p;
for (u = 0; u < hp->nhd; u++) { for (u = 0; u < hp->nhd; u++) {
if (hp->hd[u].b == NULL) { if (hp->hd[u].b == NULL) {
......
...@@ -224,7 +224,7 @@ WS_Copy(struct ws *ws, const void *str, int len) ...@@ -224,7 +224,7 @@ WS_Copy(struct ws *ws, const void *str, int len)
return (r); return (r);
} }
void * const char *
WS_Printf(struct ws *ws, const char *fmt, ...) WS_Printf(struct ws *ws, const char *fmt, ...)
{ {
unsigned u, v; unsigned u, v;
......
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
* Added VRT_DirectorResolve() * Added VRT_DirectorResolve()
* Added VCL_STRING VRT_BLOB_string(VRT_CTX, VCL_BLOB) * Added VCL_STRING VRT_BLOB_string(VRT_CTX, VCL_BLOB)
* [cache.h] WS_Reserve() removed * [cache.h] WS_Reserve() removed
* [cache.h] WS_Printf() changed
* 11.0 (2020-03-16) * 11.0 (2020-03-16)
* Changed type of vsa_suckaddr_len from int to size_t * Changed type of vsa_suckaddr_len from int to size_t
* New prefix_{ptr|len} fields in vrt_backend * New prefix_{ptr|len} fields in vrt_backend
......
...@@ -58,8 +58,8 @@ static pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER; ...@@ -58,8 +58,8 @@ static pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER;
struct cookie { struct cookie {
unsigned magic; unsigned magic;
#define VMOD_COOKIE_ENTRY_MAGIC 0x3BB41543 #define VMOD_COOKIE_ENTRY_MAGIC 0x3BB41543
char *name; const char *name;
char *value; const char *value;
VTAILQ_ENTRY(cookie) list; VTAILQ_ENTRY(cookie) list;
}; };
...@@ -163,7 +163,7 @@ vmod_set(VRT_CTX, struct vmod_priv *priv, VCL_STRING name, VCL_STRING value) ...@@ -163,7 +163,7 @@ vmod_set(VRT_CTX, struct vmod_priv *priv, VCL_STRING name, VCL_STRING value)
{ {
struct vmod_cookie *vcp = cobj_get(priv); struct vmod_cookie *vcp = cobj_get(priv);
struct cookie *cookie; struct cookie *cookie;
char *p; const char *p;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(ctx->ws, WS_MAGIC); CHECK_OBJ_NOTNULL(ctx->ws, WS_MAGIC);
......
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