[haiku] Re: Any plans for pthread support?

  • From: Colin Günther <coling@xxxxxx>
  • To: haiku@xxxxxxxxxxxxx
  • Date: Wed, 23 Sep 2009 16:28:31 +0200

Marcus Overhagen schrieb:
Colin Günther <coling@xxxxxx> wrote:
You can take a look of my implementation here: http://dev.osdrawer.net/repositories/changes/haiku-wifi/trunk/wifi/libs/free
bsd_network2/kern_condvar.c

I guess you want feedback, so let me tell you that the code is way to funny
and contains at least one serious bug.
Thanks for taking the time to review it! I'm just replying to the comments I don't understand.
Instead of testing excessivly single error codes using bloated switch 
statements,
it's much better to test for status != B_OK

Your switch cases all miss a "default" for unexpected error codes.

For example, Haiku adds B_NOT_ALLOWED and B_NO_MORE_SEMS
error codes for the semaphore functions which are not documented yet.
You don't need to initialize variables, like
   status_t status = ENOERR;

when they get a value assigned as very next step

     status = acquire_sem_etc(cvp->sema, 1, B_ABSOLUTE_TIMEOUT, 
absoluteTimeout);
This is a bug:
        } while (B_INTERRUPTED && (system_time() < absoluteTimeout));
Mmh, I can't see the bug. Would you mind to clarify?

Testing for a single status only, as in

if (status == B_BAD_SEM_ID)

can easily miss other errors.

Last, I wouldn't put misleading information into panic messages, like:

31                         panic("%s: B_BAD_VALUE. Wow, either someone altered my 
source "
32                                 "code or a memory error caused a swap in my hard 
wired"
33 "bit.\n", __func__);
regards
Marcus

Comedy-Battle! Jetzt ablachen und voten! Neue Comedians, Spontanhumoristen und 
Nachwuchs-Spaßmacher machen gute Laune - bestimmen Sie den Wochensieger!
http://comedy-battle.arcor.de/

Kind Regards
Colin

Other related posts: