[master] dbfcff3 Add SLT__MAX define (256) for max tag of a VSL record

Martin Blix Grydeland martin at varnish-cache.org
Tue Oct 1 14:48:18 CEST 2013


commit dbfcff3000138638774dee211ae384147c577855
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date:   Mon Sep 23 10:31:16 2013 +0200

    Add SLT__MAX define (256) for max tag of a VSL record

diff --git a/include/vapi/vsl.h b/include/vapi/vsl.h
index 27d3b87..feb2faa 100644
--- a/include/vapi/vsl.h
+++ b/include/vapi/vsl.h
@@ -95,7 +95,7 @@ typedef int VSLQ_dispatch_f(struct VSL_data *vsl,
 	 *   !=0: Makes VSLQ_Dispatch return with this return value immediatly
 	 */
 
-extern const char *VSL_tags[256];
+extern const char *VSL_tags[SLT__MAX];
 	/*
 	 * Tag to string array.  Contains NULL for invalid tags.
 	 */
diff --git a/include/vapi/vsl_int.h b/include/vapi/vsl_int.h
index 196bf98..02a9cb0 100644
--- a/include/vapi/vsl_int.h
+++ b/include/vapi/vsl_int.h
@@ -104,6 +104,7 @@ struct VSL_head {
  * The identifiers in shmlogtag are "SLT_" + XML tag.  A script may be run
  * on this file to extract the table rather than handcode it
  */
+#define SLT__MAX 256
 enum VSL_tag_e {
 	SLT__Bogus = 0,
 #define SLTM(foo,sdesc,ldesc)	SLT_##foo,
diff --git a/lib/libvarnishapi/vsl.c b/lib/libvarnishapi/vsl.c
index d7a5fa8..a5c9108 100644
--- a/lib/libvarnishapi/vsl.c
+++ b/lib/libvarnishapi/vsl.c
@@ -57,7 +57,7 @@
 
 /*--------------------------------------------------------------------*/
 
-const char *VSL_tags[256] = {
+const char *VSL_tags[SLT__MAX] = {
 #  define SLTM(foo,sdesc,ldesc)       [SLT_##foo] = #foo,
 #  include "tbl/vsl_tags.h"
 #  undef SLTM
@@ -91,8 +91,8 @@ VSL_New(void)
 	if (vsl == NULL)
 		return (NULL);
 
-	vsl->vbm_select = vbit_init(256);
-	vsl->vbm_supress = vbit_init(256);
+	vsl->vbm_select = vbit_init(SLT__MAX);
+	vsl->vbm_supress = vbit_init(SLT__MAX);
 	VTAILQ_INIT(&vsl->vslf_select);
 	VTAILQ_INIT(&vsl->vslf_suppress);
 
diff --git a/lib/libvarnishapi/vsl_arg.c b/lib/libvarnishapi/vsl_arg.c
index 00039ad..8a2c48d 100644
--- a/lib/libvarnishapi/vsl_arg.c
+++ b/lib/libvarnishapi/vsl_arg.c
@@ -67,7 +67,7 @@ VSL_Name2Tag(const char *name, int l)
 	if (l == -1)
 		l = strlen(name);
 	n = -1;
-	for (i = 0; i < 256; i++) {
+	for (i = 0; i < SLT__MAX; i++) {
 		if (VSL_tags[i] != NULL &&
 		    !strncasecmp(name, VSL_tags[i], l)) {
 			if (strlen(VSL_tags[i]) == l) {
@@ -220,7 +220,7 @@ VSL_Arg(struct VSL_data *vsl, int opt, const char *arg)
 	CHECK_OBJ_NOTNULL(vsl, VSL_MAGIC);
 	/* If first option is 'i', set all bits for supression */
 	if ((opt == 'i' || opt == 'I') && !(vsl->flags & F_SEEN_ixIX))
-		for (i = 0; i < 256; i++)
+		for (i = 0; i < SLT__MAX; i++)
 			vbit_set(vsl->vbm_supress, i);
 
 	switch (opt) {



More information about the varnish-commit mailing list