The use of a zero flag

Rolf Kalbermatter rolf.kalbermatter at citeng.com
Thu Jan 13 03:56:29 CST 2005


Paul Vriens wrote:

>a few days ago I found a bug in ole32/compobj.c where we did something
>like:
>
>if ( foo & FLAG) .... where FLAG=0
>
>This 'inspired' me to check for more of these kind of checks. 
>
>One that I already found is in dlls/dplayx/dplay.c
>
>We are checking for DPSET_REMOTE (which is zero) where we should have
>checked for !DPSET_LOCAL or something alike.

Often flag sets with a zero flag are more like an enumeration than real
flags and have some sort of mask defined which specifies which bits are
relevant for that group of flags.

Microsoft does something mix real flags and enumeration flags in the same
integer but always at different bit locations.

Something like 

if ((foo & MASK) == FLAG)

will usually work fine then. 

Rolf Kalbermatter 





More information about the wine-devel mailing list