[master] a093bd646 param: Fold mgt_param_tbl.c into mgt_param.c

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Mon May 30 14:04:06 UTC 2022


commit a093bd646075c09713f4e08d91bbac2d07b6f85b
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Fri Mar 11 18:55:38 2022 +0100

    param: Fold mgt_param_tbl.c into mgt_param.c

diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am
index 8e8d6b117..79383fbb6 100644
--- a/bin/varnishd/Makefile.am
+++ b/bin/varnishd/Makefile.am
@@ -87,7 +87,6 @@ varnishd_SOURCES = \
 	mgt/mgt_main.c \
 	mgt/mgt_param.c \
 	mgt/mgt_param_bits.c \
-	mgt/mgt_param_tbl.c \
 	mgt/mgt_param_tcp.c \
 	mgt/mgt_param_tweak.c \
 	mgt/mgt_shmem.c \
diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h
index 9853f51a5..2ca6a8594 100644
--- a/bin/varnishd/mgt/mgt.h
+++ b/bin/varnishd/mgt/mgt.h
@@ -191,7 +191,6 @@ void MCF_ParamConf(enum mcf_which_e, const char *param, const char *, ...)
 void MCF_ParamSet(struct cli *, const char *param, const char *val);
 void MCF_ParamProtect(struct cli *, const char *arg);
 void MCF_DumpRstParam(void);
-void MCF_AddParams(struct parspec *ps);
 extern struct params mgt_param;
 
 /* mgt_shmem.c */
diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c
index 0aae0c75f..b34fe6772 100644
--- a/bin/varnishd/mgt/mgt_param.c
+++ b/bin/varnishd/mgt/mgt_param.c
@@ -610,16 +610,25 @@ mcf_param_reset(struct cli *cli, const char * const *av, void *priv)
 }
 
 /*--------------------------------------------------------------------
- * Add a group of parameters to the global set and sort by name.
+ * Initialize parameters and sort by name.
  */
 
-void
-MCF_AddParams(struct parspec *ps)
+static struct parspec mgt_parspec[] = {
+#define PARAM_ALL
+#define PARAM_PRE {
+#define PARAM(typ, fld, nm, ...) #nm, __VA_ARGS__
+#define PARAM_POST },
+#include "tbl/params.h"
+	{ NULL, NULL, NULL }
+};
+
+static void
+mcf_init_params(void)
 {
 	struct parspec *pp;
 	const char *s;
 
-	for (pp = ps; pp->name != NULL; pp++) {
+	for (pp = mgt_parspec; pp->name != NULL; pp++) {
 		AN(pp->func);
 		s = strchr(pp->descr, '\0');
 		if (isspace(s[-1])) {
@@ -720,9 +729,7 @@ MCF_InitParams(struct cli *cli)
 	struct vsb *vsb;
 	ssize_t def, low;
 
-	MCF_AddParams(mgt_parspec);
-	MCF_AddParams(VSL_parspec);
-
+	mcf_init_params();
 	MCF_TcpParams();
 
 	def = 80 * 1024;
diff --git a/bin/varnishd/mgt/mgt_param.h b/bin/varnishd/mgt/mgt_param.h
index 694b26d31..f95e965fd 100644
--- a/bin/varnishd/mgt/mgt_param.h
+++ b/bin/varnishd/mgt/mgt_param.h
@@ -87,7 +87,3 @@ tweak_t tweak_uint;
 tweak_t tweak_vsl_buffer;
 tweak_t tweak_vsl_mask;
 tweak_t tweak_vsl_reclen;
-
-extern struct parspec mgt_parspec[]; /* mgt_param_tbl.c */
-extern struct parspec VSL_parspec[]; /* mgt_param_vsl.c */
-extern struct parspec WRK_parspec[]; /* mgt_pool.c */
diff --git a/bin/varnishd/mgt/mgt_param_bits.c b/bin/varnishd/mgt/mgt_param_bits.c
index 96e8a6df3..3ec359ffe 100644
--- a/bin/varnishd/mgt/mgt_param_bits.c
+++ b/bin/varnishd/mgt/mgt_param_bits.c
@@ -215,11 +215,3 @@ tweak_feature(struct vsb *vsb, const struct parspec *par, const char *arg)
 	return (tweak_generic_bits(vsb, par, arg, mgt_param.feature_bits,
 	    FEATURE_Reserved, feature_tags, "feature bit", '+'));
 }
-
-/*--------------------------------------------------------------------
- * The parameter table itself
- */
-
-struct parspec VSL_parspec[] = {
-	{ NULL, NULL, NULL }
-};
diff --git a/bin/varnishd/mgt/mgt_param_tbl.c b/bin/varnishd/mgt/mgt_param_tbl.c
deleted file mode 100644
index 50995411c..000000000
--- a/bin/varnishd/mgt/mgt_param_tbl.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/*-
- * Copyright (c) 2006 Verdens Gang AS
- * Copyright (c) 2006-2015 Varnish Software AS
- * All rights reserved.
- *
- * Author: Poul-Henning Kamp <phk at phk.freebsd.dk>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include <stdio.h>
-
-#include "mgt/mgt.h"
-#include "mgt/mgt_param.h"
-
-struct parspec mgt_parspec[] = {
-#define PARAM_ALL
-#define PARAM_PRE {
-#define PARAM(typ, fld, nm, ...) #nm, __VA_ARGS__
-#define PARAM_POST },
-#include "tbl/params.h"
-	{ NULL, NULL, NULL }
-};


More information about the varnish-commit mailing list