[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-users] Bug in netconn_alloc?
From: |
Simon Goldschmidt |
Subject: |
Re: [lwip-users] Bug in netconn_alloc? |
Date: |
Tue, 24 May 2011 09:10:37 +0200 |
"Walter Saegesser" <address@hidden> wrote:
> conn = (struct netconn *)memp_malloc(MEMP_NETCONN);
> ...
> sys_mbox_set_invalid(&conn->acceptmbox);
>
> As far as I see, 'acceptmbox' has not been assigned and thus can hold
> any value - if you are unlucky enough even a valid handle.
The macro sys_mbox_set_invalid() is (like the name says) supposed to set a
pointer to an mbox to a known state so that we can later check if that pointer
is valid (mbox created) or invalid (mbox not created).
E.g. if you defined sys_mbox_t to "void*", then you would
#define sys_mbox_set_invalid(mbox) (*mbox = NULL)
since in that define, mbox would have the type "void**".
It has been changed like that because the previous implementation had the
limitation that sys_mbox_t and sys_sem_t always had to be pointers: we had no
way to "invalidate" them when using aggregated OS elements (since assigning a
value - like NULL - does not work then).
So now you might define sys_mbox_t to "struct your_os_mbox", which has a member
"bool valid". You could then
#define sys_mbox_set_invalid(mbox) ((mbox)->valid = false)
Simon
--
Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de