Opened 4 weeks ago

Last modified 4 weeks ago

#30935 needs_review enhancement

Move variable definition code out of confparse.c, and refactor

Reported by: nickm Owned by: nickm
Priority: Medium Milestone: Tor: 0.4.2.x-final
Component: Core Tor/Tor Version:
Severity: Normal Keywords:
Cc: Actual Points: 0.5
Parent ID: #29211 Points: 1
Reviewer: catalyst Sponsor: Sponsor31-can

Description


Child Tickets

Change History (4)

comment:1 Changed 4 weeks ago by nickm

Actual Points: 0.5

See branch ticket30935 with PR at https://github.com/torproject/tor/pull/1126 .

It is based on #30914, so the earlier commits in this branch should be reviewed there.

comment:2 Changed 4 weeks ago by nickm

Status: assignedneeds_review

comment:3 Changed 4 weeks ago by dgoulet

Reviewer: catalyst

comment:4 Changed 4 weeks ago by nickm

Here's an overview of the commits in this branch.

Move config_var_t info conftypes.h

Pure code movement.

Move responsibility for config var macros

Refactors the macros that we have used to create config_var_t, and reduces code duplication.

Previously the macros used to define variables were redefined in every module that needed them; now they are derived from a common source. This makes them easier to change and refactor.

This commit also moves code only used for test builds into a new "conftesting.h" header.

Add a "flags" member to config_var_t

Add an (unused) flags member, and makes corresponding adjustments to the macros.

Extend macros to allow flag arguments.

Add a flags argument to the variable-definition macros.

Turn several properties of types or variables into flags.
Make "invisibility" and "undumpability" properties of variables.

These two commits are the bigger refactorings of this branch: they remove all the places in config or confparse that had previously tried to do manual inspection of a variable's type or names. To follow OO principles, we should turn these checks and inspections into properties of the types or variables themselves.

Refactor handling of TestingTorNetwork

The TestingTorNetwork option overrides the defaults for a bunch of other options. Its previous implementation was a nasty kludge that included a bunch of duplicated code, and involved overwriting the "initval" field of a bunch of config_var_t objects.

This new implementation should be much cleaner and easier to understand. It works by modifying the initially constructed or_options_t object whenever any code ask for an "initialized to defaults" object.

Make config_var and config_fmt const.

Thanks to the previous commit, we can now make more object const -- and should.

Move confparse.ch into lib/confmgt.

Code movement and header renaming. Once we moved the responsibility for handling routerset_t out of confparse.c, we no longer need confparse.c to be at a higher level than src/core. This patch lowers it.

(Edited to add: I've removed this patch from the branch for now, since I expect it will make fixup commits on this and previous patches very hard.)

Last edited 4 weeks ago by nickm (previous) (diff)
Note: See TracTickets for help on using tickets.