[tor-bugs] #25432 [Core Tor]: remove router.c internal functions from router.h

Tor Bug Tracker & Wiki blackhole at torproject.org
Tue Mar 6 02:06:33 UTC 2018


#25432: remove router.c internal functions from router.h
-----------------------------+------------------------------
     Reporter:  valentecaio  |      Owner:  valentecaio
         Type:  defect       |     Status:  assigned
     Priority:  Low          |  Milestone:
    Component:  Core Tor     |    Version:  Tor: unspecified
     Severity:  Minor        |   Keywords:  easy refactor
Actual Points:               |  Parent ID:
       Points:               |   Reviewer:
      Sponsor:               |
-----------------------------+------------------------------
 These functions (group A):
 {{{
 A
 const char *router_get_description(char *buf, const routerinfo_t *ri);
 const char *node_get_description(char *buf, const node_t *node);
 const char *routerstatus_get_description(char *buf, const routerstatus_t
 *rs);
 const char *extend_info_get_description(char *buf, const extend_info_t
 *ei);
 }}}

 Do the same as these (group B):
 {{{
 B
 const char *router_describe(const routerinfo_t *ri);
 const char *node_describe(const node_t *node);
 const char *routerstatus_describe(const routerstatus_t *ri);
 const char *extend_info_describe(const extend_info_t *ei);
 }}}

 With the difference that those last allocate a buffer, instead of forcing
 the caller to create and pass the buffer as a parameter.

 The functions from group B are an abstraction to the ones from group A:
 they are better because they always generate buffers of enough size (the
 size is NODE_DESC_BUF_LEN). So, we should avoid using group A.

 By now, both groups are declared in the header, and there is only one use
 of a function of group A (router_get_description is used on dirserv.c).

 Also, all those functions are abstractions to format_node_description,
 that should also not be used externally, so we could also remove this one
 from the header.

 The constant NODE_DESC_BUF_LEN is not necessary externally either.

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/25432>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list