[tor-bugs] #23714 [Core Tor/Tor]: stop casting small integers to (void *)

Tor Bug Tracker & Wiki blackhole at torproject.org
Fri Sep 29 20:24:31 UTC 2017

#23714: stop casting small integers to (void *)
     Reporter:  catalyst      |      Owner:  (none)
         Type:  defect        |     Status:  new
     Priority:  Medium        |  Milestone:  Tor: unspecified
    Component:  Core Tor/Tor  |    Version:
     Severity:  Normal        |   Keywords:  portability technical-debt
Actual Points:                |  Parent ID:
       Points:                |   Reviewer:
      Sponsor:                |
 Recently someone on IRC seemed confused about some `(void *)` variables
 holding the value `(void *)1`.  Converting integers to pointers is
 implementation defined, and could create invalid pointers.  (Any use of an
 invalid pointer, including assignment or comparison, is undefined
 behavior.)  In addition, it's confusing to people who are less familiar
 with C.

 Many of these uses seem to involve container types that treat a null
 pointer as an absence of an entry, but in situations there's no meaningful
 object to point to if the entry is present.  Storing the addresses of
 small statically allocated objects might be better.

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

More information about the tor-bugs mailing list