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

Re: [tor-bugs] #23966 [Core Tor/Tor]: Refactor node_has_curve25519_onion_key() to use node_get_curve25519_onion_key()



#23966: Refactor node_has_curve25519_onion_key() to use
node_get_curve25519_onion_key()
----------------------------+------------------------------------
 Reporter:  teor            |          Owner:  (none)
     Type:  defect          |         Status:  new
 Priority:  Medium          |      Milestone:  Tor: 0.3.3.x-final
Component:  Core Tor/Tor    |        Version:
 Severity:  Normal          |     Resolution:
 Keywords:  easy, refactor  |  Actual Points:
Parent ID:                  |         Points:  0.2
 Reviewer:                  |        Sponsor:
----------------------------+------------------------------------

Comment (by teor):

 Not quite, but you're very close.

 When I read node_get_curve25519_onion_key() and
 node_has_curve25519_onion_key(), I see that they both have a similar
 pattern:
 * check if something exists, and return something
 * check if something else exists, and return something
 * check if something else exists, and return something

 But we don't like duplicate code like this: it makes it easy to make
 mistakes.

 So, what we want to do instead is:
 * leave node_get_curve25519_onion_key() as it is
 * make node_has_curve25519_onion_key() call
 node_get_curve25519_onion_key(), and check if the result is not NULL.

 That way, we remove the duplicate code. And we only need to change one
 function, node_has_curve25519_onion_key().

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/23966#comment:10>
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