[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Extend macros to allow flag arguments.
commit b6457d4c08f601c4e42e64aad47ac9c30c36306e
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Thu Jun 20 16:26:05 2019 -0400
Extend macros to allow flag arguments.
---
src/app/config/config.c | 4 ++--
src/app/config/statefile.c | 2 +-
src/feature/dirauth/shared_random_state.c | 2 +-
src/lib/conf/confmacros.h | 10 +++++++---
src/test/test_confparse.c | 2 +-
5 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/src/app/config/config.c b/src/app/config/config.c
index c15236b0e..5f7a82d15 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 e0584c62a..4fe415b8c 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 3cdb223d2..d89f249a7 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 4242137c5..ff284e681 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 4bf66f323..4612419df 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) \
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits