[master] 0cfb214dc vrt: Constify sentinel pointers

Nils Goroll nils.goroll at uplex.de
Mon May 19 13:18:05 UTC 2025


commit 0cfb214dc7a50384448a437ffd268319995518fd
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Thu May 15 10:58:48 2025 +0200

    vrt: Constify sentinel pointers
    
    They are pointing to sentinel values, but nothing prevented the
    variables themselves to be assigned a different const value.

diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index fce89425d..5484f75aa 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -55,11 +55,11 @@
 #include "proxy/cache_proxy.h"
 
 // NOT using TOSTRANDS() to create a NULL pointer element despite n == 0
-const struct strands *vrt_null_strands = &(struct strands){
+const struct strands *const vrt_null_strands = &(struct strands){
 	.n = 0,
 	.p = (const char *[1]){NULL}
 };
-const struct vrt_blob *vrt_null_blob = &(struct vrt_blob){
+const struct vrt_blob *const vrt_null_blob = &(struct vrt_blob){
 	.type = VRT_NULL_BLOB_TYPE,
 	.len = 0,
 	.blob = "\0"
diff --git a/include/vrt.h b/include/vrt.h
index 0644063f7..0c17c956f 100644
--- a/include/vrt.h
+++ b/include/vrt.h
@@ -375,7 +375,7 @@ struct strands {
 /*
  * A VCL_STRANDS return value must never be NULL. Use this instead
  */
-extern const struct strands *vrt_null_strands;
+extern const struct strands *const vrt_null_strands;
 
 /*
  * Macros for VCL_STRANDS creation
@@ -409,7 +409,7 @@ struct vrt_blob {
 };
 
 #define VRT_NULL_BLOB_TYPE 0xfade4fa0
-extern const struct vrt_blob *vrt_null_blob;
+extern const struct vrt_blob *const vrt_null_blob;
 
 /***********************************************************************
  * This is the central definition of the mapping from VCL types to


More information about the varnish-commit mailing list