Subject: Re: CVS commit: src/sys/kern
To: None <>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: tech-kern
Date: 10/22/2006 21:13:50
>>> pool_get(): use PR_WAITOK, not M_WAITOK (which happens to be PR_NOWAIT ..)
>>> XXX: not the first time this mistake has been made
>> find /usr/src/sys -name *.[ch"]" -exec grep -l pool_.*M_ "{"} ";"
>> I think we should use different values for the constants and, if
>> DIAGNOSTIC, assert that the constant is in fact in the correct
>> range.
> Could the compiler help here?  For example, if we used enums instead
> of plain int and macros?

No; C enums are too weakly typed.  If you really want the compiler to
help you you could do something like

typedef struct malloc_waitflag MALLOC_WAITFLAG;
struct malloc_waitflag { int v; };
extern void *malloc(unsigned long, int type, MALLOC_WAITFLAG waitflag);

but this complicates all code that needs to check the flag, because it
has to check waitflag.v.  It also makes it more difficult to use
multiple flag bits.

/~\ The ASCII				der Mouse
\ / Ribbon Campaign
 X  Against HTML
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B