[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-users] possible bug in sys_timeout()
From: |
Kieran Mansley |
Subject: |
Re: [lwip-users] possible bug in sys_timeout() |
Date: |
Mon, 16 Feb 2004 13:42:32 +0000 (GMT) |
On Mon, 16 Feb 2004, John Taylor wrote:
> There appears to be bug in the sys_timeout() code at line 40 below. Is
> it pilot error on my part or a real bug?
>
> To exit the for-loop at line 32, the if statement at line 34 must
> evaluate to true. When the IF statement is true then "t->next == NULL"
> or "t->next->time > timeout->time" is true. BUT if "t->next == NULL"
> then I should crash at line 40.
Looks (tentatively) OK to me. Are you seeing a crash, or just think it
should be?
If t->next == NULL then it will only do lines 39-41:
39: timeout->next = t->next;
40: t->next = timeout;
41: break;
Which will become:
39: timeout->next = NULL
40: t->next = timeout;
41: break;
The only things we dereference there are timeout and t, which we know are
not NULL. We don't dereference t->next, so the fact that it points to
NULL shouldn't matter.
So, I guess I'm saying that although the code is a bit cryptic, I think
it's OK!
Kieran