[master] 98d2e2a69 http: Constify H_Header symbols

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Mon Apr 14 15:47:06 UTC 2025


commit 98d2e2a69e95bd96927177641740250f024d9261
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Tue Apr 1 17:43:07 2025 +0200

    http: Constify H_Header symbols
    
    Using the established hdr_t type definition.
    
    Solves #4304

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index d062de071..a9b81db5b 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -673,12 +673,12 @@ int http_IsFiltered(const struct http *hp, unsigned u, unsigned how);
 #define HTTPH_A_PASS		(1 << 3)	/* Response (b->o) for pass */
 #define HTTPH_C_SPECIFIC	(1 << 4)	/* Connection-specific */
 
-#define HTTPH(a, b, c) extern char *b;
+#define HTTPH(a, b, c) extern hdr_t b;
 #include "tbl/http_headers.h"
 
-extern const char *H__Status;
-extern const char *H__Proto;
-extern const char *H__Reason;
+extern hdr_t H__Status;
+extern hdr_t H__Proto;
+extern hdr_t H__Reason;
 
 // rfc7233,l,1207,1208
 #define http_tok_eq(s1, s2)		(!vct_casecmp(s1, s2))
diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c
index 514bdc77f..f11263b2e 100644
--- a/bin/varnishd/cache/cache_http.c
+++ b/bin/varnishd/cache/cache_http.c
@@ -56,12 +56,12 @@
 
 #define HTTPH(a, b, c) \
 static char _##b[] = "*" a ":"; \
-char *b = _##b;
+hdr_t b = _##b;
 #include "tbl/http_headers.h"
 
-const char *H__Status	= "\010:status:";
-const char *H__Proto	= "\007:proto:";
-const char *H__Reason	= "\010:reason:";
+hdr_t H__Status	= "\010:status:";
+hdr_t H__Proto	= "\007:proto:";
+hdr_t H__Reason	= "\010:reason:";
 
 static char * via_hdr;
 
@@ -111,7 +111,7 @@ static const unsigned char http_asso_values[256] = {
 };
 
 static struct http_hdrflg {
-	char		**hdr;
+	hdr_t		*hdr;
 	unsigned	flag;
 } http_hdrflg[GPERF_MAX_HASH_VALUE + 1] = {
 	{ NULL }, { NULL }, { NULL }, { NULL },
@@ -224,7 +224,7 @@ HTTP_Init(void)
 {
 	struct vsb *vsb;
 
-#define HTTPH(a, b, c) http_init_hdr(b, c);
+#define HTTPH(a, b, c) http_init_hdr(TRUST_ME(b), c);
 #include "tbl/http_headers.h"
 
 	vsb = VSB_new_auto();


More information about the varnish-commit mailing list