[tor-bugs] #18902 [Core Tor/Tor]: Avoid variable shadowing in Tor

Tor Bug Tracker & Wiki blackhole at torproject.org
Mon May 9 17:51:20 UTC 2016


#18902: Avoid variable shadowing in Tor
---------------------------+------------------------------
 Reporter:  teor           |          Owner:  cypherpunks
     Type:  defect         |         Status:  assigned
 Priority:  Medium         |      Milestone:  Tor: 0.2.???
Component:  Core Tor/Tor   |        Version:
 Severity:  Normal         |     Resolution:
 Keywords:  easy refactor  |  Actual Points:
Parent ID:                 |         Points:
 Reviewer:                 |        Sponsor:
---------------------------+------------------------------

Comment (by teor):

 Replying to [comment:6 teor]:
 > One strategy could be to temporarily change outer and inner names, then
 check using a compiler.
 > There is a risk that inner variables will accidentally be changed to the
 outer variable name, but that's the only risk I can see.

 Here is a detailed strategy I thought of, it might not work:
 * Change outer variable names by appending _o:
   * run compiler with -Wshadow and parse the log to create a patch that
 renames all shadowed declarations to _o, handling SMARTLIST_FOREACH as a
 special case
   * run compiler and rename all undeclared identifiers with _o

 * Change inner variable names by appending _j:
   * run compiler with -Wshadow and rename all shadowed declarations with
 _j
   * run compiler and rename all undeclared identifiers with _j

 * Revert _o patch

 * Check for and fix whitespace manually

 * Remove unnecessary redeclarations manually, if you want to

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


More information about the tor-bugs mailing list