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

Re: [tor-bugs] #1789 [Tor Relay]: Wake-up from Hibernation Occurs Day 1 Each Month



#1789: Wake-up from Hibernation Occurs Day 1 Each Month
---------------------------------+------------------------------------------
 Reporter:  BarkerJr             |        Type:  defect   
   Status:  needs_review         |    Priority:  minor    
Milestone:  Tor: 0.2.2.x-final   |   Component:  Tor Relay
  Version:  Tor: 0.2.2.14-alpha  |    Keywords:           
   Parent:                       |  
---------------------------------+------------------------------------------

Comment(by arma):

 {{{
 +  uint64_t soft_limit = DBL_TO_U64(U64_TO_DBL(acct_max) * SOFT_LIM_PCT);
 +  if (acct_max > SOFT_LIM_BYTES && acct_max - SOFT_LIM_BYTES >
 soft_limit) {
 +    soft_limit = acct_max - SOFT_LIM_BYTES;
 +  }
 }}}

 I'm not certain of my C anymore, but it seems like the "acct_max >
 SOFT_LIM_BYTES" part here is redundant, yes? If acct_max - SOFT_LIM_BYTES
 is negative, it's hardly going to find itself > soft_limit, which is a
 uint64, right?

 I mean, I can see the underflow worry if you were assigning acct_max -
 SOFT_LIM_BYTES to a uint64_t before the comparison. But you're not. Are
 compilers really so stupid? Or to say it more nicely, are compilers really
 so fickle?

 Same deal with the later stanza:
 {{{
 +    if (acct_max > expected_usage && acct_max - expected_usage >
 soft_limit)
 +      soft_limit = acct_max - expected_usage;
 }}}

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