summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2019-06-20 16:26:05 -0400
committerNick Mathewson <nickm@torproject.org>2019-06-25 12:51:25 -0400
commitb6457d4c08f601c4e42e64aad47ac9c30c36306e (patch)
treee55ee7afd31ae73116e33d132618474012483333
parent5b252d31ede521bea53c690693a2ab3d74c8fef4 (diff)
downloadtor-b6457d4c08f601c4e42e64aad47ac9c30c36306e.tar.gz
tor-b6457d4c08f601c4e42e64aad47ac9c30c36306e.zip
Extend macros to allow flag arguments.
-rw-r--r--src/app/config/config.c4
-rw-r--r--src/app/config/statefile.c2
-rw-r--r--src/feature/dirauth/shared_random_state.c2
-rw-r--r--src/lib/conf/confmacros.h10
-rw-r--r--src/test/test_confparse.c2
5 files changed, 12 insertions, 8 deletions
diff --git a/src/app/config/config.c b/src/app/config/config.c
index c15236b0e9..5f7a82d15a 100644
--- a/src/app/config/config.c
+++ b/src/app/config/config.c
@@ -259,11 +259,11 @@ DUMMY_TYPECHECK_INSTANCE(or_options_t);
* or_options_t.<b>member</b>"
*/
#define VAR(varname,conftype,member,initvalue) \
- CONFIG_VAR_ETYPE(or_options_t, varname, conftype, member, initvalue)
+ CONFIG_VAR_ETYPE(or_options_t, varname, conftype, member, 0, initvalue)
/* As VAR, but uses a type definition in addition to a type enum. */
#define VAR_D(varname,conftype,member,initvalue) \
- CONFIG_VAR_DEFN(or_options_t, varname, conftype, member, initvalue)
+ CONFIG_VAR_DEFN(or_options_t, varname, conftype, member, 0, initvalue)
#define V(member,conftype,initvalue) \
VAR(#member, conftype, member, initvalue)
diff --git a/src/app/config/statefile.c b/src/app/config/statefile.c
index e0584c62af..4fe415b8cf 100644
--- a/src/app/config/statefile.c
+++ b/src/app/config/statefile.c
@@ -71,7 +71,7 @@ static config_abbrev_t state_abbrevs_[] = {
DUMMY_TYPECHECK_INSTANCE(or_state_t);
#define VAR(varname,conftype,member,initvalue) \
- CONFIG_VAR_ETYPE(or_state_t, varname, conftype, member, initvalue)
+ CONFIG_VAR_ETYPE(or_state_t, varname, conftype, member, 0, initvalue)
#define V(member,conftype,initvalue) \
VAR(#member, conftype, member, initvalue)
diff --git a/src/feature/dirauth/shared_random_state.c b/src/feature/dirauth/shared_random_state.c
index 3cdb223d25..d89f249a72 100644
--- a/src/feature/dirauth/shared_random_state.c
+++ b/src/feature/dirauth/shared_random_state.c
@@ -52,7 +52,7 @@ static const char dstate_cur_srv_key[] = "SharedRandCurrentValue";
DUMMY_TYPECHECK_INSTANCE(sr_disk_state_t);
#define VAR(varname,conftype,member,initvalue) \
- CONFIG_VAR_ETYPE(sr_disk_state_t, varname, conftype, member, initvalue)
+ CONFIG_VAR_ETYPE(sr_disk_state_t, varname, conftype, member, 0, initvalue)
#define V(member,conftype,initvalue) \
VAR(#member, conftype, member, initvalue)
diff --git a/src/lib/conf/confmacros.h b/src/lib/conf/confmacros.h
index 4242137c5a..ff284e681d 100644
--- a/src/lib/conf/confmacros.h
+++ b/src/lib/conf/confmacros.h
@@ -30,12 +30,14 @@
* Most modules that use this macro should wrap it in a local macro that
* sets structtype to the local configuration type.
**/
-#define CONFIG_VAR_ETYPE(structtype, varname, vartype, membername, initval) \
+#define CONFIG_VAR_ETYPE(structtype, varname, vartype, membername, \
+ varflags, initval) \
{ .member = \
{ .name = varname, \
.type = CONFIG_TYPE_ ## vartype, \
.offset = offsetof(structtype, membername), \
}, \
+ .flags = varflags, \
.initvalue = initval \
CONF_TEST_MEMBERS(structtype, vartype, membername) \
}
@@ -44,13 +46,15 @@
* As CONFIG_VAR_XTYPE, but declares a value using an extension type whose
* type definition is <b>vartype</b>_type_defn.
**/
-#define CONFIG_VAR_DEFN(structtype, varname, vartype, membername, initval) \
+#define CONFIG_VAR_DEFN(structtype, varname, vartype, membername, \
+ varflags, initval) \
{ .member = \
- { .name = varname, \
+ { .name = varname, \
.type = CONFIG_TYPE_EXTENDED, \
.type_def = &vartype ## _type_defn, \
.offset = offsetof(structtype, membername), \
}, \
+ .flags = varflags, \
.initvalue = initval \
CONF_TEST_MEMBERS(structtype, vartype, membername) \
}
diff --git a/src/test/test_confparse.c b/src/test/test_confparse.c
index 4bf66f3230..4612419dff 100644
--- a/src/test/test_confparse.c
+++ b/src/test/test_confparse.c
@@ -49,7 +49,7 @@ typedef struct test_struct_t {
static test_struct_t test_struct_t_dummy;
#define VAR(varname,conftype,member,initvalue) \
- CONFIG_VAR_ETYPE(test_struct_t, varname, conftype, member, initvalue)
+ CONFIG_VAR_ETYPE(test_struct_t, varname, conftype, member, 0, initvalue)
#define V(member,conftype,initvalue) \
VAR(#member, conftype, member, initvalue)
#define OBSOLETE(varname) \