>>>>> On Mon, 4 Oct 2004 11:10:43 +0200, "Martin Carlsson" <[EMAIL PROTECTED]> said:

Martin> I noticed in the first patch you assumed times() wraps to 0,
Martin> didn't you?

Actually, in the first patch I tried to be ambivalent, as I wasn't
sure it'd be the same on all systems.
 
Martin> Putting together the original patch I assumed times() 
Martin> wraps to INT_MIN.

I suspect that most systems define clock_t similarly, but...  You have
no guarantee that its going to be defined as an int...

Martin> It would make more sense (to me) if it wrapped to 0 (makes the
Martin> -1 fault code return value more understandable).  Still
Martin> "clock_t" is defined to "long int" so it is not quite clear.

Exactly.  So this doesn't fit.

having a -1 return code is insane.  You need to check the output
argument in the function instead I'd guess.

Anyway, the new code has:

Martin> if (now < snmpv3startClock) {
Martin> result = UINT_MAX - snmpv3startClock + now;
Martin> } else {
Martin> result = now - snmpv3startClock;
Martin> }

Martin> The patch seems OK if times() wraps to INT_MIN. 
Martin> But if it wraps to 0 shouldn't UINT_MAX be INT_MAX? 

Nope.  Remember that the function must *return* a uint.  Thus the
UINT_MAX...  It's calculating the return value.  result is always post
calculation to the return value, which works out quite a bit better to
code.

However, I do think there is a problem in the above if
snmpv3startClock starts off negative, since we'd overflow UINT_MAX.
The better thing would probably be this, which I'll go do:

  if (now < snmpv3startClock) {
    result = UINT_MAX - (snmpv3startClock - now);
  } else {
    result = now - snmpv3startClock;
  }

Martin> There's still a "lumentis" comment in the file.  Nice of you
Martin> to keep it but it's just my little note to find our private
Martin> changes more easily so no need to have it in the distribution.

Thanks.  I did try to take them out, but missed one.  (we try not to
put in attributions in the code; but we do put them into the change logs).

-- 
Wes Hardaker
Sparta


-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
Net-snmp-coders mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to