Refactor "OBSOLETE" type

It no longer warns, and is now defined in terms of an "IGNORE" type.

(The "IGNORE" type is the same as "OBSOLETE", except that it is not
reported as obsolete. It should be useful for disabled modules.)

Closes ticket 32404.
This commit is contained in:
Nick Mathewson 2019-11-07 09:25:56 -05:00
parent 36af84ba50
commit a08969e460
4 changed files with 15 additions and 9 deletions

5
changes/ticket32404 Normal file
View File

@ -0,0 +1,5 @@
o Minor features (configuration):
- We use a flag-driven logic to warn about obsolete configuration fields,
so that we can include their names. In 0.4.2, we used
a special type, which prevented us from generating good warnings.
Implements ticket 32404.

View File

@ -191,6 +191,7 @@ extern const struct var_type_def_t CSV_INTERVAL_type_defn;
extern const struct var_type_def_t LINELIST_type_defn;
extern const struct var_type_def_t LINELIST_V_type_defn;
extern const struct var_type_def_t LINELIST_S_type_defn;
extern const struct var_type_def_t IGNORE_type_defn;
extern const struct var_type_def_t OBSOLETE_type_defn;
/**@}*/

View File

@ -64,7 +64,8 @@ typedef enum config_type_t {
CONFIG_TYPE_LINELIST_V, /**< Catch-all "virtual" option to summarize
* context-sensitive config lines when fetching.
*/
CONFIG_TYPE_OBSOLETE, /**< Obsolete (ignored) option. */
CONFIG_TYPE_OBSOLETE, /**< Ignored (obsolete) option. Uses no storage. */
CONFIG_TYPE_IGNORE, /**< Ignored option. Uses no storage. */
/**
* Extended type: definition appears in the <b>type_def</b> pointer
* of the corresponding struct_member_t.

View File

@ -682,17 +682,13 @@ static const var_type_fns_t linelist_s_fns = {
/////
// CONFIG_TYPE_ROUTERSET
//
// XXXX This type is not implemented here, since routerset_t is not available
// XXXX to this module.
/////
/////
// CONFIG_TYPE_OBSOLETE
// CONFIG_TYPE_IGNORE
//
// Used to indicate an obsolete option.
//
// XXXX This is not a type, and should be handled at a higher level of
// XXXX abstraction.
// Used to indicate an option that cannot be stored or encoded.
/////
static int
@ -703,8 +699,6 @@ ignore_parse(void *target, const char *value, char **errmsg,
(void)value;
(void)errmsg;
(void)params;
// XXXX move this to a higher level, once such a level exists.
log_warn(LD_GENERAL, "Skipping obsolete configuration option.");
return 0;
}
@ -774,6 +768,10 @@ const var_type_def_t LINELIST_S_type_defn = {
const var_type_def_t LINELIST_V_type_defn = {
.name="Virtual", .fns=&linelist_v_fns,
.flags=CFLG_NOREPLACE|CFLG_NOSET };
const var_type_def_t IGNORE_type_defn = {
.name="Ignored", .fns=&ignore_fns,
.flags=CFLG_NOCOPY|CFLG_NOCMP|CFLG_NODUMP|CFLG_NOSET,
};
const var_type_def_t OBSOLETE_type_defn = {
.name="Obsolete", .fns=&ignore_fns,
.flags=CFLG_GROUP_OBSOLETE,
@ -800,6 +798,7 @@ static const var_type_def_t *type_definitions_table[] = {
[CONFIG_TYPE_LINELIST] = &LINELIST_type_defn,
[CONFIG_TYPE_LINELIST_S] = &LINELIST_S_type_defn,
[CONFIG_TYPE_LINELIST_V] = &LINELIST_V_type_defn,
[CONFIG_TYPE_IGNORE] = &IGNORE_type_defn,
[CONFIG_TYPE_OBSOLETE] = &OBSOLETE_type_defn,
};