[Olsr-users] 0.5.6 Routes disappear after 4 mins of uptime, then all OK - suspect clock sync

Henning Rogge (spam-protected)
Thu Sep 4 20:19:24 CEST 2008


On Thu, Sep 4, 2008 at 17:37, Bernd Petrovitsch <(spam-protected)> wrote:
> On Thu, 2008-09-04 at 16:31 +0200, Hannes Gredler wrote:
> [....]
>> don't know - perhaps now now - at least we should fix the overflow
>> detection. (your previous patch) when comparing timestamps to now.
>
> Apart from a superfluous '{' (or missing '}';-), the notorious
> department of "minimized run-time code" uses usually more something
> like:
> ----  snip  ----
> int time_cmp(const olsr_u32_t t1, const olsr_u32_t t2)
> {
>    const olsr_32_t diff = t1 - t2;
>    return diff == 0 ? 0 : diff < 0 : -1 : 1;
> }


This code is completely unreadable in my oppinion, sorry.

A ?: operator in C is just another way to define a conditional operation.

I see no reason why the code should be any faster than

int time_cmp(const olsr_u32_t t1, const olsr_u32_t t2)
{
   const olsr_32_t diff = t1 - t2;
   if (diff > 0)
      return 1;
   if (diff < 0)
      return -1;
   return 0;
}

Henning

-- 
"Wo kämen wir hin, wenn alle sagten, wo kämem wir hin, und niemand
ginge, um einmal zu schauen, wohin man käme, wenn man ginge." (Kurt
Marti)




More information about the Olsr-users mailing list