[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-bugs] #25914 [Core Tor/Tor]: dirserv: Remove dead code



#25914: dirserv: Remove dead code
-------------------------+-------------------------------------------------
     Reporter:  dgoulet  |      Owner:  dgoulet
         Type:  defect   |     Status:  assigned
     Priority:  Medium   |  Milestone:  Tor: 0.3.4.x-final
    Component:  Core     |    Version:
  Tor/Tor                |   Keywords:  tor-dirauth, deadcode, easy, 034
     Severity:  Normal   |  -roadmap-subtask
Actual Points:           |  Parent ID:  #25610
       Points:           |   Reviewer:
      Sponsor:           |
-------------------------+-------------------------------------------------
 While working on #25610, I've noticed dead code that uses
 `dirserv_get_consensus()`.

 In `networkstatus.c`, function `networkstatus_set_current_consensus()`:

 We parse the flavor and if it is unknown, we bail early with:

 {{{
   if (flav < 0) {
     /* XXXX we don't handle unrecognized flavors yet. */
     log_warn(LD_BUG, "Unrecognized consensus flavor %s", flavor);
     return -2;
   }
 }}}

 But later in the function we have this if/else on the flavor name with a
 `else {}` statement that uses `dirserv_get_consensus()`. But we can't get
 into that else case since the first conditions are the only two flavors we
 can handle.

 In between the first checks above and this if/else ^, the flavor can
 change as in we take the one from the given consensus but again, there is
 a check on if we can handle that flavor:

 {{{
   if (flav != usable_consensus_flavor() &&
       !we_want_to_fetch_flavor(options, flav)) {
 }}}

 Bottom line, I think the `else {}` code is dead code. This simplifies the
 callgraph into the dirauth subsystem.

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/25914>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
_______________________________________________
tor-bugs mailing list
tor-bugs@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs